add docker start command as argument
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Wed, 17 Feb 2016 10:40:23 +0000 (11:40 +0100)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Wed, 17 Feb 2016 10:40:23 +0000 (11:40 +0100)
emuvim/api/zerorpcapi.py
emuvim/api/zerorpcapi_DCNetwork.py
emuvim/cli/compute.py
emuvim/cli/son-emu-cli
emuvim/dcemulator/net.py
emuvim/example_topology.py
start_dcnetwork [changed mode: 0644->0755]
start_example_chain [changed mode: 0644->0755]

index de43423..fd814b3 100755 (executable)
@@ -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.")
index 7402f3d..83b158a 100644 (file)
@@ -39,8 +39,8 @@ class ZeroRpcApiEndpointDCNetwork(object):
 \r
     def connectDCNetwork(self, net):\r
         self.net = net\r
-        logging.info("Connected DCNetwork(%s) to API endpoint %s(%s:%d)" % (\r
-            net.name, self.__class__.__name__, self.ip, self.port))\r
+        logging.info("Connected DCNetwork to API endpoint %s(%s:%d)" % (\r
+            self.__class__.__name__, self.ip, self.port))\r
 \r
     def start(self):\r
         thread = threading.Thread(target=self._api_server_thread, args=())\r
index 87247cb..15fea91 100755 (executable)
@@ -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'")
index 2a1e598..61cbd43 100755 (executable)
@@ -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__':
index 4bf9224..e0d524e 100755 (executable)
@@ -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 ):
         """
index 35c87af..9412863 100755 (executable)
@@ -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)
 
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)