From 5b844a1abb3fa789d1d72f74c86d8e47c28b2dac Mon Sep 17 00:00:00 2001 From: peusterm Date: Mon, 11 Jan 2016 15:58:15 +0100 Subject: [PATCH] cleaner API --- emuvim/dcemulator/net.py | 16 ++++++++++++++++ emuvim/dcemulator/node.py | 6 ++---- emuvim/example_topology.py | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/emuvim/dcemulator/net.py b/emuvim/dcemulator/net.py index e0f41e2..0efcafa 100644 --- a/emuvim/dcemulator/net.py +++ b/emuvim/dcemulator/net.py @@ -54,6 +54,10 @@ class DCNetwork(object): return s def addLink(self, node1, node2): + """ + Able to handle Datacenter objects as link + end points. + """ assert node1 is not None assert node2 is not None # ensure type of node1 @@ -80,6 +84,18 @@ class DCNetwork(object): raise Exception( "one of the given nodes is not a Mininet switch or None") + def addDocker( self, name, **params ): + """ + Wrapper for addDocker method provided by Dockernet. + """ + return self.mnet.addDocker( name, **params) + + def removeDocker( self, name, **params): + """ + Wrapper for removeHost. Just to be complete. + """ + return self.mnet.removeDocker(name, **params) + def start(self): # start for dc in self.dcs.itervalues(): diff --git a/emuvim/dcemulator/node.py b/emuvim/dcemulator/node.py index 5e5def0..6d1c6de 100644 --- a/emuvim/dcemulator/node.py +++ b/emuvim/dcemulator/node.py @@ -46,11 +46,9 @@ class Datacenter(object): Create a new container as compute resource and connect it to this data center. """ - #TODO remove mnet shortcut to have a clean API #TODO connect container to DC's swtich - self.net.mnet.addDocker("%s.%s" % (self.name, name), dimage="ubuntu") + self.net.addDocker("%s.%s" % (self.name, name), dimage="ubuntu") def removeCompute(self, name): - #TODO remove mnet shortcut to have a clean API #TODO disconnect container to DC's swtich - self.net.mnet.removeDocker("%s.%s" % (self.name, name)) + self.net.removeDocker("%s.%s" % (self.name, name)) diff --git a/emuvim/example_topology.py b/emuvim/example_topology.py index fce0698..109808c 100644 --- a/emuvim/example_topology.py +++ b/emuvim/example_topology.py @@ -57,7 +57,7 @@ def create_topology1(): """ 5. We want to access and control our data centers from the outside, - e.g., we want to connect an orchestrate to start/stop compute + e.g., we want to connect an orchestrator to start/stop compute resources aka. VNFs (represented by Docker containers in the emulated) So we need to instantiate API endpoints (e.g. a zerorpc or REST -- 2.25.1