Merge "Support enable/disable uplink status propagation"

This commit is contained in:
Zuul 2018-12-24 12:00:03 +00:00 committed by Gerrit Code Review
commit 7b72fb816f
5 changed files with 74 additions and 0 deletions

View File

@ -26,6 +26,7 @@ Create new port
[--binding-profile <binding-profile>]
[--host <host-id>]
[--enable | --disable]
[--enable-uplink-status-propagation | --disable-uplink-status-propagation]
[--mac-address <mac-address>]
[--security-group <security-group> | --no-security-group]
[--dns-domain <dns-domain>]
@ -87,6 +88,14 @@ Create new 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>
MAC address of this port

View File

@ -163,6 +163,13 @@ def _get_attrs(client_manager, parsed_args):
attrs['qos_policy_id'] = client_manager.network.find_qos_policy(
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
@ -349,6 +356,17 @@ class CreatePort(command.ShowOne):
action='store_true',
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(
'--project',
metavar='<project>',

View File

@ -581,6 +581,7 @@ class FakePort(object):
'tenant_id': 'project-id-' + uuid.uuid4().hex,
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
'tags': [],
'uplink_status_propagation': False,
}
# Overwrite default attributes.
@ -600,6 +601,8 @@ class FakePort(object):
port.project_id = port_attrs['tenant_id']
port.security_group_ids = port_attrs['security_group_ids']
port.qos_policy_id = port_attrs['qos_policy_id']
port.uplink_status_propagation = port_attrs[
'uplink_status_propagation']
return port

View File

@ -64,6 +64,7 @@ class TestPort(network_fakes.TestNetworkV2):
'security_group_ids',
'status',
'tags',
'uplink_status_propagation',
)
data = (
@ -93,6 +94,7 @@ class TestPort(network_fakes.TestNetworkV2):
utils.format_list(fake_port.security_group_ids),
fake_port.status,
utils.format_list(fake_port.tags),
fake_port.uplink_status_propagation,
)
return columns, data
@ -571,6 +573,43 @@ class TestCreatePort(TestPort):
def test_create_with_no_tag(self):
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):

View File

@ -0,0 +1,5 @@
---
features:
- |
Add ``--enable-uplink-status-propagation`` option and
``--disable-uplink-status-propagation`` option to ``port create`` command.