Add device ID and device owner to port unset
This adds support to unset the device_id and device_owner property on a port. Change-Id: I43b1ea63e3a119f57162948e128a85f8ba323d41
This commit is contained in:
		| @@ -1317,6 +1317,18 @@ class UnsetPort(common.NeutronUnsetCommandWithExtraArgs): | ||||
|             default=False, | ||||
|             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')) | ||||
|         parser.add_argument( | ||||
|             'port', | ||||
| @@ -1383,6 +1395,10 @@ class UnsetPort(common.NeutronUnsetCommandWithExtraArgs): | ||||
|             attrs['binding:host_id'] = None | ||||
|         if parsed_args.hints: | ||||
|             attrs['hints'] = None | ||||
|         if parsed_args.device: | ||||
|             attrs['device_id'] = '' | ||||
|         if parsed_args.device_owner: | ||||
|             attrs['device_owner'] = '' | ||||
|  | ||||
|         attrs.update( | ||||
|             self._parse_extra_properties(parsed_args.extra_properties) | ||||
|   | ||||
| @@ -3015,3 +3015,43 @@ class TestUnsetPort(TestPort): | ||||
|             **{'hints': None}, | ||||
|         ) | ||||
|         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
	 Tobias Urdin
					Tobias Urdin