diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2018-05-29 14:46:55 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2018-05-29 15:01:28 +0200 |
commit | f28d8380444fb74bd6bdf7c56cf23f59e6a8256e (patch) | |
tree | d88ddf4daa07ffadb0057aac031c144d1a1e7f1d | |
parent | ad5d3b6a3781a303ed8ff68076351c937a0f06db (diff) | |
download | rumba-f28d8380444fb74bd6bdf7c56cf23f59e6a8256e.tar.gz rumba-f28d8380444fb74bd6bdf7c56cf23f59e6a8256e.zip |
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.
-rw-r--r-- | rumba/testbeds/dockertb.py | 25 |
1 files 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, |