Support enable/disable uplink status propagation
Add options to enable/disable uplink status propagation on creating a neutron port. Related patches: * neutron: https://review.openstack.org/#/c/571899/ * openstacksdk: https://review.openstack.org/#/c/586687/ Depends-On: https://review.openstack.org/#/c/586687/ Change-Id: I095a98fc5f5aee62d979a16b3cd79d91ec3b9ddb Related-Bug: #1722720
This commit is contained in:
parent
8be53a50e5
commit
c82f4237e5
@ -26,6 +26,7 @@ Create new port
|
|||||||
[--binding-profile <binding-profile>]
|
[--binding-profile <binding-profile>]
|
||||||
[--host <host-id>]
|
[--host <host-id>]
|
||||||
[--enable | --disable]
|
[--enable | --disable]
|
||||||
|
[--enable-uplink-status-propagation | --disable-uplink-status-propagation]
|
||||||
[--mac-address <mac-address>]
|
[--mac-address <mac-address>]
|
||||||
[--security-group <security-group> | --no-security-group]
|
[--security-group <security-group> | --no-security-group]
|
||||||
[--dns-domain <dns-domain>]
|
[--dns-domain <dns-domain>]
|
||||||
@ -87,6 +88,14 @@ Create new port
|
|||||||
|
|
||||||
Disable port
|
Disable port
|
||||||
|
|
||||||
|
.. option:: --enable-uplink-status-propagation
|
||||||
|
|
||||||
|
Enable uplink status propagate
|
||||||
|
|
||||||
|
.. option:: --disable-uplink-status-propagation
|
||||||
|
|
||||||
|
Disable uplink status propagate (default)
|
||||||
|
|
||||||
.. option:: --mac-address <mac-address>
|
.. option:: --mac-address <mac-address>
|
||||||
|
|
||||||
MAC address of this port
|
MAC address of this port
|
||||||
|
@ -163,6 +163,13 @@ def _get_attrs(client_manager, parsed_args):
|
|||||||
attrs['qos_policy_id'] = client_manager.network.find_qos_policy(
|
attrs['qos_policy_id'] = client_manager.network.find_qos_policy(
|
||||||
parsed_args.qos_policy, ignore_missing=False).id
|
parsed_args.qos_policy, ignore_missing=False).id
|
||||||
|
|
||||||
|
if ('enable_uplink_status_propagation' in parsed_args and
|
||||||
|
parsed_args.enable_uplink_status_propagation):
|
||||||
|
attrs['propagate_uplink_status'] = True
|
||||||
|
if ('disable_uplink_status_propagation' in parsed_args and
|
||||||
|
parsed_args.disable_uplink_status_propagation):
|
||||||
|
attrs['propagate_uplink_status'] = False
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
@ -349,6 +356,17 @@ class CreatePort(command.ShowOne):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help=_("Disable port")
|
help=_("Disable port")
|
||||||
)
|
)
|
||||||
|
uplink_status_group = parser.add_mutually_exclusive_group()
|
||||||
|
uplink_status_group.add_argument(
|
||||||
|
'--enable-uplink-status-propagation',
|
||||||
|
action='store_true',
|
||||||
|
help=_("Enable uplink status propagate")
|
||||||
|
)
|
||||||
|
uplink_status_group.add_argument(
|
||||||
|
'--disable-uplink-status-propagation',
|
||||||
|
action='store_true',
|
||||||
|
help=_("Disable uplink status propagate (default)")
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--project',
|
'--project',
|
||||||
metavar='<project>',
|
metavar='<project>',
|
||||||
|
@ -581,6 +581,7 @@ class FakePort(object):
|
|||||||
'tenant_id': 'project-id-' + uuid.uuid4().hex,
|
'tenant_id': 'project-id-' + uuid.uuid4().hex,
|
||||||
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
||||||
'tags': [],
|
'tags': [],
|
||||||
|
'uplink_status_propagation': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
@ -600,6 +601,8 @@ class FakePort(object):
|
|||||||
port.project_id = port_attrs['tenant_id']
|
port.project_id = port_attrs['tenant_id']
|
||||||
port.security_group_ids = port_attrs['security_group_ids']
|
port.security_group_ids = port_attrs['security_group_ids']
|
||||||
port.qos_policy_id = port_attrs['qos_policy_id']
|
port.qos_policy_id = port_attrs['qos_policy_id']
|
||||||
|
port.uplink_status_propagation = port_attrs[
|
||||||
|
'uplink_status_propagation']
|
||||||
|
|
||||||
return port
|
return port
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
|||||||
'security_group_ids',
|
'security_group_ids',
|
||||||
'status',
|
'status',
|
||||||
'tags',
|
'tags',
|
||||||
|
'uplink_status_propagation',
|
||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
@ -93,6 +94,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
|||||||
utils.format_list(fake_port.security_group_ids),
|
utils.format_list(fake_port.security_group_ids),
|
||||||
fake_port.status,
|
fake_port.status,
|
||||||
utils.format_list(fake_port.tags),
|
utils.format_list(fake_port.tags),
|
||||||
|
fake_port.uplink_status_propagation,
|
||||||
)
|
)
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
@ -571,6 +573,43 @@ class TestCreatePort(TestPort):
|
|||||||
def test_create_with_no_tag(self):
|
def test_create_with_no_tag(self):
|
||||||
self._test_create_with_tag(add_tags=False)
|
self._test_create_with_tag(add_tags=False)
|
||||||
|
|
||||||
|
def _test_create_with_uplink_status_propagation(self, enable=True):
|
||||||
|
arglist = [
|
||||||
|
'--network', self._port.network_id,
|
||||||
|
'test-port',
|
||||||
|
]
|
||||||
|
if enable:
|
||||||
|
arglist += ['--enable-uplink-status-propagation']
|
||||||
|
else:
|
||||||
|
arglist += ['--disable-uplink-status-propagation']
|
||||||
|
verifylist = [
|
||||||
|
('network', self._port.network_id,),
|
||||||
|
('name', 'test-port'),
|
||||||
|
]
|
||||||
|
if enable:
|
||||||
|
verifylist.append(('enable_uplink_status_propagation', True))
|
||||||
|
else:
|
||||||
|
verifylist.append(('disable_uplink_status_propagation', True))
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = (self.cmd.take_action(parsed_args))
|
||||||
|
|
||||||
|
self.network.create_port.assert_called_once_with(**{
|
||||||
|
'admin_state_up': True,
|
||||||
|
'network_id': self._port.network_id,
|
||||||
|
'propagate_uplink_status': enable,
|
||||||
|
'name': 'test-port',
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_create_with_uplink_status_propagation_enabled(self):
|
||||||
|
self._test_create_with_uplink_status_propagation(enable=True)
|
||||||
|
|
||||||
|
def test_create_with_uplink_status_propagation_disabled(self):
|
||||||
|
self._test_create_with_uplink_status_propagation(enable=False)
|
||||||
|
|
||||||
|
|
||||||
class TestDeletePort(TestPort):
|
class TestDeletePort(TestPort):
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--enable-uplink-status-propagation`` option and
|
||||||
|
``--disable-uplink-status-propagation`` option to ``port create`` command.
|
Loading…
Reference in New Issue
Block a user