Merge "Add device ID and device owner to port unset"
This commit is contained in:
@@ -1316,6 +1316,18 @@ class UnsetPort(common.NeutronUnsetCommandWithExtraArgs):
|
|||||||
default=False,
|
default=False,
|
||||||
help=_("Clear hints for the port"),
|
help=_("Clear hints for the port"),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--device',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help=_("Clear device ID for the port."),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--device-owner',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help=_("Clear device owner for the port."),
|
||||||
|
)
|
||||||
_tag.add_tag_option_to_parser_for_unset(parser, _('port'))
|
_tag.add_tag_option_to_parser_for_unset(parser, _('port'))
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'port',
|
'port',
|
||||||
@@ -1382,6 +1394,10 @@ class UnsetPort(common.NeutronUnsetCommandWithExtraArgs):
|
|||||||
attrs['binding:host_id'] = None
|
attrs['binding:host_id'] = None
|
||||||
if parsed_args.hints:
|
if parsed_args.hints:
|
||||||
attrs['hints'] = None
|
attrs['hints'] = None
|
||||||
|
if parsed_args.device:
|
||||||
|
attrs['device_id'] = ''
|
||||||
|
if parsed_args.device_owner:
|
||||||
|
attrs['device_owner'] = ''
|
||||||
|
|
||||||
attrs.update(
|
attrs.update(
|
||||||
self._parse_extra_properties(parsed_args.extra_properties)
|
self._parse_extra_properties(parsed_args.extra_properties)
|
||||||
|
@@ -3014,3 +3014,43 @@ class TestUnsetPort(TestPort):
|
|||||||
**{'hints': None},
|
**{'hints': None},
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_unset_device(self):
|
||||||
|
testport = network_fakes.create_one_port()
|
||||||
|
self.network_client.find_port = mock.Mock(return_value=testport)
|
||||||
|
arglist = [
|
||||||
|
'--device',
|
||||||
|
testport.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('device', True),
|
||||||
|
('port', testport.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.network_client.update_port.assert_called_once_with(
|
||||||
|
testport,
|
||||||
|
**{'device_id': ''},
|
||||||
|
)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_unset_device_owner(self):
|
||||||
|
testport = network_fakes.create_one_port()
|
||||||
|
self.network_client.find_port = mock.Mock(return_value=testport)
|
||||||
|
arglist = [
|
||||||
|
'--device-owner',
|
||||||
|
testport.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('device_owner', True),
|
||||||
|
('port', testport.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.network_client.update_port.assert_called_once_with(
|
||||||
|
testport,
|
||||||
|
**{'device_owner': ''},
|
||||||
|
)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Added ``--device`` and ``--device-owner`` parameter to the
|
||||||
|
``port unset`` command.
|
Reference in New Issue
Block a user