From f28d8380444fb74bd6bdf7c56cf23f59e6a8256e Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 29 May 2018 14:46:55 +0200 Subject: testbeds: Add default image for docker testbed This adds a default image for the docker testbed for Ouroboros so it is easier for an experimenter to start experimenting with the docker testbed, similarly to the QEMU testbed. --- rumba/testbeds/dockertb.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/rumba/testbeds/dockertb.py b/rumba/testbeds/dockertb.py index 2ee4561..5dcbb16 100644 --- a/rumba/testbeds/dockertb.py +++ b/rumba/testbeds/dockertb.py @@ -39,8 +39,8 @@ class Testbed(mod.Testbed): """ Represents a docker testbed. """ - def __init__(self, base_image, exp_name='foo', pull_image=True, - use_ovs=False): + def __init__(self, base_image=None, exp_name='foo', + pull_image=True, use_ovs=False): """ Initializes the testbed class. @@ -48,14 +48,13 @@ class Testbed(mod.Testbed): :param base_image: The docker base image. :param pull_image: Retrieve the docker image from the Docker hub? :param use_ovs: Use the OVS switch instead of the Linux bridge? + + .. note:: In case no base image is provided, Rumba will automatically + download the latest version available from docker hub. """ mod.Testbed.__init__(self, exp_name, "", "", "") - img = base_image.rsplit(":", 1) - - self.base_image_repo = img[0] - self.base_image_tag = "latest" if len(img) == 1 else img[1] - self.base_image = "%s:%s" % (self.base_image_repo, self.base_image_tag) + self.base_image = base_image self.pull_image = pull_image self.use_ovs = use_ovs @@ -69,6 +68,18 @@ class Testbed(mod.Testbed): def _swap_in(self, experiment): docker_client = self.docker_client + if not self.base_image: + if experiment.prototype_name() == 'ouroboros': + self.base_image = 'arcfirerumba/ouroboros' + else: + raise Exception('Only Ouroboros supported for now.') + + img = self.base_image.rsplit(":", 1) + + self.base_image_repo = img[0] + self.base_image_tag = "latest" if len(img) == 1 else img[1] + self.base_image = "%s:%s" % (self.base_image_repo, self.base_image_tag) + # Pull image if self.pull_image: docker_client.images.pull(self.base_image_repo, -- cgit v1.2.3