diff options
author | Marco Capitani <m.capitani@nextworks.it> | 2017-04-12 15:56:37 +0200 |
---|---|---|
committer | Marco Capitani <m.capitani@nextworks.it> | 2017-04-12 15:56:37 +0200 |
commit | c83ea6f4b791cd85cd248b039b353c522f2f1f3e (patch) | |
tree | cf3ffb203f0ada7bef09301aa3f3d5400b2d8c7b /rumba/testbeds | |
parent | 46310717c3293054324cc6a0271d855b638df0ff (diff) | |
parent | 6d8d0d30d75b318650034470b376a57a37b57944 (diff) | |
download | rumba-c83ea6f4b791cd85cd248b039b353c522f2f1f3e.tar.gz rumba-c83ea6f4b791cd85cd248b039b353c522f2f1f3e.zip |
Merge branch 'master' into master-marco
Updating with ssh changes (and other)
Diffstat (limited to 'rumba/testbeds')
-rw-r--r-- | rumba/testbeds/emulab.py | 23 | ||||
-rw-r--r-- | rumba/testbeds/jfed.py | 4 | ||||
-rw-r--r-- | rumba/testbeds/qemu.py | 23 |
3 files changed, 31 insertions, 19 deletions
diff --git a/rumba/testbeds/emulab.py b/rumba/testbeds/emulab.py index c4dbe36..aee438e 100644 --- a/rumba/testbeds/emulab.py +++ b/rumba/testbeds/emulab.py @@ -43,6 +43,7 @@ class Testbed(mod.Testbed): self.url = url self.image = image self.ip = dict() + self.ops_ssh_config = mod.SSHConfig(self.ops_server()) def ops_server(self): ''' @@ -76,7 +77,7 @@ class Testbed(mod.Testbed): @return: list of created experiments (strings) ''' cmd = '/usr/testbed/bin/sslxmlrpc_client.py -m experiment getlist' - out = ssh.execute_command(self, self.ops_server(), cmd) + out = ssh.execute_command(self, self.ops_ssh_config, cmd) try: if project_name != None: @@ -98,7 +99,7 @@ class Testbed(mod.Testbed): self.exp_name + \ ' direction=in' - output = ssh.execute_command(self, self.ops_server(), cmd) + output = ssh.execute_command(self, self.ops_ssh_config, cmd) return output @@ -131,8 +132,8 @@ class Testbed(mod.Testbed): '" exp="' + exp_name + '" noswapin=true ' + \ 'nsfilepath="' + dest_file_name + '"' - ssh.execute_command(self, self.ops_server(), cmd, time_out=None) - ssh.execute_command(self, self.ops_server(), 'rm ' + dest_file_name) + ssh.execute_command(self, self.ops_ssh_config, cmd, time_out=None) + ssh.execute_command(self, self.ops_ssh_config, 'rm ' + dest_file_name) print("New experiment succesfully created.") def generate_ns_script(self, experiment): @@ -182,12 +183,12 @@ class Testbed(mod.Testbed): self.exp_name + \ ' -a | grep State | cut -f2,2 -d " "' - res = ssh.execute_command(self, self.ops_server(), cmd) + res = ssh.execute_command(self, self.ops_ssh_config, cmd) active = False if res == "active": active = True while active != True: - res = ssh.execute_command(self, self.ops_server(), cmd) + res = ssh.execute_command(self, self.ops_ssh_config, cmd) if res == "active": active = True print("Still waiting") @@ -201,9 +202,11 @@ class Testbed(mod.Testbed): @param experiment: the experiment ''' - node_full_name = self.full_name(experiment.nodes[0].name) + for node in experiment.nodes: + node.ssh_config.hostname = self.full_name(experiment.nodes[0].name) + cmd = 'cat /var/emulab/boot/topomap' - topomap = ssh.execute_command(self, node_full_name, cmd) + topomap = ssh.execute_command(self, experiment.nodes[0].ssh_config, cmd) # Almost as ugly as yo momma index = topomap.rfind("# lans") topo_array = topomap[:index].split('\\n')[1:-1] @@ -224,8 +227,7 @@ class Testbed(mod.Testbed): for node in experiment.nodes: cmd = 'cat /var/emulab/boot/ifmap' - node_full_name = self.full_name(node.name) - output = ssh.execute_command(self, node_full_name, cmd) + output = ssh.execute_command(self, node.ssh_config, cmd) output = re.split('\\\\n', output) for item in output: item = item.split() @@ -233,7 +235,6 @@ class Testbed(mod.Testbed): if isinstance(ipcp, mod.ShimEthIPCP): if self.ip[ipcp] == item[1]: ipcp.ifname = item[0] - node.full_name = self.full_name(node.name) def swap_in(self, experiment): self._create_experiment(experiment) diff --git a/rumba/testbeds/jfed.py b/rumba/testbeds/jfed.py index f56e5ba..0dfc904 100644 --- a/rumba/testbeds/jfed.py +++ b/rumba/testbeds/jfed.py @@ -111,8 +111,8 @@ class Testbed(mod.Testbed): for node in experiment.nodes: auth_name_r = self.auth_name.replace(".", "-") - node.full_name = node.name + "." + self.exp_name + "." + \ - auth_name_r + "." + self.auth_name + node.ssh_config.hostname = node.name + "." + self.exp_name + "." + \ + auth_name_r + "." + self.auth_name subprocess.call(["java", "-jar", self.jfed_jar, "create", "-S", \ self.proj_name, "--rspec", \ diff --git a/rumba/testbeds/qemu.py b/rumba/testbeds/qemu.py index 73a4f14..7255b3c 100644 --- a/rumba/testbeds/qemu.py +++ b/rumba/testbeds/qemu.py @@ -180,14 +180,14 @@ class Testbed(mod.Testbed): boot_batch_size = max(1, multiprocessing.cpu_count() // 2) booting_budget = boot_batch_size - boot_backoff = 12 + boot_backoff = 12 # in seconds base_port = 2222 - vm_memory = 164 + vm_memory = 164 # in megabytes vm_frontend = 'virtio-net-pci' vmid = 1 - for node in experiment.nodes: # type: mod.Node + for node in experiment.nodes: name = node.name vm = self.vms.setdefault(name, {'vm': node, 'ports': []}) fwdp = base_port + vmid @@ -195,7 +195,8 @@ class Testbed(mod.Testbed): mac = '00:0a:0a:0a:%02x:%02x' % (vmid, 99) vm['ssh'] = fwdp vm['id'] = vmid - node.full_name = "127.0.0.1:%s" % fwdp + node.ssh_config.hostname = "localhost" + node.ssh_config.port = fwdp vars_dict = {'fwdp': fwdp, 'id': vmid, 'mac': mac, 'bzimage': self.bzimage, @@ -243,8 +244,10 @@ class Testbed(mod.Testbed): booting_budget -= 1 if booting_budget <= 0: - print('Sleeping for %s seconds to give ' - 'the machines time to boot up.' % boot_backoff) + + print('Sleeping %s secs waiting ' + 'for the VMs to boot' % boot_backoff) + time.sleep(boot_backoff) booting_budget = boot_batch_size @@ -256,6 +259,14 @@ class Testbed(mod.Testbed): vmid += 1 + # Wait for the last batch of VMs to start + if booting_budget < boot_backoff: + tsleep = boot_backoff * (boot_batch_size - booting_budget) / \ + boot_batch_size + print('Sleeping %s secs waiting for the last VMs to boot' % tsleep) + time.sleep(tsleep) + + def swap_out(self, experiment): """ :rtype str |