From 5b37641a26aef3691b6f5ad2e3d1b768841eee8f Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Wed, 4 May 2016 15:34:49 +0200 Subject: [PATCH] name docker interfaces according to start_compute option --- src/emuvim/api/zerorpc/compute.py | 9 ++++++--- src/emuvim/cli/compute.py | 18 +++++++++++------- src/emuvim/dcemulator/net.py | 15 ++++++++++----- src/emuvim/dcemulator/node.py | 3 +-- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/emuvim/api/zerorpc/compute.py b/src/emuvim/api/zerorpc/compute.py index 38b0a06..39ccec2 100644 --- a/src/emuvim/api/zerorpc/compute.py +++ b/src/emuvim/api/zerorpc/compute.py @@ -68,7 +68,6 @@ class MultiDatacenterApi(object): """ # TODO what to return UUID / given name / internal name ? logging.debug("RPC CALL: compute start") - logging.info('nwlist2: {0}'.format(network)) try: c = self.dcs.get(dc_label).startCompute( compute_name, image=image, command=command, network=network) @@ -117,13 +116,17 @@ class MultiDatacenterApi(object): def compute_profile(self, dc_label, compute_name, image, kwargs): # note: zerorpc does not support keyword arguments + ## VIM/dummy gatekeeper's tasks: # start vnf vnf_status = self.compute_action_start(self, dc_label, compute_name, image, kwargs.get('network'), kwargs.get('command')) - # start traffic source (with fixed ip addres, no use for now...) - self.compute_action_start(self, dc_label, 'psrc', 'profile_source', [{'id':'output','ip':'10.0.10.1/24'}], None) + self.compute_action_start(self, dc_label, 'psrc', 'profile_source', [{'id':'output'}], None) + # link vnf to traffic source + DCNetwork = self.dcs.get(dc_label).net + DCNetwork.setChain() + diff --git a/src/emuvim/cli/compute.py b/src/emuvim/cli/compute.py index 6423917..2636315 100755 --- a/src/emuvim/cli/compute.py +++ b/src/emuvim/cli/compute.py @@ -31,8 +31,6 @@ class ZeroRpcClient(object): if args.get("network") is not None: nw_list = self._parse_network(args.get("network")) - pp.pprint('nwlist1: {0}'.format(nw_list)) - r = self.c.compute_action_start( args.get("datacenter"), args.get("name"), @@ -85,18 +83,24 @@ class ZeroRpcClient(object): nw_list = list() if args.get("network") is not None: nw_list = self._parse_network(args.get("network")) - logging.info('nwlist: {0}'.format(nw_list)) + + params = self._create_dict( + network=nw_list, + command=args.get("docker_command"), + input=args.get("input"), + output=args.get("output")) + r = self.c.compute_profile( args.get("datacenter"), args.get("name"), args.get("image"), - network=nw_list, - command=args.get("docker_command"), - input=args.get("input"), - output=args.get("output") + params ) pp.pprint(r) + def _create_dict(self, **kwargs): + return kwargs + def _parse_network(self, network_str): ''' parse the options for all network interfaces of the vnf diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index 4028a26..ed40545 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -124,12 +124,13 @@ class DCNetwork(Dockernet): if isinstance(node1, Docker): if "id" in params["params1"]: node1_port_id = params["params1"]["id"] + node1_port_name = link.intf1.name node2_port_id = node2.ports[link.intf2] if isinstance(node2, Docker): if "id" in params["params2"]: node2_port_id = params["params2"]["id"] - + node2_port_name = link.intf2.name # add edge and assigned port number to graph in both directions between node1 and node2 @@ -150,13 +151,17 @@ class DCNetwork(Dockernet): attr_dict[attr] = attr_number - attr_dict2 = {'src_port_id': node1_port_id, 'src_port': node1.ports[link.intf1], - 'dst_port_id': node2_port_id, 'dst_port': node2.ports[link.intf2]} + attr_dict2 = {'src_port_id': node1_port_id, 'src_port_nr': node1.ports[link.intf1], + 'src_port_name': node1_port_name, + 'dst_port_id': node2_port_id, 'dst_port_nr': node2.ports[link.intf2], + 'dst_port_name': node2_port_name} attr_dict2.update(attr_dict) self.DCNetwork_graph.add_edge(node1.name, node2.name, attr_dict=attr_dict2) - attr_dict2 = {'src_port_id': node2_port_id, 'src_port': node2.ports[link.intf2], - 'dst_port_id': node1_port_id, 'dst_port': node1.ports[link.intf1]} + attr_dict2 = {'src_port_id': node2_port_id, 'src_port_nr': node2.ports[link.intf2], + 'src_port_name': node2_port_name, + 'dst_port_id': node1_port_id, 'dst_port_nr': node1.ports[link.intf1], + 'dst_port_name': node1_port_name} attr_dict2.update(attr_dict) self.DCNetwork_graph.add_edge(node2.name, node1.name, attr_dict=attr_dict2) diff --git a/src/emuvim/dcemulator/node.py b/src/emuvim/dcemulator/node.py index 2943b6d..09dca9c 100755 --- a/src/emuvim/dcemulator/node.py +++ b/src/emuvim/dcemulator/node.py @@ -167,11 +167,10 @@ class Datacenter(object): # connect all given networks # if no --net option is given, network = [{}], so 1 empty dict in the list # this results in 1 default interface with a default ip address - logging.info('nwlist: {0}'.format(network)) for nw in network: # TODO we cannot use TCLink here (see: https://github.com/mpeuster/dockernet/issues/3) logging.info('nw: {0}'.format(nw)) - self.net.addLink(d, self.switch, params1=nw, cls=Link) + self.net.addLink(d, self.switch, params1=nw, cls=Link, intfName1=nw.get('id')) # do bookkeeping self.containers[name] = d return d # we might use UUIDs for naming later on -- 2.17.1