From 5cb3710c9327277c5766894cefa26e87d914ada0 Mon Sep 17 00:00:00 2001 From: Philip Joseph Date: Thu, 29 Dec 2016 09:37:22 -0500 Subject: [PATCH] Bug 138 * Support enabling/disabling port security feature on VDU * Openstack changes to support port enabling/disabling Fix by: Hashir Mohammed Signed-off-by: Philip Joseph --- models/plugins/yang/vnfd.yang | 5 ++-- .../rift/rwcal/openstack/openstack_drv.py | 5 ++-- .../vala/rwcal_openstack/rwcal_openstack.py | 6 +++-- .../tasklets/rwnsmtasklet/rwnsmtasklet.py | 4 +--- .../tasklets/rwvnfmtasklet/rwvnfmtasklet.py | 24 +++++++------------ 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/models/plugins/yang/vnfd.yang b/models/plugins/yang/vnfd.yang index 27adfbc1..fb1bd03e 100644 --- a/models/plugins/yang/vnfd.yang +++ b/models/plugins/yang/vnfd.yang @@ -70,6 +70,7 @@ module vnfd leaf port-security-enabled { description "Enables the port security for the port"; type boolean; + default true; } } @@ -319,7 +320,7 @@ module vnfd "Use the default management interface on this VDU."; leaf vdu-id { type leafref { - path "../../vdu/id"; + path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:vdu/vnfd:id"; } } } @@ -329,7 +330,7 @@ module vnfd "Use the ip address associated with this connection point."; leaf cp { type leafref { - path "../../connection-point/name"; + path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:connection-point/vnfd:name"; } } } diff --git a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py index 191a06f4..3e38478b 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py +++ b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/openstack_drv.py @@ -1449,9 +1449,8 @@ class NeutronDriver(object): "name" : kwargs['name'], "network_id" : kwargs['network_id'], "fixed_ips" : [ {"subnet_id": kwargs['subnet_id']}], - "binding:vnic_type" : kwargs['port_type']}} - if 'port_security_enabled' in kwargs: - params["port"]["port_security_enabled"] = kwargs['port_security_enabled'] + "binding:vnic_type" : kwargs['port_type'], + "port_security_enabled" : kwargs['port_security_enabled']}} ntconn = self._get_neutron_connection() try: diff --git a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py index 2be896a5..b685f19d 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py +++ b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py @@ -1500,8 +1500,10 @@ 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 'port_security_enabled' in c_point: - kwargs['port_security_enabled'] = c_point.port_security_enabled + 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 with self._use_driver(account) as drv: if c_point.has_field('security_group'): diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py index 2568d543..081875c5 100755 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py @@ -1123,9 +1123,7 @@ class VirtualNetworkFunctionRecord(object): cpr = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_ConnectionPoint() cpr.name = conn_p.name cpr.type_yang = conn_p.type_yang - if conn_p.has_field('port_security_enabled'): - cpr.port_security_enabled = conn_p.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 diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py index 34eda9db..b86d84fe 100755 --- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py +++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py @@ -645,12 +645,10 @@ ssh_authorized_keys: 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 } - - if cp.has_field('port_security_enabled'): - cp_info["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, + "port_security_enabled": cp.port_security_enabled} if (intf.virtual_interface.has_field('vpci') and intf.virtual_interface.vpci is not None): @@ -669,16 +667,10 @@ ssh_authorized_keys: "type_yang": intf.virtual_interface.type_yang, "vpci": intf.virtual_interface.vpci}) else: - 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}) - + 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}) vm_create_msg_dict["connection_points"] = cp_list vm_create_msg_dict.update(vdu_copy_dict) -- 2.25.1