added network argument to CLI, sufficient for demo now, added todos
authorpeusterm <manuel.peuster@uni-paderborn.de>
Fri, 29 Jan 2016 14:34:38 +0000 (15:34 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Fri, 29 Jan 2016 14:34:38 +0000 (15:34 +0100)
README.md
emuvim/api/zerorpcapi.py
emuvim/cli/compute.py

index a9d48b3..59cd092 100644 (file)
--- a/README.md
+++ b/README.md
@@ -55,7 +55,10 @@ Automatic installation is provide through an Ansible playbook.
 
 ### TODO
 * DCemulator
- * ...
+ * Advanced network model
+  * improve network management, multiple interfaces per container
+  * API to create multiple networks (per DC?)
+
 
 * Add resource constraints to datacenters
 * Check if we can use the Mininet GUI to visualize our DCs?
@@ -76,7 +79,7 @@ Automatic installation is provide through an Ansible playbook.
  * list active compute resources
 * Cloud-like reference API with CLI for demonstrations
  * Write CLI client
- * Start compute (name, DC, image)
+ * Start compute (name, DC, image, network)
  * Stop compute
 * Create an Ansible-based automatic installation routine
 * Unit tests
index be44444..7aecba4 100644 (file)
@@ -56,11 +56,13 @@ class MultiDatacenterApi(object):
     def __init__(self, dcs):
         self.dcs = dcs
 
-    def compute_action_start(self, dc_name, compute_name, image):
+    def compute_action_start(self, dc_name, compute_name, image, 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_name).startCompute(compute_name, image=image)
+            c = self.dcs.get(dc_name).startCompute(
+                compute_name, image=image, network=network)
             return str(c.name)
         except Exception as ex:
             logging.exception("RPC error.")
index 9f1030f..df40814 100644 (file)
@@ -27,8 +27,14 @@ class ZeroRpcClient(object):
             print "Command not implemented."
 
     def start(self, args):
+        network = {}
+        if args.get("network") is not None:
+            network = {"ip": args.get("network")}
         r = self.c.compute_action_start(
-            args.get("datacenter"), args.get("name"), args.get("image"))
+            args.get("datacenter"),
+            args.get("name"),
+            args.get("image"),
+            network)
         pp.pprint(r)
 
     def stop(self, args):
@@ -72,14 +78,21 @@ class ZeroRpcClient(object):
 
 
 parser = argparse.ArgumentParser(description='son-emu compute')
-parser.add_argument("command", help="Action to be executed.")
 parser.add_argument(
-    "--datacenter", "-d", dest="datacenter", help="Data center.")
+    "command",
+    help="Action to be executed: start|stop|list")
 parser.add_argument(
-    "--name", "-n", dest="name", help="Compute name.")
+    "--datacenter", "-d", dest="datacenter",
+    help="Data center to in which the compute instance should be executed")
 parser.add_argument(
-    "--image", "-i", dest="image", help="Name of container image to be used.")
-# TODO: IP, image, etc. pp.
+    "--name", "-n", dest="name",
+    help="Name of compute instance e.g. 'vnf1'")
+parser.add_argument(
+    "--image", dest="image",
+    help="Name of container image to be used e.g. 'ubuntu'")
+parser.add_argument(
+    "--net", dest="network",
+    help="Network properties of compute instance e.g. '10.0.0.123/8'")
 
 
 def main(argv):