Add name option to 'port set'
Port's name can be updated in NeutronClient and it is a very good feature for a user to have the ability to rename a port. This was missing in the openstackclient, and the same has been added in this patch. Change-Id: I6e712ef08ab1c0a23786c4bb6972d3e0f8f0f999 Implements: blueprint neutron-client
This commit is contained in:
parent
b4c3adbd30
commit
66f94dca5c
@ -130,6 +130,7 @@ Set port properties
|
|||||||
[--binding-profile <binding-profile>]
|
[--binding-profile <binding-profile>]
|
||||||
[--host-id <host-id>]
|
[--host-id <host-id>]
|
||||||
[--enable | --disable]
|
[--enable | --disable]
|
||||||
|
[--name <name>]
|
||||||
<port>
|
<port>
|
||||||
|
|
||||||
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
|
.. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address>
|
||||||
@ -168,6 +169,10 @@ Set port properties
|
|||||||
|
|
||||||
Disable port
|
Disable port
|
||||||
|
|
||||||
|
.. option:: --name
|
||||||
|
|
||||||
|
Set port name
|
||||||
|
|
||||||
.. _port_set-port:
|
.. _port_set-port:
|
||||||
.. describe:: <port>
|
.. describe:: <port>
|
||||||
|
|
||||||
|
@ -97,10 +97,11 @@ def _get_attrs(client_manager, parsed_args):
|
|||||||
if parsed_args.host:
|
if parsed_args.host:
|
||||||
attrs['binding:host_id'] = parsed_args.host
|
attrs['binding:host_id'] = parsed_args.host
|
||||||
|
|
||||||
|
# It is possible that name is not updated during 'port set'
|
||||||
|
if parsed_args.name is not None:
|
||||||
|
attrs['name'] = str(parsed_args.name)
|
||||||
# The remaining options do not support 'port set' command, so they require
|
# The remaining options do not support 'port set' command, so they require
|
||||||
# additional check
|
# additional check
|
||||||
if 'name' in parsed_args and parsed_args.name is not None:
|
|
||||||
attrs['name'] = str(parsed_args.name)
|
|
||||||
if 'mac_address' in parsed_args and parsed_args.mac_address is not None:
|
if 'mac_address' in parsed_args and parsed_args.mac_address is not None:
|
||||||
attrs['mac_address'] = parsed_args.mac_address
|
attrs['mac_address'] = parsed_args.mac_address
|
||||||
if 'network' in parsed_args and parsed_args.network is not None:
|
if 'network' in parsed_args and parsed_args.network is not None:
|
||||||
@ -342,6 +343,10 @@ class SetPort(command.Command):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='Disable port',
|
help='Disable port',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--name',
|
||||||
|
metavar="<name>",
|
||||||
|
help=('Set port name'))
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'port',
|
'port',
|
||||||
metavar="<port>",
|
metavar="<port>",
|
||||||
|
@ -319,6 +319,7 @@ class TestSetPort(TestPort):
|
|||||||
'--vnic-type', 'macvtap',
|
'--vnic-type', 'macvtap',
|
||||||
'--binding-profile', 'foo=bar',
|
'--binding-profile', 'foo=bar',
|
||||||
'--host', 'binding-host-id-xxxx',
|
'--host', 'binding-host-id-xxxx',
|
||||||
|
'--name', 'newName',
|
||||||
self._port.name,
|
self._port.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -326,6 +327,7 @@ class TestSetPort(TestPort):
|
|||||||
('vnic_type', 'macvtap'),
|
('vnic_type', 'macvtap'),
|
||||||
('binding_profile', {'foo': 'bar'}),
|
('binding_profile', {'foo': 'bar'}),
|
||||||
('host', 'binding-host-id-xxxx'),
|
('host', 'binding-host-id-xxxx'),
|
||||||
|
('name', 'newName')
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -336,6 +338,7 @@ class TestSetPort(TestPort):
|
|||||||
'binding:vnic_type': 'macvtap',
|
'binding:vnic_type': 'macvtap',
|
||||||
'binding:profile': {'foo': 'bar'},
|
'binding:profile': {'foo': 'bar'},
|
||||||
'binding:host_id': 'binding-host-id-xxxx',
|
'binding:host_id': 'binding-host-id-xxxx',
|
||||||
|
'name': 'newName',
|
||||||
}
|
}
|
||||||
self.network.update_port.assert_called_once_with(self._port, **attrs)
|
self.network.update_port.assert_called_once_with(self._port, **attrs)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Port name can now be updated using ``port set``
|
Loading…
x
Reference in New Issue
Block a user