diff options
-rw-r--r-- | rumba/model.py | 21 | ||||
-rw-r--r-- | rumba/prototypes/irati.py | 2 | ||||
-rw-r--r-- | rumba/testbeds/jfed.py | 10 | ||||
-rw-r--r-- | rumba/testbeds/qemu.py | 47 | ||||
-rwxr-xr-x | tools/rumba-access | 2 |
5 files changed, 49 insertions, 33 deletions
diff --git a/rumba/model.py b/rumba/model.py index affdcbf..f4f98d1 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -22,10 +22,25 @@ import abc import rumba.log as log - +import os +import stat logger = log.get_logger(__name__) +tmp_dir = '/tmp/rumba' +try: + os.mkdir(tmp_dir) + os.chmod(tmp_dir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) +except OSError: + # Already there, nothing to do + pass + +cache_dir = os.path.join(os.path.expanduser("~"), '.cache/rumba/') +try: + os.mkdir(cache_dir) +except OSError: + # Already there, nothing to do + pass # Represents generic testbed info # @@ -222,8 +237,6 @@ class Node: s += ", ".join(rl) s += " ]\n" - s += " Policies: [ " - return s def __hash__(self): @@ -628,7 +641,7 @@ class Experiment: break def dump_ssh_info(self): - f = open('ssh_info', 'w') + f = open(os.path.join(tmp_dir, 'ssh_info'), 'w') for node in self.nodes: f.write("%s;%s;%s;%s;%s\n" % (node.name, self.testbed.username, diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py index c01e413..57901fc 100644 --- a/rumba/prototypes/irati.py +++ b/rumba/prototypes/irati.py @@ -58,7 +58,7 @@ class Experiment(mod.Experiment): else: self.sudo = self.real_sudo - self._conf_dir = os.path.join(os.getcwd(), 'IRATI_conf') + self._conf_dir = os.path.join(mod.tmp_dir, 'IRATI_conf') try: os.mkdir(self._conf_dir) except OSError: diff --git a/rumba/testbeds/jfed.py b/rumba/testbeds/jfed.py index e158048..9c72ca7 100644 --- a/rumba/testbeds/jfed.py +++ b/rumba/testbeds/jfed.py @@ -51,9 +51,10 @@ class Testbed(mod.Testbed): self.cert_file = cert_file self.exp_hours = exp_hours self.if_id = dict() - self.rspec = self.exp_name + ".rspec" - self.manifest = self.exp_name + ".rrspec" - self.jfed_jar = "jfed_cli/experimenter-cli.jar" + self.rspec = os.path.join(mod.tmp_dir, self.exp_name + ".rspec") + self.manifest = os.path.join(mod.tmp_dir, self.exp_name + ".rrspec") + self.jfed_jar = os.path.join(mod.cache_dir, + 'jfed_cli/experimenter-cli.jar') if image is not None: self.image = "urn:publicid:IDN+" + authority + \ "+image+wall2-ilabt-iminds-be:" + image @@ -68,7 +69,8 @@ class Testbed(mod.Testbed): tar = tarfile.open(tarball) tar.extractall() tar.close() - logger.info("Extracted in current directory") + os.rename(os.path.join(os.getcwd(), 'jfed_cli'), + os.path.join(mod.cache_dir, 'jfed_cli')) os.remove(tarball) self.flags['no_vlan_offload'] = True diff --git a/rumba/testbeds/qemu.py b/rumba/testbeds/qemu.py index 1d449dc..f0b73a8 100644 --- a/rumba/testbeds/qemu.py +++ b/rumba/testbeds/qemu.py @@ -28,23 +28,20 @@ import rumba.log as log import rumba.ssh_support as ssh_support import wget - logger = log.get_logger(__name__) class Testbed(mod.Testbed): - def __init__(self, exp_name, bzimage=None, initramfs=None, proj_name="ARCFIRE", - password="root", username="root", - use_vhost=True, qemu_logs_dir=None): + def __init__(self, exp_name, bzimage_path=None, initramfs_path=None, + proj_name="ARCFIRE", password="root", username="root", + use_vhost=True): mod.Testbed.__init__(self, exp_name, username, password, proj_name) self.vms = {} self.shims = [] self.vhost = use_vhost - self.qemu_logs_dir = os.getcwd() if qemu_logs_dir is None \ - else qemu_logs_dir self.boot_processes = [] - self.bzimage = bzimage - self.initramfs = initramfs + self.bzimage_path = bzimage_path + self.initramfs_path = initramfs_path @staticmethod def _run_command_chain(commands, results_queue, @@ -127,17 +124,19 @@ class Testbed(mod.Testbed): # Download the proper buildroot images, if the user did not specify # local images url_prefix = "https://bitbucket.org/vmaffione/rina-images/downloads/" - if not self.bzimage: - self.bzimage = '%s.bzImage' % (experiment.prototype_name()) - if not os.path.exists(self.bzimage): - logger.info("Downloading %s" % (url_prefix + self.bzimage)) - wget.download(url_prefix + self.bzimage) + if not self.bzimage_path: + bzimage = '%s.bzImage' % (experiment.prototype_name()) + self.bzimage_path = os.path.join(mod.cache_dir, bzimage) + if not os.path.exists(self.bzimage_path): + logger.info("Downloading %s" % (url_prefix + bzimage)) + wget.download(url_prefix + bzimage, out=self.bzimage_path) print("\n") - if not self.initramfs: - self.initramfs = '%s.rootfs.cpio' % (experiment.prototype_name()) - if not os.path.exists(self.initramfs): - logger.info("Downloading %s" % (url_prefix + self.initramfs)) - wget.download(url_prefix + self.initramfs) + if not self.initramfs_path: + initramfs = '%s.rootfs.cpio' % (experiment.prototype_name()) + self.initramfs_path = os.path.join(mod.cache_dir, initramfs) + if not os.path.exists(self.initramfs_path): + logger.info("Downloading %s" % (url_prefix + initramfs)) + wget.download(url_prefix + initramfs, out=self.initramfs_path) print("\n") logger.info('Setting up interfaces.') @@ -255,13 +254,15 @@ class Testbed(mod.Testbed): vm['id'] = vmid node.ssh_config.hostname = "localhost" node.ssh_config.port = fwdp + log_file = os.path.join(mod.tmp_dir, name + '.log') vars_dict = {'fwdp': fwdp, 'id': vmid, 'mac': mac, - 'bzimage': self.bzimage, - 'initramfs': self.initramfs, + 'bzimage': self.bzimage_path, + 'initramfs': self.initramfs_path, 'fwdc': fwdc, 'memory': vm_memory, 'frontend': vm_frontend, - 'vmname': name} + 'vmname': name, + 'log_file' : log_file} host_fwd_str = 'hostfwd=tcp::%(fwdp)s-:22' % vars_dict vars_dict['hostfwdstr'] = host_fwd_str @@ -279,7 +280,7 @@ class Testbed(mod.Testbed): '-m %(memory)sM ' '-device %(frontend)s,mac=%(mac)s,netdev=mgmt ' '-netdev user,id=mgmt,%(hostfwdstr)s ' - '-serial file:%(vmname)s.log ' + '-serial file:%(log_file)s ' % vars_dict ) @@ -307,7 +308,7 @@ class Testbed(mod.Testbed): time.sleep(boot_backoff) booting_budget = boot_batch_size - with open('%s/qemu_out_%s' % (self.qemu_logs_dir, vmid), 'w')\ + with open('%s/qemu_out_%s' % (mod.tmp_dir, vmid), 'w')\ as out_file: logger.debug('executing >> %s', command) self.boot_processes.append(subprocess.Popen(command.split(), diff --git a/tools/rumba-access b/tools/rumba-access index 1cf382e..a2a5e83 100755 --- a/tools/rumba-access +++ b/tools/rumba-access @@ -1,6 +1,6 @@ #!/usr/bin/env bash -FILE=ssh_info +FILE=/tmp/rumba/ssh_info MACHINE_ID=$1 if [ "$MACHINE_ID" == "" ]; then |