fix monitoring bug
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 21 Apr 2017 11:47:06 +0000 (13:47 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Fri, 21 Apr 2017 11:47:06 +0000 (13:47 +0200)
add option to specify sap vnfd file in toplogy file

src/emuvim/api/sonata/__init__.py
src/emuvim/api/sonata/dummygatekeeper.py
src/emuvim/dcemulator/monitoring.py
src/emuvim/examples/sonata_simple_topology.py
src/emuvim/examples/vepc_sap_vnfd.yml [new file with mode: 0755]

index 6a6e2c2..fa87370 100755 (executable)
@@ -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):
index e1feaf7..7d1f525 100755 (executable)
@@ -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
index ce24a40..985a1c1 100755 (executable)
@@ -202,7 +202,7 @@ class DCNetworkMonitor():
         network_metric = {}\r
 \r
         # check if port is specified (vnf:port)\r
-        if vnf_interface is None:\r
+        if vnf_interface is None or vnf_interface == '':\r
             # take first interface by default\r
             connected_sw = self.net.DCNetwork_graph.neighbors(vnf_name)[0]\r
             link_dict = self.net.DCNetwork_graph[vnf_name][connected_sw]\r
@@ -404,8 +404,10 @@ class DCNetworkMonitor():
         previous_measurement = metric_dict['previous_measurement']\r
         previous_monitor_time = metric_dict['previous_monitor_time']\r
         mon_port = metric_dict['mon_port']\r
-\r
         for port_stat in port_stat_dict[str(switch_dpid)]:\r
+            # ovs output also gives back 'LOCAL' port\r
+            if port_stat['port_no'] == 'LOCAL':\r
+                continue\r
             if int(port_stat['port_no']) == int(mon_port):\r
                 port_uptime = port_stat['duration_sec'] + port_stat['duration_nsec'] * 10 ** (-9)\r
                 this_measurement = int(port_stat[metric_key])\r
index b68e760..bf3cc20 100755 (executable)
@@ -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 (executable)
index 0000000..4ca0727
--- /dev/null
@@ -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"