From 4d11d3117a44f13a1271b9c018707d316d49100a Mon Sep 17 00:00:00 2001 From: Jason Li Date: Tue, 5 May 2020 00:39:43 -0500 Subject: [PATCH] Add propagate_uplink_status support to OS::Neutron::Port This resource depends on Neutron API extension ``uplink-status-propagation`` and the default is ``False``. If this property is set to ``True``, the VF link state can follow that of PF. See release note at https://docs.openstack.org/releasenotes/neutron/stein.html. Change-Id: I46749f0458fd69e3f62d03e5b4648e1704750e15 --- .../resources/openstack/neutron/port.py | 18 ++++++-- .../openstack/neutron/test_neutron_port.py | 43 +++++++++++++++++++ ...k-status-propagation-abd90d794e330d31.yaml | 8 ++++ 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add-port-uplink-status-propagation-abd90d794e330d31.yaml diff --git a/heat/engine/resources/openstack/neutron/port.py b/heat/engine/resources/openstack/neutron/port.py index c2b7e6478a..4ea844121e 100644 --- a/heat/engine/resources/openstack/neutron/port.py +++ b/heat/engine/resources/openstack/neutron/port.py @@ -53,11 +53,11 @@ class Port(neutron.NeutronResource): EXTRA_PROPERTIES = ( VALUE_SPECS, ADMIN_STATE_UP, MAC_ADDRESS, ALLOWED_ADDRESS_PAIRS, VNIC_TYPE, QOS_POLICY, - PORT_SECURITY_ENABLED, + PORT_SECURITY_ENABLED, PROPAGATE_UPLINK_STATUS, ) = ( 'value_specs', 'admin_state_up', 'mac_address', 'allowed_address_pairs', 'binding:vnic_type', 'qos_policy', - 'port_security_enabled', + 'port_security_enabled', 'propagate_uplink_status', ) _FIXED_IP_KEYS = ( @@ -77,12 +77,13 @@ class Port(neutron.NeutronResource): MAC_ADDRESS_ATTR, NAME_ATTR, NETWORK_ID_ATTR, SECURITY_GROUPS_ATTR, STATUS, TENANT_ID, ALLOWED_ADDRESS_PAIRS_ATTR, SUBNETS_ATTR, PORT_SECURITY_ENABLED_ATTR, QOS_POLICY_ATTR, DNS_ASSIGNMENT, - NETWORK_ATTR, + NETWORK_ATTR, PROPAGATE_UPLINK_STATUS_ATTR, ) = ( 'admin_state_up', 'device_id', 'device_owner', 'fixed_ips', 'mac_address', 'name', 'network_id', 'security_groups', 'status', 'tenant_id', 'allowed_address_pairs', 'subnets', 'port_security_enabled', 'qos_policy_id', 'dns_assignment', 'network', + 'propagate_uplink_status', ) properties_schema = { @@ -305,6 +306,12 @@ class Port(neutron.NeutronResource): update_allowed=True, support_status=support.SupportStatus(version='6.0.0') ), + PROPAGATE_UPLINK_STATUS: properties.Schema( + properties.Schema.BOOLEAN, + _('Flag to enable/disable propagate uplink status on the port.'), + update_allowed=True, + support_status=support.SupportStatus(version='15.0.0') + ), } # Need to update properties_schema with other properties before @@ -394,6 +401,11 @@ class Port(neutron.NeutronResource): type=attributes.Schema.MAP, support_status=support.SupportStatus(version='11.0.0'), ), + PROPAGATE_UPLINK_STATUS_ATTR: attributes.Schema( + _("Enable/Disable propagate uplink status for the port."), + support_status=support.SupportStatus(version='15.0.0'), + type=attributes.Schema.BOOLEAN + ), } def translation_rules(self, props): diff --git a/heat/tests/openstack/neutron/test_neutron_port.py b/heat/tests/openstack/neutron/test_neutron_port.py index 228273cdea..2e534689a1 100644 --- a/heat/tests/openstack/neutron/test_neutron_port.py +++ b/heat/tests/openstack/neutron/test_neutron_port.py @@ -67,6 +67,18 @@ resources: ''' +neutron_port_propagate_ul_status_template = ''' +heat_template_version: 2015-04-30 +description: Template to test port Neutron resource +resources: + port: + type: OS::Neutron::Port + properties: + network: abcd1234 + propagate_uplink_status: True +''' + + class NeutronPortTest(common.HeatTestCase): def setUp(self): @@ -239,6 +251,34 @@ class NeutronPortTest(common.HeatTestCase): 'device_owner': '' }}) + def test_port_propagate_uplink_status(self): + t = template_format.parse(neutron_port_propagate_ul_status_template) + stack = utils.parse_stack(t) + + self.find_mock.return_value = 'abcd1234' + + self.create_mock.return_value = {'port': { + "status": "BUILD", + "id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766" + }} + + self.port_show_mock.return_value = {'port': { + "status": "ACTIVE", + "id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766", + }} + + port = stack['port'] + scheduler.TaskRunner(port.create)() + self.create_mock.assert_called_once_with({'port': { + 'network_id': u'abcd1234', + 'propagate_uplink_status': True, + 'name': utils.PhysName(stack.name, 'port'), + 'admin_state_up': True, + 'binding:vnic_type': 'normal', + 'device_id': '', + 'device_owner': '' + }}) + def test_missing_mac_address(self): t = template_format.parse(neutron_port_with_address_pair_template) t['resources']['port']['properties']['allowed_address_pairs'][0].pop( @@ -579,6 +619,7 @@ class NeutronPortTest(common.HeatTestCase): 'ipv4_address_scope': None, 'description': '', 'subnets': [subnet_dict['id']], 'port_security_enabled': True, + 'propagate_uplink_status': True, 'tenant_id': '58a61fc3992944ce971404a2ece6ff98', 'tags': [], 'ipv6_address_scope': None, 'project_id': '58a61fc3992944ce971404a2ece6ff98', @@ -882,6 +923,7 @@ class NeutronPortTest(common.HeatTestCase): 'tenant_id': '30f466e3d14b4251853899f9c26e2b66', 'binding:profile': {}, 'port_security_enabled': True, + 'propagate_uplink_status': True, 'binding:vnic_type': 'normal', 'fixed_ips': [ {'subnet_id': '02d9608f-8f30-4611-ad02-69855c82457f', @@ -901,6 +943,7 @@ class NeutronPortTest(common.HeatTestCase): 'admin_state_up': True, 'device_owner': '', 'port_security_enabled': True, + 'propagate_uplink_status': True, 'binding:vnic_type': 'normal', 'fixed_ips': [ {'subnet': '02d9608f-8f30-4611-ad02-69855c82457f', diff --git a/releasenotes/notes/add-port-uplink-status-propagation-abd90d794e330d31.yaml b/releasenotes/notes/add-port-uplink-status-propagation-abd90d794e330d31.yaml new file mode 100644 index 0000000000..bd067a15ef --- /dev/null +++ b/releasenotes/notes/add-port-uplink-status-propagation-abd90d794e330d31.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Added ``propagate_uplink_status`` property to resource type + ``OS::Neutron::Port``. This resource depends on Neutron API + extension ``uplink-status-propagation`` and the default is + ``False``. If this property is set to ``True``, the VF link + state can follow that of PF.