diff --git a/lower-constraints.txt b/lower-constraints.txt index 25f71e45a2..f93db8aa8c 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -38,7 +38,7 @@ msgpack-python==0.4.0 munch==2.1.0 netaddr==0.7.18 netifaces==0.10.4 -openstacksdk==0.52.0 +openstacksdk==0.53.0 os-client-config==2.1.0 os-service-types==1.7.0 os-testr==1.0.0 diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py index cb77759efd..dfdb604d55 100644 --- a/openstackclient/network/v2/port.py +++ b/openstackclient/network/v2/port.py @@ -168,6 +168,9 @@ def _get_attrs(client_manager, parsed_args): parsed_args.numa_policy_legacy): attrs['numa_affinity_policy'] = 'legacy' + if 'device_profile' in parsed_args and parsed_args.device_profile: + attrs['device_profile'] = parsed_args.device_profile + return attrs @@ -443,6 +446,11 @@ class CreatePort(command.ShowOne): "ip-address=[,mac-address=] " "(repeat option to set multiple allowed-address pairs)") ) + parser.add_argument( + '--device-profile', + metavar='', + help=_('Cyborg port device profile') + ) _tag.add_tag_option_to_parser_for_create(parser, _('port')) return parser diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py index d690669038..e5023d43c5 100644 --- a/openstackclient/tests/unit/network/v2/fakes.py +++ b/openstackclient/tests/unit/network/v2/fakes.py @@ -697,6 +697,7 @@ class FakePort(object): 'description': 'description-' + uuid.uuid4().hex, 'device_id': 'device-id-' + uuid.uuid4().hex, 'device_owner': 'compute:nova', + 'device_profile': 'cyborg_device_profile_1', 'dns_assignment': [{}], 'dns_domain': 'dns-domain-' + uuid.uuid4().hex, 'dns_name': 'dns-name-' + uuid.uuid4().hex, diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py index e21f9d01f1..c8bced71c3 100644 --- a/openstackclient/tests/unit/network/v2/test_port.py +++ b/openstackclient/tests/unit/network/v2/test_port.py @@ -54,6 +54,7 @@ class TestPort(network_fakes.TestNetworkV2): 'description', 'device_id', 'device_owner', + 'device_profile', 'dns_assignment', 'dns_domain', 'dns_name', @@ -86,6 +87,7 @@ class TestPort(network_fakes.TestNetworkV2): fake_port.description, fake_port.device_id, fake_port.device_owner, + fake_port.device_profile, format_columns.ListDictColumn(fake_port.dns_assignment), fake_port.dns_domain, fake_port.dns_name, @@ -737,6 +739,33 @@ class TestCreatePort(TestPort): def test_create_with_numa_affinity_policy_null(self): self._test_create_with_numa_affinity_policy() + def test_create_with_device_profile(self): + arglist = [ + '--network', self._port.network_id, + '--device-profile', 'cyborg_device_profile_1', + 'test-port', + ] + + verifylist = [ + ('network', self._port.network_id,), + ('device_profile', self._port.device_profile,), + ('name', 'test-port'), + ] + + 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', + 'device_profile': 'cyborg_device_profile_1', + } + self.network.create_port.assert_called_once_with(**create_args) + self.assertEqual(self.columns, columns) + self.assertItemsEqual(self.data, data) + class TestDeletePort(TestPort): diff --git a/releasenotes/notes/port-device-profile-4a3bf800da21c778.yaml b/releasenotes/notes/port-device-profile-4a3bf800da21c778.yaml new file mode 100644 index 0000000000..db0d495fd7 --- /dev/null +++ b/releasenotes/notes/port-device-profile-4a3bf800da21c778.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add device profile to ``port create`` command. diff --git a/requirements.txt b/requirements.txt index 21e291013b..5077ad779b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 cliff>=3.5.0 # Apache-2.0 iso8601>=0.1.11 # MIT -openstacksdk>=0.52.0 # Apache-2.0 +openstacksdk>=0.53.0 # Apache-2.0 osc-lib>=2.3.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 python-keystoneclient>=3.22.0 # Apache-2.0