Skip to content

Commit b1b5a2a

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add name option to 'port set'"
2 parents c3f6ee9 + 66f94dc commit b1b5a2a

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

doc/source/command-objects/port.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Set port properties
130130
[--binding-profile <binding-profile>]
131131
[--host-id <host-id>]
132132
[--enable | --disable]
133+
[--name <name>]
133134
<port>
134135
135136
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
@@ -168,6 +169,10 @@ Set port properties
168169
169170
Disable port
170171
172+
.. option:: --name
173+
174+
Set port name
175+
171176
.. _port_set-port:
172177
.. describe:: <port>
173178

openstackclient/network/v2/port.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ def _get_attrs(client_manager, parsed_args):
9797
if parsed_args.host:
9898
attrs['binding:host_id'] = parsed_args.host
9999

100+
# It is possible that name is not updated during 'port set'
101+
if parsed_args.name is not None:
102+
attrs['name'] = str(parsed_args.name)
100103
# The remaining options do not support 'port set' command, so they require
101104
# additional check
102-
if 'name' in parsed_args and parsed_args.name is not None:
103-
attrs['name'] = str(parsed_args.name)
104105
if 'mac_address' in parsed_args and parsed_args.mac_address is not None:
105106
attrs['mac_address'] = parsed_args.mac_address
106107
if 'network' in parsed_args and parsed_args.network is not None:
@@ -342,6 +343,10 @@ def get_parser(self, prog_name):
342343
action='store_true',
343344
help='Disable port',
344345
)
346+
parser.add_argument(
347+
'--name',
348+
metavar="<name>",
349+
help=('Set port name'))
345350
parser.add_argument(
346351
'port',
347352
metavar="<port>",

openstackclient/tests/network/v2/test_port.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,15 @@ def test_set_that(self):
319319
'--vnic-type', 'macvtap',
320320
'--binding-profile', 'foo=bar',
321321
'--host', 'binding-host-id-xxxx',
322+
'--name', 'newName',
322323
self._port.name,
323324
]
324325
verifylist = [
325326
('enable', True),
326327
('vnic_type', 'macvtap'),
327328
('binding_profile', {'foo': 'bar'}),
328329
('host', 'binding-host-id-xxxx'),
330+
('name', 'newName')
329331
]
330332

331333
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -336,6 +338,7 @@ def test_set_that(self):
336338
'binding:vnic_type': 'macvtap',
337339
'binding:profile': {'foo': 'bar'},
338340
'binding:host_id': 'binding-host-id-xxxx',
341+
'name': 'newName',
339342
}
340343
self.network.update_port.assert_called_once_with(self._port, **attrs)
341344
self.assertIsNone(result)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Port name can now be updated using ``port set``

0 commit comments

Comments
 (0)