Merge "Add 'data_plane_status' option to Port classes"
This commit is contained in:
		| @@ -232,6 +232,7 @@ Set port properties | |||||||
|         [--dns-name <dns-name>] |         [--dns-name <dns-name>] | ||||||
|         [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]] |         [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>]] | ||||||
|         [--no-allowed-address] |         [--no-allowed-address] | ||||||
|  |         [--data-plane-status <status>] | ||||||
|         <port> |         <port> | ||||||
|  |  | ||||||
| .. option:: --description <description> | .. option:: --description <description> | ||||||
| @@ -335,6 +336,12 @@ Set port properties | |||||||
|     (Specify both --allowed-address and --no-allowed-address |     (Specify both --allowed-address and --no-allowed-address | ||||||
|     to overwrite the current allowed-address pairs) |     to overwrite the current allowed-address pairs) | ||||||
|  |  | ||||||
|  | .. option:: --data-plane-status | ||||||
|  |  | ||||||
|  |     Set data plane status of this port (ACTIVE | DOWN). | ||||||
|  |     Unset it to None with the 'port unset' command | ||||||
|  |     (requires data plane status extension) | ||||||
|  |  | ||||||
| .. _port_set-port: | .. _port_set-port: | ||||||
| .. describe:: <port> | .. describe:: <port> | ||||||
|  |  | ||||||
| @@ -370,6 +377,7 @@ Unset port properties | |||||||
|         [--security-group <security-group> [...]] |         [--security-group <security-group> [...]] | ||||||
|         [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>] [...]] |         [--allowed-address ip-address=<ip-address>[,mac-address=<mac-address>] [...]] | ||||||
|         [--qos-policy] |         [--qos-policy] | ||||||
|  |         [--data-plane-status] | ||||||
|         <port> |         <port> | ||||||
|  |  | ||||||
| .. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address> | .. option:: --fixed-ip subnet=<subnet>,ip-address=<ip-address> | ||||||
| @@ -398,6 +406,10 @@ Unset port properties | |||||||
|  |  | ||||||
|     Remove the QoS policy attached to the port |     Remove the QoS policy attached to the port | ||||||
|  |  | ||||||
|  | .. option:: --data-plane-status | ||||||
|  |  | ||||||
|  |     Clear existing information of data plane status | ||||||
|  |  | ||||||
| .. _port_unset-port: | .. _port_unset-port: | ||||||
| .. describe:: <port> | .. describe:: <port> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -685,6 +685,15 @@ class SetPort(command.Command): | |||||||
|                    "(Specify both --allowed-address and --no-allowed-address" |                    "(Specify both --allowed-address and --no-allowed-address" | ||||||
|                    "to overwrite the current allowed-address pairs)") |                    "to overwrite the current allowed-address pairs)") | ||||||
|         ) |         ) | ||||||
|  |         parser.add_argument( | ||||||
|  |             '--data-plane-status', | ||||||
|  |             metavar='<status>', | ||||||
|  |             choices=['ACTIVE', 'DOWN'], | ||||||
|  |             help=_("Set data plane status of this port (ACTIVE | DOWN). " | ||||||
|  |                    "Unset it to None with the 'port unset' command " | ||||||
|  |                    "(requires data plane status extension)") | ||||||
|  |         ) | ||||||
|  |  | ||||||
|         return parser |         return parser | ||||||
|  |  | ||||||
|     def take_action(self, parsed_args): |     def take_action(self, parsed_args): | ||||||
| @@ -737,6 +746,8 @@ class SetPort(command.Command): | |||||||
|             attrs['allowed_address_pairs'].extend( |             attrs['allowed_address_pairs'].extend( | ||||||
|                 _convert_address_pairs(parsed_args) |                 _convert_address_pairs(parsed_args) | ||||||
|             ) |             ) | ||||||
|  |         if parsed_args.data_plane_status: | ||||||
|  |             attrs['data_plane_status'] = parsed_args.data_plane_status | ||||||
|  |  | ||||||
|         client.update_port(obj, **attrs) |         client.update_port(obj, **attrs) | ||||||
|  |  | ||||||
| @@ -816,6 +827,11 @@ class UnsetPort(command.Command): | |||||||
|             default=False, |             default=False, | ||||||
|             help=_("Remove the QoS policy attached to the port") |             help=_("Remove the QoS policy attached to the port") | ||||||
|         ) |         ) | ||||||
|  |         parser.add_argument( | ||||||
|  |             '--data-plane-status', | ||||||
|  |             action='store_true', | ||||||
|  |             help=_("Clear existing information of data plane status") | ||||||
|  |         ) | ||||||
|  |  | ||||||
|         return parser |         return parser | ||||||
|  |  | ||||||
| @@ -867,6 +883,8 @@ class UnsetPort(command.Command): | |||||||
|             attrs['allowed_address_pairs'] = tmp_addr_pairs |             attrs['allowed_address_pairs'] = tmp_addr_pairs | ||||||
|         if parsed_args.qos_policy: |         if parsed_args.qos_policy: | ||||||
|             attrs['qos_policy_id'] = None |             attrs['qos_policy_id'] = None | ||||||
|  |         if parsed_args.data_plane_status: | ||||||
|  |             attrs['data_plane_status'] = None | ||||||
|  |  | ||||||
|         if attrs: |         if attrs: | ||||||
|             client.update_port(obj, **attrs) |             client.update_port(obj, **attrs) | ||||||
|   | |||||||
| @@ -558,6 +558,7 @@ class FakePort(object): | |||||||
|             'binding:vif_details': {}, |             'binding:vif_details': {}, | ||||||
|             'binding:vif_type': 'ovs', |             'binding:vif_type': 'ovs', | ||||||
|             'binding:vnic_type': 'normal', |             'binding:vnic_type': 'normal', | ||||||
|  |             'data_plane_status': None, | ||||||
|             'description': 'description-' + uuid.uuid4().hex, |             'description': 'description-' + uuid.uuid4().hex, | ||||||
|             'device_id': 'device-id-' + uuid.uuid4().hex, |             'device_id': 'device-id-' + uuid.uuid4().hex, | ||||||
|             'device_owner': 'compute:nova', |             'device_owner': 'compute:nova', | ||||||
|   | |||||||
| @@ -44,6 +44,7 @@ class TestPort(network_fakes.TestNetworkV2): | |||||||
|             'binding_vif_details', |             'binding_vif_details', | ||||||
|             'binding_vif_type', |             'binding_vif_type', | ||||||
|             'binding_vnic_type', |             'binding_vnic_type', | ||||||
|  |             'data_plane_status', | ||||||
|             'description', |             'description', | ||||||
|             'device_id', |             'device_id', | ||||||
|             'device_owner', |             'device_owner', | ||||||
| @@ -70,6 +71,7 @@ class TestPort(network_fakes.TestNetworkV2): | |||||||
|             utils.format_dict(fake_port.binding_vif_details), |             utils.format_dict(fake_port.binding_vif_details), | ||||||
|             fake_port.binding_vif_type, |             fake_port.binding_vif_type, | ||||||
|             fake_port.binding_vnic_type, |             fake_port.binding_vnic_type, | ||||||
|  |             fake_port.data_plane_status, | ||||||
|             fake_port.description, |             fake_port.description, | ||||||
|             fake_port.device_id, |             fake_port.device_id, | ||||||
|             fake_port.device_owner, |             fake_port.device_owner, | ||||||
| @@ -1371,6 +1373,40 @@ class TestSetPort(TestPort): | |||||||
|         self.network.update_port.assert_called_once_with(_testport, **attrs) |         self.network.update_port.assert_called_once_with(_testport, **attrs) | ||||||
|         self.assertIsNone(result) |         self.assertIsNone(result) | ||||||
|  |  | ||||||
|  |     def test_set_port_data_plane_status(self): | ||||||
|  |         _testport = network_fakes.FakePort.create_one_port( | ||||||
|  |             {'data_plane_status': None}) | ||||||
|  |         self.network.find_port = mock.Mock(return_value=_testport) | ||||||
|  |         arglist = [ | ||||||
|  |             '--data-plane-status', 'ACTIVE', | ||||||
|  |             _testport.name, | ||||||
|  |         ] | ||||||
|  |         verifylist = [ | ||||||
|  |             ('data_plane_status', 'ACTIVE'), | ||||||
|  |             ('port', _testport.name), | ||||||
|  |         ] | ||||||
|  |  | ||||||
|  |         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||||
|  |         result = self.cmd.take_action(parsed_args) | ||||||
|  |  | ||||||
|  |         attrs = { | ||||||
|  |             'data_plane_status': 'ACTIVE', | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         self.network.update_port.assert_called_once_with(_testport, **attrs) | ||||||
|  |         self.assertIsNone(result) | ||||||
|  |  | ||||||
|  |     def test_set_port_invalid_data_plane_status_value(self): | ||||||
|  |         arglist = [ | ||||||
|  |             '--data-plane-status', 'Spider-Man', | ||||||
|  |             'test-port', | ||||||
|  |         ] | ||||||
|  |         self.assertRaises(tests_utils.ParserException, | ||||||
|  |                           self.check_parser, | ||||||
|  |                           self.cmd, | ||||||
|  |                           arglist, | ||||||
|  |                           None) | ||||||
|  |  | ||||||
|  |  | ||||||
| class TestShowPort(TestPort): | class TestShowPort(TestPort): | ||||||
|  |  | ||||||
| @@ -1573,3 +1609,26 @@ class TestUnsetPort(TestPort): | |||||||
|         self.assertRaises(exceptions.CommandError, |         self.assertRaises(exceptions.CommandError, | ||||||
|                           self.cmd.take_action, |                           self.cmd.take_action, | ||||||
|                           parsed_args) |                           parsed_args) | ||||||
|  |  | ||||||
|  |     def test_unset_port_data_plane_status(self): | ||||||
|  |         _fake_port = network_fakes.FakePort.create_one_port( | ||||||
|  |             {'data_plane_status': 'ACTIVE'}) | ||||||
|  |         self.network.find_port = mock.Mock(return_value=_fake_port) | ||||||
|  |         arglist = [ | ||||||
|  |             '--data-plane-status', | ||||||
|  |             _fake_port.name, | ||||||
|  |         ] | ||||||
|  |         verifylist = [ | ||||||
|  |             ('data_plane_status', True), | ||||||
|  |             ('port', _fake_port.name), | ||||||
|  |         ] | ||||||
|  |  | ||||||
|  |         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||||
|  |         result = self.cmd.take_action(parsed_args) | ||||||
|  |  | ||||||
|  |         attrs = { | ||||||
|  |             'data_plane_status': None, | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         self.network.update_port.assert_called_once_with(_fake_port, **attrs) | ||||||
|  |         self.assertIsNone(result) | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								releasenotes/notes/bug-1684989-3bda158a822d2f73.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								releasenotes/notes/bug-1684989-3bda158a822d2f73.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | --- | ||||||
|  | features: | ||||||
|  |   - Add ``--data-plane-status`` option to ``port set`` and ``port unset`` | ||||||
|  |     commands. | ||||||
|  |     [Bug `1684989 <https://bugs.launchpad.net/bugs/1684989>`_] | ||||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins