Add option to clear information from ports
This patch adds the option of "no-fixed-ip" and "no-binding-profile" which is used to clear the fixed-ip and binding:profile information from the ports. Change-Id: I946301eaf6c647bae55e4f416aa0d98e5f06e699
This commit is contained in:
parent
0edab95fd1
commit
73d15e3768
doc/source/command-objects
openstackclient
releasenotes/notes
@ -123,11 +123,11 @@ Set port properties
|
|||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
os port set
|
os port set
|
||||||
[--fixed-ip subnet=<subnet>,ip-address=<ip-address>]
|
[--fixed-ip subnet=<subnet>,ip-address=<ip-address> | --no-fixed-ip]
|
||||||
[--device-id <device-id>]
|
[--device-id <device-id>]
|
||||||
[--device-owner <device-owner>]
|
[--device-owner <device-owner>]
|
||||||
[--vnic-type <vnic-type>]
|
[--vnic-type <vnic-type>]
|
||||||
[--binding-profile <binding-profile>]
|
[--binding-profile <binding-profile> | --no-binding-profile]
|
||||||
[--host-id <host-id>]
|
[--host-id <host-id>]
|
||||||
[--enable | --disable]
|
[--enable | --disable]
|
||||||
[--name <name>]
|
[--name <name>]
|
||||||
@ -139,6 +139,10 @@ Set port properties
|
|||||||
subnet=<subnet>,ip-address=<ip-address>
|
subnet=<subnet>,ip-address=<ip-address>
|
||||||
(you can repeat this option)
|
(you can repeat this option)
|
||||||
|
|
||||||
|
.. option:: --no-fixed-ip
|
||||||
|
|
||||||
|
Clear existing information of fixed-ips
|
||||||
|
|
||||||
.. option:: --device-id <device-id>
|
.. option:: --device-id <device-id>
|
||||||
|
|
||||||
Device ID of this port
|
Device ID of this port
|
||||||
@ -157,6 +161,10 @@ Set port properties
|
|||||||
Custom data to be passed as binding:profile: <key>=<value>
|
Custom data to be passed as binding:profile: <key>=<value>
|
||||||
(this option can be repeated)
|
(this option can be repeated)
|
||||||
|
|
||||||
|
.. option:: --no-binding-profile
|
||||||
|
|
||||||
|
Clear existing information of binding:profile
|
||||||
|
|
||||||
.. option:: --host-id <host-id>
|
.. option:: --host-id <host-id>
|
||||||
|
|
||||||
The ID of the host where the port is allocated
|
The ID of the host where the port is allocated
|
||||||
|
@ -151,14 +151,6 @@ def _prepare_fixed_ips(client_manager, parsed_args):
|
|||||||
|
|
||||||
|
|
||||||
def _add_updatable_args(parser):
|
def _add_updatable_args(parser):
|
||||||
parser.add_argument(
|
|
||||||
'--fixed-ip',
|
|
||||||
metavar='subnet=<subnet>,ip-address=<ip-address>',
|
|
||||||
action=parseractions.MultiKeyValueAction,
|
|
||||||
optional_keys=['subnet', 'ip-address'],
|
|
||||||
help='Desired IP and/or subnet (name or ID) for this port: '
|
|
||||||
'subnet=<subnet>,ip-address=<ip-address> '
|
|
||||||
'(this option can be repeated)')
|
|
||||||
# NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
|
# NOTE(dtroyer): --device-id is deprecated in Mar 2016. Do not
|
||||||
# remove before 3.x release or Mar 2017.
|
# remove before 3.x release or Mar 2017.
|
||||||
device_group = parser.add_mutually_exclusive_group()
|
device_group = parser.add_mutually_exclusive_group()
|
||||||
@ -184,12 +176,6 @@ def _add_updatable_args(parser):
|
|||||||
help="VNIC type for this port (direct | direct-physical |"
|
help="VNIC type for this port (direct | direct-physical |"
|
||||||
" macvtap | normal | baremetal). If unspecified during"
|
" macvtap | normal | baremetal). If unspecified during"
|
||||||
" port creation, default value will be 'normal'.")
|
" port creation, default value will be 'normal'.")
|
||||||
parser.add_argument(
|
|
||||||
'--binding-profile',
|
|
||||||
metavar='<binding-profile>',
|
|
||||||
action=parseractions.KeyValueAction,
|
|
||||||
help='Custom data to be passed as binding:profile: <key>=<value> '
|
|
||||||
'(this option can be repeated)')
|
|
||||||
# NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
|
# NOTE(dtroyer): --host-id is deprecated in Mar 2016. Do not
|
||||||
# remove before 3.x release or Mar 2017.
|
# remove before 3.x release or Mar 2017.
|
||||||
host_group = parser.add_mutually_exclusive_group()
|
host_group = parser.add_mutually_exclusive_group()
|
||||||
@ -217,6 +203,20 @@ class CreatePort(command.ShowOne):
|
|||||||
required=True,
|
required=True,
|
||||||
help='Network this port belongs to (name or ID)')
|
help='Network this port belongs to (name or ID)')
|
||||||
_add_updatable_args(parser)
|
_add_updatable_args(parser)
|
||||||
|
parser.add_argument(
|
||||||
|
'--fixed-ip',
|
||||||
|
metavar='subnet=<subnet>,ip-address=<ip-address>',
|
||||||
|
action=parseractions.MultiKeyValueAction,
|
||||||
|
optional_keys=['subnet', 'ip-address'],
|
||||||
|
help='Desired IP and/or subnet (name or ID) for this port: '
|
||||||
|
'subnet=<subnet>,ip-address=<ip-address> '
|
||||||
|
'(this option can be repeated)')
|
||||||
|
parser.add_argument(
|
||||||
|
'--binding-profile',
|
||||||
|
metavar='<binding-profile>',
|
||||||
|
action=parseractions.KeyValueAction,
|
||||||
|
help='Custom data to be passed as binding:profile: <key>=<value> '
|
||||||
|
'(this option can be repeated)')
|
||||||
admin_group = parser.add_mutually_exclusive_group()
|
admin_group = parser.add_mutually_exclusive_group()
|
||||||
admin_group.add_argument(
|
admin_group.add_argument(
|
||||||
'--enable',
|
'--enable',
|
||||||
@ -352,7 +352,30 @@ class SetPort(command.Command):
|
|||||||
metavar="<port>",
|
metavar="<port>",
|
||||||
help=("Port to modify (name or ID)")
|
help=("Port to modify (name or ID)")
|
||||||
)
|
)
|
||||||
|
fixed_ip = parser.add_mutually_exclusive_group()
|
||||||
|
fixed_ip.add_argument(
|
||||||
|
'--fixed-ip',
|
||||||
|
metavar='subnet=<subnet>,ip-address=<ip-address>',
|
||||||
|
action=parseractions.MultiKeyValueAction,
|
||||||
|
optional_keys=['subnet', 'ip-address'],
|
||||||
|
help='Desired IP and/or subnet (name or ID) for this port: '
|
||||||
|
'subnet=<subnet>,ip-address=<ip-address> '
|
||||||
|
'(this option can be repeated)')
|
||||||
|
fixed_ip.add_argument(
|
||||||
|
'--no-fixed-ip',
|
||||||
|
action='store_true',
|
||||||
|
help='Clear existing information of fixed-ips')
|
||||||
|
binding_profile = parser.add_mutually_exclusive_group()
|
||||||
|
binding_profile.add_argument(
|
||||||
|
'--binding-profile',
|
||||||
|
metavar='<binding-profile>',
|
||||||
|
action=parseractions.KeyValueAction,
|
||||||
|
help='Custom data to be passed as binding:profile: <key>=<value> '
|
||||||
|
'(this option can be repeated)')
|
||||||
|
binding_profile.add_argument(
|
||||||
|
'--no-binding-profile',
|
||||||
|
action='store_true',
|
||||||
|
help='Clear existing information of binding:profile')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -361,6 +384,11 @@ class SetPort(command.Command):
|
|||||||
_prepare_fixed_ips(self.app.client_manager, parsed_args)
|
_prepare_fixed_ips(self.app.client_manager, parsed_args)
|
||||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||||
|
|
||||||
|
if parsed_args.no_fixed_ip:
|
||||||
|
attrs['fixed_ips'] = []
|
||||||
|
if parsed_args.no_binding_profile:
|
||||||
|
attrs['binding:profile'] = {}
|
||||||
|
|
||||||
if attrs == {}:
|
if attrs == {}:
|
||||||
msg = "Nothing specified to be set"
|
msg = "Nothing specified to be set"
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
@ -298,10 +298,14 @@ class TestSetPort(TestPort):
|
|||||||
def test_set_this(self):
|
def test_set_this(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--disable',
|
'--disable',
|
||||||
|
'--no-fixed-ip',
|
||||||
|
'--no-binding-profile',
|
||||||
self._port.name,
|
self._port.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('disable', True),
|
('disable', True),
|
||||||
|
('no_binding_profile', True),
|
||||||
|
('no_fixed_ip', True),
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -309,6 +313,8 @@ class TestSetPort(TestPort):
|
|||||||
|
|
||||||
attrs = {
|
attrs = {
|
||||||
'admin_state_up': False,
|
'admin_state_up': False,
|
||||||
|
'binding:profile': {},
|
||||||
|
'fixed_ips': [],
|
||||||
}
|
}
|
||||||
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,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Fixed-IP information and binding profile information
|
||||||
|
in ports can now be cleared using ``--no-fixed-ip``
|
||||||
|
and ``--no-binding-profile`` with ``port set``
|
Loading…
x
Reference in New Issue
Block a user