Bug 95 Expose mac-address in VNFRs 90/590/1 v1.0.1
authorRajesh <rajesh.velandy@riftio.com>
Tue, 1 Nov 2016 19:58:21 +0000 (19:58 +0000)
committerRajesh <rajesh.velandy@riftio.com>
Tue, 1 Nov 2016 19:58:42 +0000 (19:58 +0000)
Signed-off-by: Rajesh <rajesh.velandy@riftio.com>
models/plugins/yang/vnfr.yang
rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
rwcal/plugins/yang/rwcal.yang
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py
rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py

index 4a427d4..cd9541c 100644 (file)
@@ -191,7 +191,7 @@ module vnfr
       }
 
       leaf create-time {
-        description 
+        description
           "Creation timestamp of this Virtual Network 
           Function.  The timestamp is expressed as 
           seconds since unix epoch - 1970-01-01T00:00:00Z";
@@ -252,7 +252,7 @@ module vnfr
         uses vnfd:common-connection-point;
 
         leaf vlr-ref {
-          description 
+          description
               "Reference to the VLR associated with this connection point";
           type  leafref {
             path "/vlr:vlr-catalog/vlr:vlr/vlr:id";
@@ -260,10 +260,16 @@ module vnfr
         }
 
         leaf ip-address {
-          description 
+          description
               "IP address assigned to the external connection point";
           type inet:ip-address;
         }
+        leaf mac-address {
+          description
+              "MAC address assigned to the external connection point";
+          // type inet:mac-address;
+          type string;
+        }
         leaf connection-point-id {
           rwpb:field-inline "true";
           rwpb:field-string-max 64;
@@ -351,10 +357,16 @@ module vnfr
           uses vnfd:common-connection-point;
 
           leaf ip-address {
-            description 
-                "IP address assigned to the external connection point";
+            description
+                "IP address assigned to the internal connection point";
             type inet:ip-address;
           }
+          leaf mac-address {
+            description
+                "MAC address assigned to the internal connection point";
+            // type inet:mac-address;
+            type string;
+          }
         }
 
         list internal-interface {
index 19eea3b..ddf665a 100644 (file)
@@ -1159,6 +1159,8 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
         if ('fixed_ips' in port_info) and (len(port_info['fixed_ips']) >= 1):
             if 'ip_address' in port_info['fixed_ips'][0]:
                 c_point.ip_address = port_info['fixed_ips'][0]['ip_address']
+        if 'mac_address' in port_info :
+            c_point.mac_addr = port_info['mac_address']
         if port_info['status'] == 'ACTIVE':
             c_point.state = 'active'
         else:
index 09e4acc..9519d05 100644 (file)
@@ -1092,6 +1092,12 @@ module rwcal
       rwpb:field-string-max 64;
       type string;
     }
+
+    leaf mac-addr {
+      rwpb:field-inline "true";
+      rwpb:field-string-max 48;
+      type string;
+    }
   }
 
   grouping virtual-link-info-params {
index ddc4c9b..1f29d06 100644 (file)
@@ -546,6 +546,11 @@ class OpenmanoNsr(object):
                     return vnf["ip_address"].strip()
                 return None
 
+            def get_vnf_mac_address(vnf):
+                if "mac_address" in vnf:
+                    return vnf["mac_address"].strip()
+                return None
+
             def get_ext_cp_info(vnf):
                 cp_info_list = []
                 for vm in vnf["vms"]:
@@ -563,7 +568,11 @@ class OpenmanoNsr(object):
                         if ip_address is None:
                             ip_address = "0.0.0.0"
 
-                        cp_info_list.append((intf["external_name"], ip_address))
+                        mac_address = intf["mac_address"]
+                        if mac_address is None:
+                            mac_address="00:00:00:00:00:00"
+
+                        cp_info_list.append((intf["external_name"], ip_address, mac_address))
 
                 return cp_info_list
 
@@ -611,6 +620,7 @@ class OpenmanoNsr(object):
 
                     if all_vms_active(vnf_status):
                         vnf_ip_address = get_vnf_ip_address(vnf_status)
+                        vnf_mac_address = get_vnf_mac_address(vnf_status)
 
                         if vnf_ip_address is None:
                             self._log.warning("No IP address obtained "
@@ -621,7 +631,7 @@ class OpenmanoNsr(object):
                         self._log.debug("All VMs in VNF are active.  Marking as running.")
                         vnfr_msg.operational_status = "running"
 
-                        self._log.debug("Got VNF ip address: %s", vnf_ip_address)
+                        self._log.debug("Got VNF ip address: %s, mac-address: %s", vnf_ip_address, vnf_mac_address)
                         vnfr_msg.mgmt_interface.ip_address = vnf_ip_address
                         vnfr_msg.vnf_configuration.config_access.mgmt_ip_address = vnf_ip_address
 
@@ -639,11 +649,12 @@ class OpenmanoNsr(object):
 
                         # Add connection point information for the config manager
                         cp_info_list = get_ext_cp_info(vnf_status)
-                        for (cp_name, cp_ip) in cp_info_list:
+                        for (cp_name, cp_ip, cp_mac_addr) in cp_info_list:
                             cp = vnfr_msg.connection_point.add()
                             cp.name = cp_name
                             cp.short_name = cp_name
                             cp.ip_address = cp_ip
+                            cp.mac_address = cp_mac_addr
 
                         yield from self._publisher.publish_vnfr(None, vnfr_msg)
                         active_vnfs.append(vnfr)
index 2c6c102..eef4ded 100755 (executable)
@@ -308,6 +308,14 @@ class VirtualDeploymentUnitRecord(object):
                     return conn_point.ip_address
         return "0.0.0.0"
 
+    def cp_mac_addr(self, cp_name):
+        """ Find mac address by connection point name """
+        if self._vm_resp is not None:
+            for conn_point in self._vm_resp.connection_points:
+                if conn_point.name == cp_name:
+                    return conn_point.mac_addr
+        return "00:00:00:00:00:00"
+
     def cp_id(self, cp_name):
         """ Find connection point id  by connection point name """
         if self._vm_resp is not None:
@@ -408,7 +416,8 @@ class VirtualDeploymentUnitRecord(object):
             icp_list.append({"name": cp.name,
                              "id": cp.id,
                              "type_yang": "VPORT",
-                             "ip_address": self.cp_ip_addr(cp.id)})
+                             "ip_address": self.cp_ip_addr(cp.id),
+                             "mac_address": self.cp_mac_addr(cp.id)})
 
             ii_list.append({"name": intf.name,
                             "vdur_internal_connection_point_ref": cp.id,
@@ -423,7 +432,10 @@ class VirtualDeploymentUnitRecord(object):
             ei_list.append({"name": cp,
                             "vnfd_connection_point_ref": cp,
                             "virtual_interface": {}})
-            self._vnfr.update_cp(cp, self.cp_ip_addr(cp), self.cp_id(cp))
+            self._vnfr.update_cp(cp,
+                                 self.cp_ip_addr(cp),
+                                 self.cp_mac_addr(cp),
+                                 self.cp_id(cp))
 
         vdur_dict["external_interface"] = ei_list
 
@@ -1651,13 +1663,14 @@ class VirtualNetworkFunctionRecord(object):
         # Update the VNFR with the changed status
         yield from self.publish(None)
 
-    def update_cp(self, cp_name, ip_address, cp_id):
+    def update_cp(self, cp_name, ip_address, mac_addr, cp_id):
         """Updated the connection point with ip address"""
         for cp in self._cprs:
             if cp.name == cp_name:
                 self._log.debug("Setting ip address and id for cp %s, cpr %s with ip %s id %s",
                                 cp_name, cp, ip_address, cp_id)
                 cp.ip_address = ip_address
+                cp.mac_address = mac_addr
                 cp.connection_point_id = cp_id
                 return