From: stevenvanrossem Date: Fri, 6 May 2016 08:35:15 +0000 (+0200) Subject: fix bug in chaining command X-Git-Tag: v3.1~129^2~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=307aa1f4774345d9e9a70c02eeee312ecb1b13cf;p=osm%2Fvim-emu.git fix bug in chaining command --- diff --git a/src/emuvim/api/zerorpc/compute.py b/src/emuvim/api/zerorpc/compute.py index 9d59183..4815fa7 100644 --- a/src/emuvim/api/zerorpc/compute.py +++ b/src/emuvim/api/zerorpc/compute.py @@ -7,6 +7,9 @@ import logging import threading import zerorpc +import paramiko +import ipaddress + logging.basicConfig(level=logging.INFO) @@ -122,7 +125,7 @@ class MultiDatacenterApi(object): kwargs.get('network'), kwargs.get('command')) # start traffic source (with fixed ip addres, no use for now...) - self.compute_action_start( dc_label, 'psrc', 'profile_source', [{'id':'output'}], None) + psrc_status = self.compute_action_start( dc_label, 'psrc', 'profile_source', [{'id':'output'}], None) # link vnf to traffic source DCNetwork = self.dcs.get(dc_label).net DCNetwork.setChain('psrc', compute_name, @@ -131,6 +134,32 @@ class MultiDatacenterApi(object): cmd='add-flow', weight=None) ## SSM/SP tasks: + # start traffic generation + for nw in psrc_status.get('network'): + if nw.get('intf_name') == 'output': + psrc_output_ip = unicode(nw['ip']) + break + dummy_iperf_server_ip = ipaddress.IPv4Address(psrc_output_ip) + 1 + iperf_cmd = 'iperf -c {0} -u -l18 -b10M -t1000 &'.format(dummy_iperf_server_ip) + + psrc_mgmt_ip = psrc_status['docker_network'] + psrc_user='root' + psrc_passw='root' + + # use ssh login when starting command externally + ret = self.dcs.get(dc_label).containers.get('psrc').pexec(iperf_cmd) + logging.info(ret) + self.dcs.get(dc_label).containers.get('psrc').monitor() + + #ssh does not work when exectuted via zerorpc command + #psrc_mgmt_ip = '172.17.0.3' + #ssh = paramiko.SSHClient() + #ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + #ssh.connect(psrc_mgmt_ip, username='steven', password='test') + #ssh.connect(psrc_mgmt_ip, username='root', password='root') + + #iperf_cmd = 'iperf -c {0} -u -l18 -b10M -t1000'.format(dummy_iperf_server_ip) + #stdin, stdout, stderr = ssh.exec_command(iperf_cmd) # get monitor data and analyze # create table diff --git a/src/emuvim/cli/network.py b/src/emuvim/cli/network.py index 6b196a3..c524226 100755 --- a/src/emuvim/cli/network.py +++ b/src/emuvim/cli/network.py @@ -33,13 +33,14 @@ class ZeroRpcClient(object): vnf_dst_name = self._parse_vnf_name(args.get("destination")) vnf_dst_interface = self._parse_vnf_interface(args.get("destination")) weight = args.get("weight") + # note zerorpc does not support named arguments r = self.c.network_action_start( #args.get("datacenter"), vnf_src_name, vnf_dst_name, - vnf_src_interface=vnf_src_interface, - vnf_dst_interface=vnf_dst_interface, - weight=weight) + vnf_src_interface, + vnf_dst_interface, + weight) pp.pprint(r) def remove(self, args): @@ -52,9 +53,9 @@ class ZeroRpcClient(object): #args.get("datacenter"), vnf_src_name, vnf_dst_name, - vnf_src_interface=vnf_src_interface, - vnf_dst_interface=vnf_dst_interface, - weight=weight) + vnf_src_interface, + vnf_dst_interface, + weight) pp.pprint(r) def _parse_vnf_name(self, vnf_name_str): diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index b3ec7ee..6531beb 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -91,7 +91,7 @@ class DCNetworkMonitor(): if link_dict[link]['src_port_id'] == vnf_interface: # found the right link and connected switch # logging.info("{0},{1}".format(link_dict[link]['src_port_id'], vnf_source_interface)) - network_metric['mon_port'] = link_dict[link]['dst_port'] + network_metric['mon_port'] = link_dict[link]['dst_port_nr'] break if 'mon_port' not in network_metric: diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index 633ec6b..ac44d57 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -223,6 +223,7 @@ class DCNetwork(Dockernet): # to remove chain do setChain( src, dst, cmd='del-flows') def setChain(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None, cmd='add-flow', weight=None): + logging.info('vnf_src_if: {0}'.format(vnf_src_interface)) #check if port is specified (vnf:port) if vnf_src_interface is None: # take first interface by default diff --git a/src/emuvim/dcemulator/node.py b/src/emuvim/dcemulator/node.py index d533f97..ad33adf 100755 --- a/src/emuvim/dcemulator/node.py +++ b/src/emuvim/dcemulator/node.py @@ -39,7 +39,7 @@ class EmulatorCompute(Docker): this compute instance is connected to. """ # format list of tuples (name, Ip, MAC, isUp, status) - return [(str(i), i.IP(), i.MAC(), i.isUp(), i.status()) + return [{'intf_name':str(i), 'ip':i.IP(), 'mac':i.MAC(), 'up':i.isUp(), 'status':i.status()} for i in self.intfList()] def getStatus(self): diff --git a/src/emuvim/examples/monitoring_demo_topology.py b/src/emuvim/examples/monitoring_demo_topology.py index fc515a8..8592d62 100755 --- a/src/emuvim/examples/monitoring_demo_topology.py +++ b/src/emuvim/examples/monitoring_demo_topology.py @@ -29,7 +29,7 @@ def create_topology1(): """ 1. Create a data center network object (DCNetwork) with monitoring enabled """ - net = DCNetwork(monitor=False) + net = DCNetwork(monitor=True) """ 1b. add a monitoring agent to the DCNetwork