From 9424b5f36e2ef87d4bd01b9b4e5fc83965ec33b6 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Thu, 1 Jun 2017 17:12:28 +0200 Subject: qemu plugin: automatic download of buildroot images --- examples/two-layers.py | 6 ++---- rumba/testbeds/qemu.py | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/examples/two-layers.py b/examples/two-layers.py index b4e4e64..b3622fd 100755 --- a/examples/two-layers.py +++ b/examples/two-layers.py @@ -48,11 +48,9 @@ d = Node("d", tb = qemu.Testbed(exp_name = "twolayers", username = "root", - password = "root", - bzimage = '/home/vmaffione/git/rlite/demo/buildroot/bzImage', - initramfs = '/home/vmaffione/git/rlite/demo/buildroot/rootfs.cpio') + password = "root") -exp = rl.Experiment(tb, nodes = [a, b, c, d]) +exp = irati.Experiment(tb, nodes = [a, b, c, d]) print(exp) diff --git a/rumba/testbeds/qemu.py b/rumba/testbeds/qemu.py index a916525..894bee5 100644 --- a/rumba/testbeds/qemu.py +++ b/rumba/testbeds/qemu.py @@ -26,25 +26,41 @@ import os import rumba.model as mod 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, initramfs, proj_name="ARCFIRE", + def __init__(self, exp_name, bzimage=None, initramfs=None, proj_name="ARCFIRE", password="root", username="root", use_vhost=True, qemu_logs_dir=None): mod.Testbed.__init__(self, exp_name, username, password, proj_name) self.vms = {} self.shims = [] - self.bzimage = bzimage - self.initramfs = initramfs self.vhost = use_vhost self.qemu_logs_dir = os.getcwd() if qemu_logs_dir is None \ else qemu_logs_dir self.boot_processes = [] + # Download the proper buildroot image, if not provided explicitely + url_prefix = "https://bitbucket.org/vmaffione/rina-images/downloads/" + if not bzimage: + bzimage = 'irati.bzImage' + if not os.path.exists(bzimage): + print("Downloading %s" % (url_prefix + bzimage)) + wget.download(url_prefix + bzimage) + print("\n") + if not initramfs: + initramfs = 'irati.rootfs.cpio' + if not os.path.exists(initramfs): + print("Downloading %s" % (url_prefix + initramfs)) + wget.download(url_prefix + initramfs) + print("\n") + self.bzimage = bzimage + self.initramfs = initramfs + @staticmethod def _run_command_chain(commands, results_queue, error_queue, ignore_errors=False): -- cgit v1.2.3 From d1b49132f669cf1df4367103ebad63029793a127 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Thu, 1 Jun 2017 17:24:25 +0200 Subject: model: Experiment: add prototype_name() --- rumba/model.py | 8 ++++++-- rumba/prototypes/irati.py | 3 +++ rumba/prototypes/ouroboros.py | 3 +++ rumba/prototypes/rlite.py | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rumba/model.py b/rumba/model.py index 9fbda57..8631a9d 100644 --- a/rumba/model.py +++ b/rumba/model.py @@ -514,11 +514,15 @@ class Experiment: @abc.abstractmethod def install_prototype(self): - raise Exception('run_prototype() method not implemented') + raise Exception('install_prototype() method not implemented') @abc.abstractmethod def bootstrap_prototype(self): - raise Exception('run_prototype() method not implemented') + raise Exception('bootstrap_prototype() method not implemented') + + @abc.abstractmethod + def prototype_name(self): + raise Exception('prototype_name() method not implemented') def swap_in(self): # Realize the experiment testbed (testbed-specific) diff --git a/rumba/prototypes/irati.py b/rumba/prototypes/irati.py index f9c715f..750d6aa 100644 --- a/rumba/prototypes/irati.py +++ b/rumba/prototypes/irati.py @@ -38,6 +38,9 @@ logger = log.get_logger(__name__) # An experiment over the IRATI implementation class Experiment(mod.Experiment): + def prototype_name(self): + return 'irati' + @staticmethod def real_sudo(s): return 'sudo ' + s diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py index 01b8b72..9ac1425 100644 --- a/rumba/prototypes/ouroboros.py +++ b/rumba/prototypes/ouroboros.py @@ -32,6 +32,9 @@ class Experiment(mod.Experiment): def __init__(self, testbed, nodes=None): mod.Experiment.__init__(self, testbed, nodes) + def prototype_name(self): + return 'ouroboros' + def setup_ouroboros(self): for node in self.nodes: ssh.execute_command(self.testbed, node.ssh_config, diff --git a/rumba/prototypes/rlite.py b/rumba/prototypes/rlite.py index 625668d..098125a 100644 --- a/rumba/prototypes/rlite.py +++ b/rumba/prototypes/rlite.py @@ -34,6 +34,9 @@ class Experiment(mod.Experiment): def __init__(self, testbed, nodes=None): mod.Experiment.__init__(self, testbed, nodes) + def prototype_name(self): + return 'rlite' + def execute_commands(self, node, cmds): ssh.execute_commands(self.testbed, node.ssh_config, cmds, time_out=None) -- cgit v1.2.3 From 15687f1938dd5faa68eccfdcacc45fb4b0644b45 Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Thu, 1 Jun 2017 17:34:12 +0200 Subject: qemu testbed: use the prototype name to get the right buildroot image --- rumba/testbeds/qemu.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/rumba/testbeds/qemu.py b/rumba/testbeds/qemu.py index 894bee5..b7ebef9 100644 --- a/rumba/testbeds/qemu.py +++ b/rumba/testbeds/qemu.py @@ -43,21 +43,6 @@ class Testbed(mod.Testbed): self.qemu_logs_dir = os.getcwd() if qemu_logs_dir is None \ else qemu_logs_dir self.boot_processes = [] - - # Download the proper buildroot image, if not provided explicitely - url_prefix = "https://bitbucket.org/vmaffione/rina-images/downloads/" - if not bzimage: - bzimage = 'irati.bzImage' - if not os.path.exists(bzimage): - print("Downloading %s" % (url_prefix + bzimage)) - wget.download(url_prefix + bzimage) - print("\n") - if not initramfs: - initramfs = 'irati.rootfs.cpio' - if not os.path.exists(initramfs): - print("Downloading %s" % (url_prefix + initramfs)) - wget.download(url_prefix + initramfs) - print("\n") self.bzimage = bzimage self.initramfs = initramfs @@ -130,6 +115,23 @@ class Testbed(mod.Testbed): raise Exception('Not authenticated') logger.info("swapping in") + + # 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) + 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) + print("\n") + logger.info('Setting up interfaces.') # Building bridges and taps -- cgit v1.2.3