Bug 138 48/948/1
authorHashir Mohammed <hashir.mohammed@riftio.com>
Thu, 12 Jan 2017 19:34:15 +0000 (14:34 -0500)
committerHashir Mohammed <hashir.mohammed@riftio.com>
Fri, 13 Jan 2017 13:20:01 +0000 (08:20 -0500)
  * Bug fixes
   - Handle the case where Openstack is not configured with port security driver

Signed-off-by: Hashir Mohammed <hashir.mohammed@riftio.com>
models/plugins/yang/vnfd.yang
rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py
rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py
rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py

index 26f0a9f..3fa141f 100644 (file)
@@ -70,7 +70,6 @@ module vnfd
     leaf port-security-enabled {
       description "Enables the port security for the port";
       type boolean;
-      default true;
     }
   }
 
index a88013a..ae12b13 100644 (file)
@@ -1436,8 +1436,9 @@ class NeutronDriver(object):
                 "name"              : kwargs['name'],
                 "network_id"        : kwargs['network_id'],
                 "fixed_ips"         : [ {"subnet_id": kwargs['subnet_id']}],
-                "binding:vnic_type" : kwargs['port_type'],
-                "port_security_enabled" : kwargs['port_security_enabled']}}
+                "binding:vnic_type" : kwargs['port_type']}}
+        if 'port_security_enabled' in kwargs:
+            params["port"]["port_security_enabled"] = kwargs['port_security_enabled']
 
         ntconn = self._get_neutron_connection()
         try:
index a370330..3794ce5 100644 (file)
@@ -1501,10 +1501,8 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud):
             raise NotImplementedError("Port Type: %s not supported" %(c_point.type_yang))
 
         # By default port gets created with post_security enaled as True
-        if c_point.port_security_enabled is not None and c_point.port_security_enabled == False:
-            kwargs['port_security_enabled'] = False
-        else:
-            kwargs['port_security_enabled'] = True
+        if 'port_security_enabled' in c_point:
+            kwargs['port_security_enabled'] = c_point.port_security_enabled
 
         with self._use_driver(account) as drv:
             if c_point.has_field('security_group'):
index d683a60..0537cc5 100755 (executable)
@@ -957,7 +957,6 @@ class VirtualNetworkFunctionRecord(object):
         vnfr_dict.update(vnfd_copy_dict)
 
         vnfr = RwVnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr.from_dict(vnfr_dict)
-
         vnfr.vnfd = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_Vnfd.from_dict(self.vnfd.as_dict(),
                                                                           ignore_missing_keys=True)
         vnfr.member_vnf_index_ref = self.member_vnf_index
@@ -1073,7 +1072,9 @@ class VirtualNetworkFunctionRecord(object):
             cpr = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_ConnectionPoint()
             cpr.name = conn_p.name
             cpr.type_yang = conn_p.type_yang
-            cpr.port_security_enabled = conn_p.port_security_enabled
+            if conn_p.has_field('port_security_enabled'):
+              cpr.port_security_enabled = conn_p.port_security_enabled
+
             vlr_ref = find_vlr_for_cp(conn_p)
             if vlr_ref is None:
                 msg = "Failed to find VLR for cp = %s" % conn_p.name
index 2bcbecc..5ff2983 100755 (executable)
@@ -632,10 +632,12 @@ class VirtualDeploymentUnitRecord(object):
 
         cp_list = []
         for intf, cp, vlr in self._ext_intf:
-            cp_info = {"name": cp.name,
-                       "virtual_link_id": vlr.network_id,
-                       "type_yang": intf.virtual_interface.type_yang,
-                       "port_security_enabled": cp.port_security_enabled}
+            cp_info = { "name": cp.name,
+                        "virtual_link_id": vlr.network_id,
+                        "type_yang": intf.virtual_interface.type_yang }
+
+            if cp.has_field('port_security_enabled'):
+                cp_info["port_security_enabled"] = cp.port_security_enabled
 
             if (intf.virtual_interface.has_field('vpci') and
                     intf.virtual_interface.vpci is not None):
@@ -654,10 +656,16 @@ class VirtualDeploymentUnitRecord(object):
                                 "type_yang": intf.virtual_interface.type_yang,
                                 "vpci": intf.virtual_interface.vpci})
             else:
-                cp_list.append({"name": cp,
-                                "virtual_link_id": vlr.network_id,
-                                "type_yang": intf.virtual_interface.type_yang,
-                                "port_security_enabled": cp.port_security_enabled})
+                if cp.has_field('port_security_enabled'):
+                    cp_list.append({"name": cp,
+                                    "virtual_link_id": vlr.network_id,
+                                    "type_yang": intf.virtual_interface.type_yang,
+                                    "port_security_enabled": cp.port_security_enabled})
+                else:
+                    cp_list.append({"name": cp,
+                                    "virtual_link_id": vlr.network_id,
+                                    "type_yang": intf.virtual_interface.type_yang})
+
 
         vm_create_msg_dict["connection_points"] = cp_list
         vm_create_msg_dict.update(vdu_copy_dict)