From c6ace2d9c93a95405acabc7b72a0a6672c01dae3 Mon Sep 17 00:00:00 2001 From: stevenvanrossem Date: Fri, 21 Apr 2017 13:47:06 +0200 Subject: [PATCH] fix monitoring bug add option to specify sap vnfd file in toplogy file --- src/emuvim/api/sonata/__init__.py | 4 +- src/emuvim/api/sonata/dummygatekeeper.py | 7 ++- src/emuvim/dcemulator/monitoring.py | 6 ++- src/emuvim/examples/sonata_simple_topology.py | 13 ++++- src/emuvim/examples/vepc_sap_vnfd.yml | 50 +++++++++++++++++++ 5 files changed, 74 insertions(+), 6 deletions(-) create mode 100755 src/emuvim/examples/vepc_sap_vnfd.yml diff --git a/src/emuvim/api/sonata/__init__.py b/src/emuvim/api/sonata/__init__.py index 6a6e2c2..fa87370 100755 --- a/src/emuvim/api/sonata/__init__.py +++ b/src/emuvim/api/sonata/__init__.py @@ -46,7 +46,8 @@ class SonataDummyGatekeeperEndpoint(object): topology. """ - def __init__(self, listenip, port, deploy_sap=False, docker_management=False, auto_deploy=False, auto_delete=False): + def __init__(self, listenip, port, deploy_sap=False, docker_management=False, + auto_deploy=False, auto_delete=False, sap_vnfd_path=None): self.dcs = {} self.ip = listenip self.port = port @@ -54,6 +55,7 @@ class SonataDummyGatekeeperEndpoint(object): dgk.USE_DOCKER_MGMT = docker_management dgk.AUTO_DEPLOY = auto_deploy dgk.AUTO_DELETE = auto_delete + dgk.SAP_VNFD = sap_vnfd_path logging.debug("Created API endpoint %s" % self) def __repr__(self): diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index e1feaf7..7d1f525 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -98,6 +98,8 @@ ELAN_SUBNETS = generate_subnets('10.20', 0, subnet_size=50, mask=24) # 10.30.xxx.0/30 ELINE_SUBNETS = generate_subnets('10.30', 0, subnet_size=50, mask=30) +# path to the VNFD for the SAP VNF that is deployed as internal SAP point +SAP_VNFD=None class Gatekeeper(object): @@ -514,7 +516,10 @@ class Service(object): # Each Service Access Point (connection_point) in the nsd is getting its own container (default) elif sap["type"] == "internal" or sap["type"] == "management": # add SAP to self.vnfds - sapfile = pkg_resources.resource_filename(__name__, "sap_vnfd.yml") + if SAP_VNFD is None: + sapfile = pkg_resources.resource_filename(__name__, "sap_vnfd.yml") + else: + sapfile = SAP_VNFD sap_vnfd = load_yaml(sapfile) sap_vnfd["connection_points"][0]["id"] = sap_interface sap_vnfd["name"] = sap_docker_name diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index ce24a40..985a1c1 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -202,7 +202,7 @@ class DCNetworkMonitor(): network_metric = {} # check if port is specified (vnf:port) - if vnf_interface is None: + if vnf_interface is None or vnf_interface == '': # take first interface by default connected_sw = self.net.DCNetwork_graph.neighbors(vnf_name)[0] link_dict = self.net.DCNetwork_graph[vnf_name][connected_sw] @@ -404,8 +404,10 @@ class DCNetworkMonitor(): previous_measurement = metric_dict['previous_measurement'] previous_monitor_time = metric_dict['previous_monitor_time'] mon_port = metric_dict['mon_port'] - for port_stat in port_stat_dict[str(switch_dpid)]: + # ovs output also gives back 'LOCAL' port + if port_stat['port_no'] == 'LOCAL': + continue if int(port_stat['port_no']) == int(mon_port): port_uptime = port_stat['duration_sec'] + port_stat['duration_nsec'] * 10 ** (-9) this_measurement = int(port_stat[metric_key]) diff --git a/src/emuvim/examples/sonata_simple_topology.py b/src/emuvim/examples/sonata_simple_topology.py index b68e760..bf3cc20 100755 --- a/src/emuvim/examples/sonata_simple_topology.py +++ b/src/emuvim/examples/sonata_simple_topology.py @@ -40,13 +40,14 @@ from emuvim.dcemulator.net import DCNetwork from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint from emuvim.api.sonata import SonataDummyGatekeeperEndpoint from mininet.node import RemoteController +import os logging.basicConfig(level=logging.INFO) def create_topology1(): # create topology - net = DCNetwork(controller=RemoteController, monitor=True, enable_learning=True) + net = DCNetwork(controller=RemoteController, monitor=False, enable_learning=True) dc1 = net.addDatacenter("dc1") @@ -57,8 +58,16 @@ def create_topology1(): # run API endpoint server (in another thread, don't block) rapi1.start() + + # specify a vnfd file to be deployed as internal SAP: + sap_vnfd = 'vepc_sap_vnfd.yml' + dir_path = os.path.dirname(__file__) + sap_vnfd_path = os.path.join(dir_path, sap_vnfd) + # sap_vnfd_path = None # add the SONATA dummy gatekeeper to each DC - sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", 5000, deploy_sap=True, auto_deploy=True, docker_management=True, auto_delete=True) + sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", 5000, deploy_sap=True, auto_deploy=True, + docker_management=True, auto_delete=True, + sap_vnfd_path=sap_vnfd_path) sdkg1.connectDatacenter(dc1) # run the dummy gatekeeper (in another thread, don't block) sdkg1.start() diff --git a/src/emuvim/examples/vepc_sap_vnfd.yml b/src/emuvim/examples/vepc_sap_vnfd.yml new file mode 100755 index 0000000..4ca0727 --- /dev/null +++ b/src/emuvim/examples/vepc_sap_vnfd.yml @@ -0,0 +1,50 @@ + +--- +## +## Some general information regarding this +## VNF descriptor. +## +descriptor_version: "vnfd-schema-01" +vendor: "eu.sonata-nfv" +name: "sap_vnf" +version: "0.1" +author: "Steven Van Rossem, Ghent University, steven.vanrossem@intec.ugent.be" +description: "A sink for the vEPC service" +## +## The virtual deployment unit. +## +virtual_deployment_units: + - id: "1" + vm_image: "sink:v3" + vm_image_format: "docker" + resource_requirements: + cpu: + vcpus: 1 + memory: + size: 1 + size_unit: "GB" + storage: + size: 1 + size_unit: "GB" + connection_points: + - id: "vdu01:cp01" + type: "interface" + +## +## The virtual links that interconnect +## the different connections points. +## +virtual_links: + - id: "port" + connectivity_type: "E-Line" + connection_points_reference: + - "vdu01:cp01" + - "port" + +## +## The VNF connection points to the +## outside world. +## +connection_points: + - id: "port" + type: "interface" -- 2.25.1