From 8fbf9781aa638201aa54b3e5e7c2c7384b7ca8f7 Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Wed, 17 Feb 2016 11:40:23 +0100 Subject: [PATCH] add docker start command as argument --- emuvim/api/zerorpcapi.py | 4 ++-- emuvim/api/zerorpcapi_DCNetwork.py | 4 ++-- emuvim/cli/compute.py | 6 +++++- emuvim/cli/son-emu-cli | 2 +- emuvim/dcemulator/net.py | 10 +++++----- emuvim/example_topology.py | 1 + start_dcnetwork | 0 start_example_chain | 0 8 files changed, 16 insertions(+), 11 deletions(-) mode change 100644 => 100755 start_dcnetwork mode change 100644 => 100755 start_example_chain diff --git a/emuvim/api/zerorpcapi.py b/emuvim/api/zerorpcapi.py index de43423..fd814b3 100755 --- a/emuvim/api/zerorpcapi.py +++ b/emuvim/api/zerorpcapi.py @@ -56,13 +56,13 @@ class MultiDatacenterApi(object): def __init__(self, dcs): self.dcs = dcs - def compute_action_start(self, dc_label, compute_name, image, network): + def compute_action_start(self, dc_label, compute_name, image, command, network): # network e.g. {"ip": "10.0.0.254/8"} # TODO what to return UUID / given name / internal name ? logging.debug("RPC CALL: compute start") try: c = self.dcs.get(dc_label).startCompute( - compute_name, image=image, network=network) + compute_name, image=image, command=command, network=network) return str(c.name) except Exception as ex: logging.exception("RPC error.") diff --git a/emuvim/api/zerorpcapi_DCNetwork.py b/emuvim/api/zerorpcapi_DCNetwork.py index 7402f3d..83b158a 100644 --- a/emuvim/api/zerorpcapi_DCNetwork.py +++ b/emuvim/api/zerorpcapi_DCNetwork.py @@ -39,8 +39,8 @@ class ZeroRpcApiEndpointDCNetwork(object): def connectDCNetwork(self, net): self.net = net - logging.info("Connected DCNetwork(%s) to API endpoint %s(%s:%d)" % ( - net.name, self.__class__.__name__, self.ip, self.port)) + logging.info("Connected DCNetwork to API endpoint %s(%s:%d)" % ( + self.__class__.__name__, self.ip, self.port)) def start(self): thread = threading.Thread(target=self._api_server_thread, args=()) diff --git a/emuvim/cli/compute.py b/emuvim/cli/compute.py index 87247cb..15fea91 100755 --- a/emuvim/cli/compute.py +++ b/emuvim/cli/compute.py @@ -34,6 +34,7 @@ class ZeroRpcClient(object): args.get("datacenter"), args.get("name"), args.get("image"), + args.get("docker_command"), network) pp.pprint(r) @@ -89,8 +90,11 @@ parser.add_argument( "--name", "-n", dest="name", help="Name of compute instance e.g. 'vnf1'") parser.add_argument( - "--image", dest="image", + "--image","-i", dest="image", help="Name of container image to be used e.g. 'ubuntu'") +parser.add_argument( + "--dcmd", "-c", dest="docker_command", + help="Startup command of the container e.g. './start.sh'") parser.add_argument( "--net", dest="network", help="Network properties of compute instance e.g. '10.0.0.123/8'") diff --git a/emuvim/cli/son-emu-cli b/emuvim/cli/son-emu-cli index 2a1e598..61cbd43 100755 --- a/emuvim/cli/son-emu-cli +++ b/emuvim/cli/son-emu-cli @@ -28,7 +28,7 @@ def main(): network.main(sys.argv[2:]) elif sys.argv[1] == "datacenter": datacenter.main(sys.argv[2:]) - elif sys.argv[1] == "monitor": + elif sys.argv[1] == "monitor": monitor.main(sys.argv[2:]) if __name__ == '__main__': diff --git a/emuvim/dcemulator/net.py b/emuvim/dcemulator/net.py index 4bf9224..e0d524e 100755 --- a/emuvim/dcemulator/net.py +++ b/emuvim/dcemulator/net.py @@ -97,15 +97,15 @@ class DCNetwork(Dockernet): """ Wrapper for addDocker method to use custom container class. """ - self.DCNetwork_graph.add_node(name) - return Dockernet.addDocker(self, name, cls=EmulatorCompute, **params) + self.DCNetwork_graph.add_node(label) + return Dockernet.addDocker(self, label, cls=EmulatorCompute, **params) - def removeDocker( self, name, **params ): + def removeDocker( self, label, **params ): """ Wrapper for removeDocker method to update graph. """ - self.DCNetwork_graph.remove_node(name) - return Dockernet.removeDocker(self, name, **params) + self.DCNetwork_graph.remove_node(label) + return Dockernet.removeDocker(self, label, **params) def addSwitch( self, name, add_to_graph=True, **params ): """ diff --git a/emuvim/example_topology.py b/emuvim/example_topology.py index 35c87af..9412863 100755 --- a/emuvim/example_topology.py +++ b/emuvim/example_topology.py @@ -20,6 +20,7 @@ import logging from mininet.log import setLogLevel from dcemulator.net import DCNetwork from api.zerorpcapi import ZeroRpcApiEndpoint +from api.zerorpcapi_DCNetwork import ZeroRpcApiEndpointDCNetwork logging.basicConfig(level=logging.INFO) diff --git a/start_dcnetwork b/start_dcnetwork old mode 100644 new mode 100755 diff --git a/start_example_chain b/start_example_chain old mode 100644 new mode 100755 -- 2.25.1