Add "trusted" attribute to the "port"
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/927723 Related-bug: #2060916 Change-Id: I8e3d4ee2208ef6bb6c96ee430d7b550a0720431e
This commit is contained in:
parent
9c5fd76d9e
commit
47144103ca
@ -93,6 +93,7 @@ def _get_columns(item):
|
|||||||
'status': 'status',
|
'status': 'status',
|
||||||
'tags': 'tags',
|
'tags': 'tags',
|
||||||
'trunk_details': 'trunk_details',
|
'trunk_details': 'trunk_details',
|
||||||
|
'trusted': 'trusted',
|
||||||
'updated_at': 'updated_at',
|
'updated_at': 'updated_at',
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@ -222,6 +223,10 @@ def _get_attrs(client_manager, parsed_args):
|
|||||||
and parsed_args.hardware_offload_type
|
and parsed_args.hardware_offload_type
|
||||||
):
|
):
|
||||||
attrs['hardware_offload_type'] = parsed_args.hardware_offload_type
|
attrs['hardware_offload_type'] = parsed_args.hardware_offload_type
|
||||||
|
if parsed_args.not_trusted:
|
||||||
|
attrs['trusted'] = False
|
||||||
|
if parsed_args.trusted:
|
||||||
|
attrs['trusted'] = True
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
@ -388,6 +393,25 @@ def _add_updatable_args(parser, create=False):
|
|||||||
'(repeat option to set multiple hints)'
|
'(repeat option to set multiple hints)'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
port_trusted = parser.add_mutually_exclusive_group()
|
||||||
|
port_trusted.add_argument(
|
||||||
|
'--trusted',
|
||||||
|
action='store_true',
|
||||||
|
help=_(
|
||||||
|
"Set port to be trusted. This will be populated into the "
|
||||||
|
"'binding:profile' dictionary and passed to the services "
|
||||||
|
"which expect it in this dictionary (for example, Nova)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
port_trusted.add_argument(
|
||||||
|
'--not-trusted',
|
||||||
|
action='store_true',
|
||||||
|
help=_(
|
||||||
|
"Set port to be not trusted. This will be populated into the "
|
||||||
|
"'binding:profile' dictionary and passed to the services "
|
||||||
|
"which expect it in this dictionary (for example, Nova)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# TODO(abhiraut): Use the SDK resource mapped attribute names once the
|
# TODO(abhiraut): Use the SDK resource mapped attribute names once the
|
||||||
@ -1122,6 +1146,11 @@ class SetPort(common.NeutronCommandWithExtraArgs):
|
|||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
attrs['hints'] = expanded_hints
|
attrs['hints'] = expanded_hints
|
||||||
|
|
||||||
|
if parsed_args.not_trusted:
|
||||||
|
attrs['trusted'] = False
|
||||||
|
if parsed_args.trusted:
|
||||||
|
attrs['trusted'] = True
|
||||||
|
|
||||||
attrs.update(
|
attrs.update(
|
||||||
self._parse_extra_properties(parsed_args.extra_properties)
|
self._parse_extra_properties(parsed_args.extra_properties)
|
||||||
)
|
)
|
||||||
|
@ -1676,6 +1676,7 @@ def create_one_port(attrs=None):
|
|||||||
'qos_network_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
'qos_network_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
||||||
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
|
||||||
'tags': [],
|
'tags': [],
|
||||||
|
'trusted': None,
|
||||||
'propagate_uplink_status': False,
|
'propagate_uplink_status': False,
|
||||||
'location': 'MUNCHMUNCHMUNCH',
|
'location': 'MUNCHMUNCHMUNCH',
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
|||||||
'security_group_ids',
|
'security_group_ids',
|
||||||
'status',
|
'status',
|
||||||
'tags',
|
'tags',
|
||||||
|
'trusted',
|
||||||
'trunk_details',
|
'trunk_details',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
)
|
)
|
||||||
@ -114,6 +115,7 @@ class TestPort(network_fakes.TestNetworkV2):
|
|||||||
format_columns.ListColumn(fake_port.security_group_ids),
|
format_columns.ListColumn(fake_port.security_group_ids),
|
||||||
fake_port.status,
|
fake_port.status,
|
||||||
format_columns.ListColumn(fake_port.tags),
|
format_columns.ListColumn(fake_port.tags),
|
||||||
|
fake_port.trusted,
|
||||||
fake_port.trunk_details,
|
fake_port.trunk_details,
|
||||||
fake_port.updated_at,
|
fake_port.updated_at,
|
||||||
)
|
)
|
||||||
@ -1111,6 +1113,50 @@ class TestCreatePort(TestPort):
|
|||||||
def test_create_with_hardware_offload_type_null(self):
|
def test_create_with_hardware_offload_type_null(self):
|
||||||
self._test_create_with_hardware_offload_type()
|
self._test_create_with_hardware_offload_type()
|
||||||
|
|
||||||
|
def _test_create_with_trusted_field(self, trusted):
|
||||||
|
arglist = [
|
||||||
|
'--network',
|
||||||
|
self._port.network_id,
|
||||||
|
'test-port',
|
||||||
|
]
|
||||||
|
if trusted:
|
||||||
|
arglist += ['--trusted']
|
||||||
|
else:
|
||||||
|
arglist += ['--not-trusted']
|
||||||
|
|
||||||
|
verifylist = [
|
||||||
|
(
|
||||||
|
'network',
|
||||||
|
self._port.network_id,
|
||||||
|
),
|
||||||
|
('name', 'test-port'),
|
||||||
|
]
|
||||||
|
if trusted:
|
||||||
|
verifylist.append(('trusted', True))
|
||||||
|
else:
|
||||||
|
verifylist.append(('trusted', False))
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
create_args = {
|
||||||
|
'admin_state_up': True,
|
||||||
|
'network_id': self._port.network_id,
|
||||||
|
'name': 'test-port',
|
||||||
|
}
|
||||||
|
create_args['trusted'] = trusted
|
||||||
|
self.network_client.create_port.assert_called_once_with(**create_args)
|
||||||
|
|
||||||
|
self.assertEqual(set(self.columns), set(columns))
|
||||||
|
self.assertCountEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_create_with_trusted_true(self):
|
||||||
|
self._test_create_with_trusted_field(True)
|
||||||
|
|
||||||
|
def test_create_with_trusted_false(self):
|
||||||
|
self._test_create_with_trusted_field(False)
|
||||||
|
|
||||||
|
|
||||||
class TestDeletePort(TestPort):
|
class TestDeletePort(TestPort):
|
||||||
# Ports to delete.
|
# Ports to delete.
|
||||||
@ -2497,6 +2543,35 @@ class TestSetPort(TestPort):
|
|||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def _test_set_trusted_field(self, trusted):
|
||||||
|
arglist = [self._port.id]
|
||||||
|
if trusted:
|
||||||
|
arglist += ['--trusted']
|
||||||
|
else:
|
||||||
|
arglist += ['--not-trusted']
|
||||||
|
|
||||||
|
verifylist = [
|
||||||
|
('port', self._port.id),
|
||||||
|
]
|
||||||
|
if trusted:
|
||||||
|
verifylist.append(('trusted', True))
|
||||||
|
else:
|
||||||
|
verifylist.append(('trusted', False))
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
self.network_client.update_port.assert_called_once_with(
|
||||||
|
self._port, **{'trusted': trusted}
|
||||||
|
)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_set_trusted_true(self):
|
||||||
|
self._test_set_trusted_field(True)
|
||||||
|
|
||||||
|
def test_set_trusted_false(self):
|
||||||
|
self._test_set_trusted_field(False)
|
||||||
|
|
||||||
|
|
||||||
class TestShowPort(TestPort):
|
class TestShowPort(TestPort):
|
||||||
# The port to show.
|
# The port to show.
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``trusted`` attribute to the ``port create`` and ``port set`` commands.
|
||||||
|
It can be set to ``true`` with ``--trusted`` and to ``false`` with
|
||||||
|
``--not-trusted`` CLI arguments passed to the ``port create`` and ``port
|
||||||
|
set`` commands``
|
Loading…
x
Reference in New Issue
Block a user