From 45dce6172f28aab5b2c6af52a04e426cf9f18aee Mon Sep 17 00:00:00 2001 From: peusterm Date: Fri, 29 Jan 2016 15:34:38 +0100 Subject: [PATCH] added network argument to CLI, sufficient for demo now, added todos --- README.md | 7 +++++-- emuvim/api/zerorpcapi.py | 6 ++++-- emuvim/cli/compute.py | 25 +++++++++++++++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a9d48b3..59cd092 100644 --- 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 diff --git a/emuvim/api/zerorpcapi.py b/emuvim/api/zerorpcapi.py index be44444..7aecba4 100644 --- a/emuvim/api/zerorpcapi.py +++ b/emuvim/api/zerorpcapi.py @@ -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.") diff --git a/emuvim/cli/compute.py b/emuvim/cli/compute.py index 9f1030f..df40814 100644 --- a/emuvim/cli/compute.py +++ b/emuvim/cli/compute.py @@ -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): -- 2.25.1