Skip to content

Commit 01a53fa

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add device profile to port"
2 parents bfa032c + 0cc878e commit 01a53fa

6 files changed

Lines changed: 44 additions & 2 deletions

File tree

lower-constraints.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ msgpack-python==0.4.0
3838
munch==2.1.0
3939
netaddr==0.7.18
4040
netifaces==0.10.4
41-
openstacksdk==0.52.0
41+
openstacksdk==0.53.0
4242
os-client-config==2.1.0
4343
os-service-types==1.7.0
4444
os-testr==1.0.0

openstackclient/network/v2/port.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ def _get_attrs(client_manager, parsed_args):
168168
parsed_args.numa_policy_legacy):
169169
attrs['numa_affinity_policy'] = 'legacy'
170170

171+
if 'device_profile' in parsed_args and parsed_args.device_profile:
172+
attrs['device_profile'] = parsed_args.device_profile
173+
171174
return attrs
172175

173176

@@ -443,6 +446,11 @@ def get_parser(self, prog_name):
443446
"ip-address=<ip-address>[,mac-address=<mac-address>] "
444447
"(repeat option to set multiple allowed-address pairs)")
445448
)
449+
parser.add_argument(
450+
'--device-profile',
451+
metavar='<device-profile>',
452+
help=_('Cyborg port device profile')
453+
)
446454
_tag.add_tag_option_to_parser_for_create(parser, _('port'))
447455
return parser
448456

openstackclient/tests/unit/network/v2/fakes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ def create_one_port(attrs=None):
697697
'description': 'description-' + uuid.uuid4().hex,
698698
'device_id': 'device-id-' + uuid.uuid4().hex,
699699
'device_owner': 'compute:nova',
700+
'device_profile': 'cyborg_device_profile_1',
700701
'dns_assignment': [{}],
701702
'dns_domain': 'dns-domain-' + uuid.uuid4().hex,
702703
'dns_name': 'dns-name-' + uuid.uuid4().hex,

openstackclient/tests/unit/network/v2/test_port.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def _get_common_cols_data(fake_port):
5454
'description',
5555
'device_id',
5656
'device_owner',
57+
'device_profile',
5758
'dns_assignment',
5859
'dns_domain',
5960
'dns_name',
@@ -86,6 +87,7 @@ def _get_common_cols_data(fake_port):
8687
fake_port.description,
8788
fake_port.device_id,
8889
fake_port.device_owner,
90+
fake_port.device_profile,
8991
format_columns.ListDictColumn(fake_port.dns_assignment),
9092
fake_port.dns_domain,
9193
fake_port.dns_name,
@@ -737,6 +739,33 @@ def test_create_with_numa_affinity_policy_legacy(self):
737739
def test_create_with_numa_affinity_policy_null(self):
738740
self._test_create_with_numa_affinity_policy()
739741

742+
def test_create_with_device_profile(self):
743+
arglist = [
744+
'--network', self._port.network_id,
745+
'--device-profile', 'cyborg_device_profile_1',
746+
'test-port',
747+
]
748+
749+
verifylist = [
750+
('network', self._port.network_id,),
751+
('device_profile', self._port.device_profile,),
752+
('name', 'test-port'),
753+
]
754+
755+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
756+
757+
columns, data = (self.cmd.take_action(parsed_args))
758+
759+
create_args = {
760+
'admin_state_up': True,
761+
'network_id': self._port.network_id,
762+
'name': 'test-port',
763+
'device_profile': 'cyborg_device_profile_1',
764+
}
765+
self.network.create_port.assert_called_once_with(**create_args)
766+
self.assertEqual(self.columns, columns)
767+
self.assertItemsEqual(self.data, data)
768+
740769

741770
class TestDeletePort(TestPort):
742771

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Add device profile to ``port create`` command.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
55

66
cliff>=3.5.0 # Apache-2.0
77
iso8601>=0.1.11 # MIT
8-
openstacksdk>=0.52.0 # Apache-2.0
8+
openstacksdk>=0.53.0 # Apache-2.0
99
osc-lib>=2.3.0 # Apache-2.0
1010
oslo.i18n>=3.15.3 # Apache-2.0
1111
python-keystoneclient>=3.22.0 # Apache-2.0

0 commit comments

Comments
 (0)