python-openstackclient 6.3.0__py3-none-any.whl → 6.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. openstackclient/common/availability_zone.py +4 -4
  2. openstackclient/common/pagination.py +82 -0
  3. openstackclient/compute/v2/flavor.py +2 -16
  4. openstackclient/compute/v2/hypervisor.py +2 -21
  5. openstackclient/compute/v2/keypair.py +2 -9
  6. openstackclient/compute/v2/server.py +220 -131
  7. openstackclient/compute/v2/server_event.py +30 -19
  8. openstackclient/compute/v2/server_group.py +2 -23
  9. openstackclient/compute/v2/server_migration.py +2 -22
  10. openstackclient/compute/v2/usage.py +4 -6
  11. openstackclient/identity/v3/mapping.py +25 -3
  12. openstackclient/identity/v3/policy.py +3 -1
  13. openstackclient/image/v2/cache.py +218 -0
  14. openstackclient/image/v2/image.py +40 -17
  15. openstackclient/image/v2/metadef_namespaces.py +25 -21
  16. openstackclient/image/v2/metadef_objects.py +189 -0
  17. openstackclient/image/v2/metadef_properties.py +284 -0
  18. openstackclient/network/utils.py +100 -0
  19. openstackclient/network/v2/default_security_group_rule.py +418 -0
  20. openstackclient/network/v2/local_ip_association.py +1 -1
  21. openstackclient/network/v2/ndp_proxy.py +7 -3
  22. openstackclient/network/v2/network.py +2 -2
  23. openstackclient/network/v2/port.py +65 -19
  24. openstackclient/network/v2/security_group_rule.py +18 -111
  25. openstackclient/network/v2/subnet.py +1 -0
  26. openstackclient/object/v1/container.py +2 -12
  27. openstackclient/object/v1/object.py +2 -11
  28. openstackclient/tests/functional/base.py +13 -6
  29. openstackclient/tests/functional/identity/v3/test_role.py +11 -3
  30. openstackclient/tests/functional/network/v2/common.py +7 -1
  31. openstackclient/tests/functional/network/v2/test_address_group.py +2 -4
  32. openstackclient/tests/functional/network/v2/test_address_scope.py +0 -6
  33. openstackclient/tests/functional/network/v2/test_default_security_group_rule.py +67 -0
  34. openstackclient/tests/functional/network/v2/test_floating_ip.py +3 -6
  35. openstackclient/tests/functional/network/v2/test_ip_availability.py +3 -8
  36. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +3 -4
  37. openstackclient/tests/functional/network/v2/test_local_ip.py +2 -4
  38. openstackclient/tests/functional/network/v2/test_network.py +18 -17
  39. openstackclient/tests/functional/network/v2/test_network_agent.py +24 -21
  40. openstackclient/tests/functional/network/v2/test_network_flavor.py +0 -6
  41. openstackclient/tests/functional/network/v2/test_network_flavor_profile.py +0 -6
  42. openstackclient/tests/functional/network/v2/test_network_meter.py +6 -6
  43. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +7 -8
  44. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +1 -3
  45. openstackclient/tests/functional/network/v2/test_network_qos_policy.py +4 -4
  46. openstackclient/tests/functional/network/v2/test_network_qos_rule.py +16 -20
  47. openstackclient/tests/functional/network/v2/test_network_qos_rule_type.py +4 -4
  48. openstackclient/tests/functional/network/v2/test_network_rbac.py +1 -4
  49. openstackclient/tests/functional/network/v2/test_network_segment.py +7 -12
  50. openstackclient/tests/functional/network/v2/test_network_segment_range.py +3 -4
  51. openstackclient/tests/functional/network/v2/test_network_service_provider.py +2 -4
  52. openstackclient/tests/functional/network/v2/test_network_trunk.py +3 -3
  53. openstackclient/tests/functional/network/v2/test_port.py +2 -8
  54. openstackclient/tests/functional/network/v2/test_router.py +0 -6
  55. openstackclient/tests/functional/network/v2/test_security_group.py +1 -4
  56. openstackclient/tests/functional/network/v2/test_security_group_rule.py +1 -4
  57. openstackclient/tests/functional/network/v2/test_subnet.py +4 -22
  58. openstackclient/tests/functional/network/v2/test_subnet_pool.py +0 -6
  59. openstackclient/tests/unit/common/test_availability_zone.py +28 -30
  60. openstackclient/tests/unit/common/test_extension.py +1 -4
  61. openstackclient/tests/unit/common/test_limits.py +2 -4
  62. openstackclient/tests/unit/common/test_project_cleanup.py +3 -10
  63. openstackclient/tests/unit/common/test_quota.py +18 -24
  64. openstackclient/tests/unit/compute/v2/fakes.py +24 -11
  65. openstackclient/tests/unit/compute/v2/test_agent.py +1 -1
  66. openstackclient/tests/unit/compute/v2/test_aggregate.py +62 -72
  67. openstackclient/tests/unit/compute/v2/test_console.py +18 -30
  68. openstackclient/tests/unit/compute/v2/test_flavor.py +85 -89
  69. openstackclient/tests/unit/compute/v2/test_host.py +12 -19
  70. openstackclient/tests/unit/compute/v2/test_hypervisor.py +23 -25
  71. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -6
  72. openstackclient/tests/unit/compute/v2/test_keypair.py +25 -39
  73. openstackclient/tests/unit/compute/v2/test_server.py +316 -365
  74. openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -17
  75. openstackclient/tests/unit/compute/v2/test_server_event.py +23 -25
  76. openstackclient/tests/unit/compute/v2/test_server_group.py +41 -33
  77. openstackclient/tests/unit/compute/v2/test_server_image.py +6 -18
  78. openstackclient/tests/unit/compute/v2/test_server_migration.py +45 -45
  79. openstackclient/tests/unit/compute/v2/test_server_volume.py +15 -31
  80. openstackclient/tests/unit/compute/v2/test_service.py +51 -56
  81. openstackclient/tests/unit/compute/v2/test_usage.py +10 -13
  82. openstackclient/tests/unit/fakes.py +4 -0
  83. openstackclient/tests/unit/identity/v3/test_mappings.py +9 -4
  84. openstackclient/tests/unit/identity/v3/test_trust.py +0 -2
  85. openstackclient/tests/unit/image/v1/fakes.py +2 -1
  86. openstackclient/tests/unit/image/v1/test_image.py +1 -1
  87. openstackclient/tests/unit/image/v2/fakes.py +82 -0
  88. openstackclient/tests/unit/image/v2/test_cache.py +214 -0
  89. openstackclient/tests/unit/image/v2/test_image.py +62 -4
  90. openstackclient/tests/unit/image/v2/test_metadef_namespaces.py +5 -19
  91. openstackclient/tests/unit/image/v2/test_metadef_objects.py +162 -0
  92. openstackclient/tests/unit/image/v2/test_metadef_properties.py +227 -0
  93. openstackclient/tests/unit/integ/cli/test_shell.py +0 -2
  94. openstackclient/tests/unit/network/test_common.py +3 -3
  95. openstackclient/tests/unit/network/v2/fakes.py +1 -0
  96. openstackclient/tests/unit/network/v2/test_default_security_group_rule.py +1133 -0
  97. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +5 -13
  98. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -9
  99. openstackclient/tests/unit/network/v2/test_network.py +33 -0
  100. openstackclient/tests/unit/network/v2/test_network_compute.py +5 -11
  101. openstackclient/tests/unit/network/v2/test_network_trunk.py +6 -8
  102. openstackclient/tests/unit/network/v2/test_port.py +83 -38
  103. openstackclient/tests/unit/network/v2/test_security_group_compute.py +7 -15
  104. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +19 -27
  105. openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +3 -6
  106. openstackclient/tests/unit/network/v2/test_subnet.py +92 -0
  107. openstackclient/tests/unit/network/v2/test_subnet_pool.py +11 -13
  108. openstackclient/tests/unit/test_shell.py +1 -7
  109. openstackclient/tests/unit/utils.py +10 -4
  110. openstackclient/tests/unit/volume/v1/fakes.py +7 -1
  111. openstackclient/tests/unit/volume/v1/test_qos_specs.py +2 -2
  112. openstackclient/tests/unit/volume/v1/test_service.py +1 -1
  113. openstackclient/tests/unit/volume/v1/test_transfer_request.py +2 -2
  114. openstackclient/tests/unit/volume/v1/test_type.py +2 -4
  115. openstackclient/tests/unit/volume/v1/test_volume.py +5 -7
  116. openstackclient/tests/unit/volume/v1/test_volume_backup.py +4 -4
  117. openstackclient/tests/unit/volume/v2/fakes.py +32 -12
  118. openstackclient/tests/unit/volume/v2/test_backup_record.py +1 -1
  119. openstackclient/tests/unit/volume/v2/test_consistency_group.py +4 -6
  120. openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py +2 -4
  121. openstackclient/tests/unit/volume/v2/test_qos_specs.py +2 -2
  122. openstackclient/tests/unit/volume/v2/test_service.py +1 -1
  123. openstackclient/tests/unit/volume/v2/test_volume.py +78 -16
  124. openstackclient/tests/unit/volume/v2/test_volume_backend.py +10 -22
  125. openstackclient/tests/unit/volume/v2/test_volume_backup.py +76 -89
  126. openstackclient/tests/unit/volume/v2/test_volume_host.py +1 -1
  127. openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +5 -7
  128. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +4 -8
  129. openstackclient/tests/unit/volume/v2/test_volume_type.py +164 -24
  130. openstackclient/tests/unit/volume/v3/fakes.py +91 -15
  131. openstackclient/tests/unit/volume/v3/test_block_storage_cleanup.py +3 -7
  132. openstackclient/tests/unit/volume/v3/test_block_storage_cluster.py +11 -31
  133. openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +6 -16
  134. openstackclient/tests/unit/volume/v3/test_block_storage_manage.py +219 -157
  135. openstackclient/tests/unit/volume/v3/test_block_storage_resource_filter.py +32 -23
  136. openstackclient/tests/unit/volume/v3/test_volume.py +50 -48
  137. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +17 -47
  138. openstackclient/tests/unit/volume/v3/test_volume_group.py +23 -65
  139. openstackclient/tests/unit/volume/v3/test_volume_group_snapshot.py +88 -77
  140. openstackclient/tests/unit/volume/v3/test_volume_group_type.py +14 -42
  141. openstackclient/tests/unit/volume/v3/test_volume_message.py +10 -28
  142. openstackclient/volume/v1/volume.py +2 -14
  143. openstackclient/volume/v2/volume.py +30 -15
  144. openstackclient/volume/v2/volume_backend.py +10 -18
  145. openstackclient/volume/v2/volume_backup.py +18 -15
  146. openstackclient/volume/v2/volume_snapshot.py +2 -12
  147. openstackclient/volume/v2/volume_type.py +211 -14
  148. openstackclient/volume/v3/block_storage_manage.py +72 -11
  149. openstackclient/volume/v3/block_storage_resource_filter.py +33 -11
  150. openstackclient/volume/v3/volume_attachment.py +2 -14
  151. openstackclient/volume/v3/volume_group_snapshot.py +27 -27
  152. openstackclient/volume/v3/volume_message.py +2 -13
  153. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/AUTHORS +11 -0
  154. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/METADATA +6 -5
  155. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/RECORD +160 -151
  156. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/entry_points.txt +23 -5
  157. python_openstackclient-6.5.0.dist-info/pbr.json +1 -0
  158. openstackclient/tests/unit/common/test_parseractions.py +0 -233
  159. python_openstackclient-6.3.0.dist-info/pbr.json +0 -1
  160. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/LICENSE +0 -0
  161. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/WHEEL +0 -0
  162. {python_openstackclient-6.3.0.dist-info → python_openstackclient-6.5.0.dist-info}/top_level.txt +0 -0
@@ -24,16 +24,8 @@ from openstackclient.tests.unit import utils as tests_utils
24
24
  # Tests for Nova network
25
25
 
26
26
 
27
- class TestFloatingIPCompute(compute_fakes.TestComputev2):
28
- def setUp(self):
29
- super(TestFloatingIPCompute, self).setUp()
30
-
31
- # Get a shortcut to the compute client
32
- self.compute = self.app.client_manager.compute
33
-
34
-
35
27
  @mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_create')
36
- class TestCreateFloatingIPCompute(TestFloatingIPCompute):
28
+ class TestCreateFloatingIPCompute(compute_fakes.TestComputev2):
37
29
  # The floating ip to be deleted.
38
30
  _floating_ip = compute_fakes.create_one_floating_ip()
39
31
 
@@ -58,7 +50,7 @@ class TestCreateFloatingIPCompute(TestFloatingIPCompute):
58
50
 
59
51
  self.app.client_manager.network_endpoint_enabled = False
60
52
 
61
- # self.compute.floating_ips.create.return_value = self.floating_ip
53
+ # self.compute_client.floating_ips.create.return_value = self.floating_ip
62
54
 
63
55
  # Get the command object to test
64
56
  self.cmd = fip.CreateFloatingIP(self.app, None)
@@ -93,7 +85,7 @@ class TestCreateFloatingIPCompute(TestFloatingIPCompute):
93
85
 
94
86
 
95
87
  @mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_delete')
96
- class TestDeleteFloatingIPCompute(TestFloatingIPCompute):
88
+ class TestDeleteFloatingIPCompute(compute_fakes.TestComputev2):
97
89
  # The floating ips to be deleted.
98
90
  _floating_ips = compute_fakes.create_floating_ips(count=2)
99
91
 
@@ -169,7 +161,7 @@ class TestDeleteFloatingIPCompute(TestFloatingIPCompute):
169
161
 
170
162
 
171
163
  @mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_list')
172
- class TestListFloatingIPCompute(TestFloatingIPCompute):
164
+ class TestListFloatingIPCompute(compute_fakes.TestComputev2):
173
165
  # The floating ips to be list up
174
166
  _floating_ips = compute_fakes.create_floating_ips(count=3)
175
167
 
@@ -215,7 +207,7 @@ class TestListFloatingIPCompute(TestFloatingIPCompute):
215
207
 
216
208
 
217
209
  @mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_find')
218
- class TestShowFloatingIPCompute(TestFloatingIPCompute):
210
+ class TestShowFloatingIPCompute(compute_fakes.TestComputev2):
219
211
  # The floating ip to display.
220
212
  _floating_ip = compute_fakes.create_one_floating_ip()
221
213
 
@@ -20,16 +20,8 @@ from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
20
20
  # Tests for Compute network
21
21
 
22
22
 
23
- class TestFloatingIPPoolCompute(compute_fakes.TestComputev2):
24
- def setUp(self):
25
- super(TestFloatingIPPoolCompute, self).setUp()
26
-
27
- # Get a shortcut to the compute client
28
- self.compute = self.app.client_manager.compute
29
-
30
-
31
23
  @mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_pool_list')
32
- class TestListFloatingIPPoolCompute(TestFloatingIPPoolCompute):
24
+ class TestListFloatingIPPoolCompute(compute_fakes.TestComputev2):
33
25
  # The floating ip pools to list up
34
26
  _floating_ip_pools = compute_fakes.create_floating_ip_pools(count=3)
35
27
 
@@ -1063,6 +1063,39 @@ class TestSetNetwork(TestNetwork):
1063
1063
  )
1064
1064
  self.assertIsNone(result)
1065
1065
 
1066
+ def test_set_to_empty(self):
1067
+ # Test if empty strings are accepted to clear any of the fields,
1068
+ # so once they are set to a value its possible to clear them again.
1069
+
1070
+ arglist = [
1071
+ self._network.name,
1072
+ '--name',
1073
+ '',
1074
+ '--description',
1075
+ '',
1076
+ '--dns-domain',
1077
+ '',
1078
+ ]
1079
+ verifylist = [
1080
+ ('network', self._network.name),
1081
+ ('description', ''),
1082
+ ('name', ''),
1083
+ ('dns_domain', ''),
1084
+ ]
1085
+
1086
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1087
+ result = self.cmd.take_action(parsed_args)
1088
+
1089
+ attrs = {
1090
+ 'name': '',
1091
+ 'description': '',
1092
+ 'dns_domain': '',
1093
+ }
1094
+ self.network_client.update_network.assert_called_once_with(
1095
+ self._network, **attrs
1096
+ )
1097
+ self.assertIsNone(result)
1098
+
1066
1099
  def test_set_nothing(self):
1067
1100
  arglist = [
1068
1101
  self._network.name,
@@ -23,16 +23,10 @@ from openstackclient.tests.unit import utils as tests_utils
23
23
 
24
24
  # Tests for Nova network
25
25
  #
26
- class TestNetworkCompute(compute_fakes.TestComputev2):
27
- def setUp(self):
28
- super(TestNetworkCompute, self).setUp()
29
-
30
- # Get a shortcut to the compute client
31
- self.compute = self.app.client_manager.compute
32
26
 
33
27
 
34
28
  @mock.patch('openstackclient.api.compute_v2.APIv2.network_create')
35
- class TestCreateNetworkCompute(TestNetworkCompute):
29
+ class TestCreateNetworkCompute(compute_fakes.TestComputev2):
36
30
  # The network to create.
37
31
  _network = compute_fakes.create_one_network()
38
32
 
@@ -172,7 +166,7 @@ class TestCreateNetworkCompute(TestNetworkCompute):
172
166
 
173
167
 
174
168
  @mock.patch('openstackclient.api.compute_v2.APIv2.network_delete')
175
- class TestDeleteNetworkCompute(TestNetworkCompute):
169
+ class TestDeleteNetworkCompute(compute_fakes.TestComputev2):
176
170
  def setUp(self):
177
171
  super(TestDeleteNetworkCompute, self).setUp()
178
172
 
@@ -182,7 +176,7 @@ class TestDeleteNetworkCompute(TestNetworkCompute):
182
176
  self._networks = compute_fakes.create_networks(count=3)
183
177
 
184
178
  # Return value of utils.find_resource()
185
- self.compute.api.network_find = compute_fakes.get_networks(
179
+ self.compute_client.api.network_find = compute_fakes.get_networks(
186
180
  networks=self._networks
187
181
  )
188
182
 
@@ -252,7 +246,7 @@ class TestDeleteNetworkCompute(TestNetworkCompute):
252
246
 
253
247
 
254
248
  @mock.patch('openstackclient.api.compute_v2.APIv2.network_list')
255
- class TestListNetworkCompute(TestNetworkCompute):
249
+ class TestListNetworkCompute(compute_fakes.TestComputev2):
256
250
  # The networks going to be listed up.
257
251
  _networks = compute_fakes.create_networks(count=3)
258
252
 
@@ -297,7 +291,7 @@ class TestListNetworkCompute(TestNetworkCompute):
297
291
 
298
292
 
299
293
  @mock.patch('openstackclient.api.compute_v2.APIv2.network_find')
300
- class TestShowNetworkCompute(TestNetworkCompute):
294
+ class TestShowNetworkCompute(compute_fakes.TestComputev2):
301
295
  # The network to show.
302
296
  _network = compute_fakes.create_one_network()
303
297
 
@@ -9,9 +9,7 @@
9
9
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
- #
13
12
 
14
- import argparse
15
13
  import copy
16
14
  from unittest import mock
17
15
  from unittest.mock import call
@@ -23,7 +21,7 @@ import testtools
23
21
  from openstackclient.network.v2 import network_trunk
24
22
  from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes_v3
25
23
  from openstackclient.tests.unit.network.v2 import fakes as network_fakes
26
- from openstackclient.tests.unit import utils as tests_utils
24
+ from openstackclient.tests.unit import utils as test_utils
27
25
 
28
26
 
29
27
  # Tests for Neutron trunks
@@ -104,7 +102,7 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
104
102
  verifylist = []
105
103
 
106
104
  self.assertRaises(
107
- tests_utils.ParserException,
105
+ test_utils.ParserException,
108
106
  self.check_parser,
109
107
  self.cmd,
110
108
  arglist,
@@ -289,7 +287,7 @@ class TestCreateNetworkTrunk(TestNetworkTrunk):
289
287
  ),
290
288
  ]
291
289
 
292
- with testtools.ExpectedException(argparse.ArgumentTypeError):
290
+ with testtools.ExpectedException(test_utils.ParserException):
293
291
  self.check_parser(self.cmd, arglist, verifylist)
294
292
 
295
293
 
@@ -432,7 +430,7 @@ class TestShowNetworkTrunk(TestNetworkTrunk):
432
430
  verifylist = []
433
431
 
434
432
  self.assertRaises(
435
- tests_utils.ParserException,
433
+ test_utils.ParserException,
436
434
  self.check_parser,
437
435
  self.cmd,
438
436
  arglist,
@@ -755,7 +753,7 @@ class TestSetNetworkTrunk(TestNetworkTrunk):
755
753
  ),
756
754
  ]
757
755
 
758
- with testtools.ExpectedException(argparse.ArgumentTypeError):
756
+ with testtools.ExpectedException(test_utils.ParserException):
759
757
  self.check_parser(self.cmd, arglist, verifylist)
760
758
 
761
759
  self.network_client.add_trunk_subports.assert_not_called()
@@ -949,7 +947,7 @@ class TestUnsetNetworkTrunk(TestNetworkTrunk):
949
947
  ('trunk', self._trunk['name']),
950
948
  ]
951
949
  self.assertRaises(
952
- tests_utils.ParserException,
950
+ test_utils.ParserException,
953
951
  self.check_parser,
954
952
  self.cmd,
955
953
  arglist,
@@ -9,9 +9,7 @@
9
9
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
- #
13
12
 
14
- import argparse
15
13
  from unittest import mock
16
14
  from unittest.mock import call
17
15
 
@@ -23,7 +21,7 @@ from openstackclient.network.v2 import port
23
21
  from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
24
22
  from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
25
23
  from openstackclient.tests.unit.network.v2 import fakes as network_fakes
26
- from openstackclient.tests.unit import utils as tests_utils
24
+ from openstackclient.tests.unit import utils as test_utils
27
25
 
28
26
 
29
27
  LIST_FIELDS_TO_RETRIEVE = ('id', 'name', 'mac_address', 'fixed_ips', 'status')
@@ -58,6 +56,7 @@ class TestPort(network_fakes.TestNetworkV2):
58
56
  'dns_name',
59
57
  'extra_dhcp_opts',
60
58
  'fixed_ips',
59
+ 'hardware_offload_type',
61
60
  'hints',
62
61
  'id',
63
62
  'ip_allocation',
@@ -98,6 +97,7 @@ class TestPort(network_fakes.TestNetworkV2):
98
97
  fake_port.dns_name,
99
98
  format_columns.ListDictColumn(fake_port.extra_dhcp_opts),
100
99
  format_columns.ListDictColumn(fake_port.fixed_ips),
100
+ fake_port.hardware_offload_type,
101
101
  fake_port.hints,
102
102
  fake_port.id,
103
103
  fake_port.ip_allocation,
@@ -172,7 +172,7 @@ class TestCreatePort(TestPort):
172
172
  )
173
173
  self.assertFalse(self.network_client.set_tags.called)
174
174
 
175
- self.assertEqual(set(self.columns), set(columns))
175
+ self.assertCountEqual(self.columns, columns)
176
176
  self.assertCountEqual(self.data, data)
177
177
 
178
178
  def test_create_full_options(self):
@@ -245,7 +245,7 @@ class TestCreatePort(TestPort):
245
245
  }
246
246
  )
247
247
 
248
- self.assertEqual(set(self.columns), set(columns))
248
+ self.assertCountEqual(self.columns, columns)
249
249
  self.assertCountEqual(self.data, data)
250
250
 
251
251
  def test_create_invalid_json_binding_profile(self):
@@ -257,7 +257,7 @@ class TestCreatePort(TestPort):
257
257
  'test-port',
258
258
  ]
259
259
  self.assertRaises(
260
- argparse.ArgumentTypeError,
260
+ test_utils.ParserException,
261
261
  self.check_parser,
262
262
  self.cmd,
263
263
  arglist,
@@ -273,7 +273,7 @@ class TestCreatePort(TestPort):
273
273
  'test-port',
274
274
  ]
275
275
  self.assertRaises(
276
- argparse.ArgumentTypeError,
276
+ test_utils.ParserException,
277
277
  self.check_parser,
278
278
  self.cmd,
279
279
  arglist,
@@ -309,7 +309,7 @@ class TestCreatePort(TestPort):
309
309
  }
310
310
  )
311
311
 
312
- self.assertEqual(set(self.columns), set(columns))
312
+ self.assertCountEqual(self.columns, columns)
313
313
  self.assertCountEqual(self.data, data)
314
314
 
315
315
  def test_create_with_security_group(self):
@@ -347,7 +347,7 @@ class TestCreatePort(TestPort):
347
347
  }
348
348
  )
349
349
 
350
- self.assertEqual(set(self.columns), set(columns))
350
+ self.assertCountEqual(self.columns, columns)
351
351
  self.assertCountEqual(self.data, data)
352
352
 
353
353
  def test_create_port_with_dns_name(self):
@@ -380,7 +380,7 @@ class TestCreatePort(TestPort):
380
380
  }
381
381
  )
382
382
 
383
- self.assertEqual(set(self.columns), set(columns))
383
+ self.assertCountEqual(self.columns, columns)
384
384
  self.assertCountEqual(self.data, data)
385
385
 
386
386
  def test_create_with_security_groups(self):
@@ -420,7 +420,7 @@ class TestCreatePort(TestPort):
420
420
  }
421
421
  )
422
422
 
423
- self.assertEqual(set(self.columns), set(columns))
423
+ self.assertCountEqual(self.columns, columns)
424
424
  self.assertCountEqual(self.data, data)
425
425
 
426
426
  def test_create_with_no_security_groups(self):
@@ -449,7 +449,7 @@ class TestCreatePort(TestPort):
449
449
  }
450
450
  )
451
451
 
452
- self.assertEqual(set(self.columns), set(columns))
452
+ self.assertCountEqual(self.columns, columns)
453
453
  self.assertCountEqual(self.data, data)
454
454
 
455
455
  def test_create_with_no_fixed_ips(self):
@@ -478,7 +478,7 @@ class TestCreatePort(TestPort):
478
478
  }
479
479
  )
480
480
 
481
- self.assertEqual(set(self.columns), set(columns))
481
+ self.assertCountEqual(self.columns, columns)
482
482
  self.assertCountEqual(self.data, data)
483
483
 
484
484
  def test_create_port_with_allowed_address_pair_ipaddr(self):
@@ -520,7 +520,7 @@ class TestCreatePort(TestPort):
520
520
  }
521
521
  )
522
522
 
523
- self.assertEqual(set(self.columns), set(columns))
523
+ self.assertCountEqual(self.columns, columns)
524
524
  self.assertCountEqual(self.data, data)
525
525
 
526
526
  def test_create_port_with_allowed_address_pair(self):
@@ -571,7 +571,7 @@ class TestCreatePort(TestPort):
571
571
  }
572
572
  )
573
573
 
574
- self.assertEqual(set(self.columns), set(columns))
574
+ self.assertCountEqual(self.columns, columns)
575
575
  self.assertCountEqual(self.data, data)
576
576
 
577
577
  def test_create_port_with_qos(self):
@@ -608,7 +608,7 @@ class TestCreatePort(TestPort):
608
608
  }
609
609
  )
610
610
 
611
- self.assertEqual(set(self.columns), set(columns))
611
+ self.assertCountEqual(self.columns, columns)
612
612
  self.assertCountEqual(self.data, data)
613
613
 
614
614
  def test_create_port_security_enabled(self):
@@ -733,12 +733,12 @@ class TestCreatePort(TestPort):
733
733
  )
734
734
  if add_tags:
735
735
  self.network_client.set_tags.assert_called_once_with(
736
- self._port, tests_utils.CompareBySet(['red', 'blue'])
736
+ self._port, test_utils.CompareBySet(['red', 'blue'])
737
737
  )
738
738
  else:
739
739
  self.assertFalse(self.network_client.set_tags.called)
740
740
 
741
- self.assertEqual(set(self.columns), set(columns))
741
+ self.assertCountEqual(self.columns, columns)
742
742
  self.assertCountEqual(self.data, data)
743
743
 
744
744
  def test_create_with_tags(self):
@@ -787,7 +787,7 @@ class TestCreatePort(TestPort):
787
787
  }
788
788
  )
789
789
 
790
- self.assertEqual(set(self.columns), set(columns))
790
+ self.assertCountEqual(self.columns, columns)
791
791
  self.assertCountEqual(self.data, data)
792
792
 
793
793
  def test_create_with_uplink_status_propagation_enabled(self):
@@ -893,7 +893,7 @@ class TestCreatePort(TestPort):
893
893
  create_args['numa_affinity_policy'] = numa_affinity_policy
894
894
  self.network_client.create_port.assert_called_once_with(**create_args)
895
895
 
896
- self.assertEqual(set(self.columns), set(columns))
896
+ self.assertCountEqual(self.columns, columns)
897
897
  self.assertCountEqual(self.data, data)
898
898
 
899
899
  def test_create_with_numa_affinity_policy_required(self):
@@ -940,7 +940,7 @@ class TestCreatePort(TestPort):
940
940
  'device_profile': 'cyborg_device_profile_1',
941
941
  }
942
942
  self.network_client.create_port.assert_called_once_with(**create_args)
943
- self.assertEqual(set(self.columns), set(columns))
943
+ self.assertCountEqual(self.columns, columns)
944
944
  self.assertCountEqual(self.data, data)
945
945
 
946
946
  def test_create_hints_invalid_json(self):
@@ -952,7 +952,7 @@ class TestCreatePort(TestPort):
952
952
  'test-port',
953
953
  ]
954
954
  self.assertRaises(
955
- argparse.ArgumentTypeError,
955
+ test_utils.ParserException,
956
956
  self.check_parser,
957
957
  self.cmd,
958
958
  arglist,
@@ -976,7 +976,7 @@ class TestCreatePort(TestPort):
976
976
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
977
977
 
978
978
  self.assertRaises(
979
- argparse.ArgumentTypeError,
979
+ exceptions.CommandError,
980
980
  self.cmd.take_action,
981
981
  parsed_args,
982
982
  )
@@ -998,7 +998,7 @@ class TestCreatePort(TestPort):
998
998
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
999
999
 
1000
1000
  self.assertRaises(
1001
- argparse.ArgumentTypeError,
1001
+ exceptions.CommandError,
1002
1002
  self.cmd.take_action,
1003
1003
  parsed_args,
1004
1004
  )
@@ -1032,7 +1032,7 @@ class TestCreatePort(TestPort):
1032
1032
  }
1033
1033
  )
1034
1034
 
1035
- self.assertEqual(set(self.columns), set(columns))
1035
+ self.assertCountEqual(self.columns, columns)
1036
1036
  self.assertCountEqual(self.data, data)
1037
1037
 
1038
1038
  def test_create_hints_valid_json(self):
@@ -1067,9 +1067,51 @@ class TestCreatePort(TestPort):
1067
1067
  }
1068
1068
  )
1069
1069
 
1070
+ self.assertCountEqual(self.columns, columns)
1071
+ self.assertCountEqual(self.data, data)
1072
+
1073
+ def _test_create_with_hardware_offload_type(self, hwol_type=None):
1074
+ arglist = [
1075
+ '--network',
1076
+ self._port.network_id,
1077
+ 'test-port',
1078
+ ]
1079
+ if hwol_type:
1080
+ arglist += ['--hardware-offload-type', hwol_type]
1081
+
1082
+ hardware_offload_type = None if not hwol_type else hwol_type
1083
+ verifylist = [
1084
+ (
1085
+ 'network',
1086
+ self._port.network_id,
1087
+ ),
1088
+ ('name', 'test-port'),
1089
+ ]
1090
+ if hwol_type:
1091
+ verifylist.append(('hardware_offload_type', hwol_type))
1092
+
1093
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1094
+
1095
+ columns, data = self.cmd.take_action(parsed_args)
1096
+
1097
+ create_args = {
1098
+ 'admin_state_up': True,
1099
+ 'network_id': self._port.network_id,
1100
+ 'name': 'test-port',
1101
+ }
1102
+ if hwol_type:
1103
+ create_args['hardware_offload_type'] = hardware_offload_type
1104
+ self.network_client.create_port.assert_called_once_with(**create_args)
1105
+
1070
1106
  self.assertEqual(set(self.columns), set(columns))
1071
1107
  self.assertCountEqual(self.data, data)
1072
1108
 
1109
+ def test_create_with_hardware_offload_type_switchdev(self):
1110
+ self._test_create_with_hardware_offload_type(hwol_type='switchdev')
1111
+
1112
+ def test_create_with_hardware_offload_type_null(self):
1113
+ self._test_create_with_hardware_offload_type()
1114
+
1073
1115
 
1074
1116
  class TestDeletePort(TestPort):
1075
1117
  # Ports to delete.
@@ -1200,8 +1242,6 @@ class TestListPort(TestPort):
1200
1242
  def setUp(self):
1201
1243
  super(TestListPort, self).setUp()
1202
1244
 
1203
- # Get the command object to test
1204
- self.cmd = port.ListPort(self.app, self.namespace)
1205
1245
  self.network_client.ports = mock.Mock(return_value=self._ports)
1206
1246
  fake_router = network_fakes.FakeRouter.create_one_router(
1207
1247
  {
@@ -1215,7 +1255,12 @@ class TestListPort(TestPort):
1215
1255
  )
1216
1256
  self.network_client.find_router = mock.Mock(return_value=fake_router)
1217
1257
  self.network_client.find_network = mock.Mock(return_value=fake_network)
1258
+
1218
1259
  self.app.client_manager.compute = mock.Mock()
1260
+ self.compute_client = self.app.client_manager.compute
1261
+
1262
+ # Get the command object to test
1263
+ self.cmd = port.ListPort(self.app, self.namespace)
1219
1264
 
1220
1265
  def test_port_list_no_options(self):
1221
1266
  arglist = []
@@ -1662,7 +1707,7 @@ class TestListPort(TestPort):
1662
1707
 
1663
1708
  columns, data = self.cmd.take_action(parsed_args)
1664
1709
  filters = {
1665
- 'security_groups': ['sg-id1', 'sg-id2'],
1710
+ 'security_group_ids': ['sg-id1', 'sg-id2'],
1666
1711
  'fields': LIST_FIELDS_TO_RETRIEVE,
1667
1712
  }
1668
1713
 
@@ -1902,7 +1947,7 @@ class TestSetPort(TestPort):
1902
1947
  'test-port',
1903
1948
  ]
1904
1949
  self.assertRaises(
1905
- argparse.ArgumentTypeError,
1950
+ test_utils.ParserException,
1906
1951
  self.check_parser,
1907
1952
  self.cmd,
1908
1953
  arglist,
@@ -1916,7 +1961,7 @@ class TestSetPort(TestPort):
1916
1961
  'test-port',
1917
1962
  ]
1918
1963
  self.assertRaises(
1919
- argparse.ArgumentTypeError,
1964
+ test_utils.ParserException,
1920
1965
  self.check_parser,
1921
1966
  self.cmd,
1922
1967
  arglist,
@@ -2282,7 +2327,7 @@ class TestSetPort(TestPort):
2282
2327
  'test-port',
2283
2328
  ]
2284
2329
  self.assertRaises(
2285
- tests_utils.ParserException,
2330
+ test_utils.ParserException,
2286
2331
  self.check_parser,
2287
2332
  self.cmd,
2288
2333
  arglist,
@@ -2306,7 +2351,7 @@ class TestSetPort(TestPort):
2306
2351
 
2307
2352
  self.assertFalse(self.network_client.update_port.called)
2308
2353
  self.network_client.set_tags.assert_called_once_with(
2309
- self._port, tests_utils.CompareBySet(expected_args)
2354
+ self._port, test_utils.CompareBySet(expected_args)
2310
2355
  )
2311
2356
  self.assertIsNone(result)
2312
2357
 
@@ -2355,7 +2400,7 @@ class TestSetPort(TestPort):
2355
2400
  'test-port',
2356
2401
  ]
2357
2402
  self.assertRaises(
2358
- argparse.ArgumentTypeError,
2403
+ test_utils.ParserException,
2359
2404
  self.check_parser,
2360
2405
  self.cmd,
2361
2406
  arglist,
@@ -2374,7 +2419,7 @@ class TestSetPort(TestPort):
2374
2419
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2375
2420
 
2376
2421
  self.assertRaises(
2377
- argparse.ArgumentTypeError,
2422
+ exceptions.CommandError,
2378
2423
  self.cmd.take_action,
2379
2424
  parsed_args,
2380
2425
  )
@@ -2391,7 +2436,7 @@ class TestSetPort(TestPort):
2391
2436
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2392
2437
 
2393
2438
  self.assertRaises(
2394
- argparse.ArgumentTypeError,
2439
+ exceptions.CommandError,
2395
2440
  self.cmd.take_action,
2396
2441
  parsed_args,
2397
2442
  )
@@ -2474,7 +2519,7 @@ class TestShowPort(TestPort):
2474
2519
  verifylist = []
2475
2520
 
2476
2521
  self.assertRaises(
2477
- tests_utils.ParserException,
2522
+ test_utils.ParserException,
2478
2523
  self.check_parser,
2479
2524
  self.cmd,
2480
2525
  arglist,
@@ -2496,7 +2541,7 @@ class TestShowPort(TestPort):
2496
2541
  self._port.name, ignore_missing=False
2497
2542
  )
2498
2543
 
2499
- self.assertEqual(set(self.columns), set(columns))
2544
+ self.assertCountEqual(self.columns, columns)
2500
2545
  self.assertCountEqual(self.data, data)
2501
2546
 
2502
2547
 
@@ -2753,7 +2798,7 @@ class TestUnsetPort(TestPort):
2753
2798
 
2754
2799
  self.assertFalse(self.network_client.update_port.called)
2755
2800
  self.network_client.set_tags.assert_called_once_with(
2756
- self._testport, tests_utils.CompareBySet(expected_args)
2801
+ self._testport, test_utils.CompareBySet(expected_args)
2757
2802
  )
2758
2803
  self.assertIsNone(result)
2759
2804
 
@@ -22,16 +22,8 @@ from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
22
22
  from openstackclient.tests.unit import utils as tests_utils
23
23
 
24
24
 
25
- class TestSecurityGroupCompute(compute_fakes.TestComputev2):
26
- def setUp(self):
27
- super(TestSecurityGroupCompute, self).setUp()
28
-
29
- # Get a shortcut to the compute client
30
- self.compute = self.app.client_manager.compute
31
-
32
-
33
25
  @mock.patch('openstackclient.api.compute_v2.APIv2.security_group_create')
34
- class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
26
+ class TestCreateSecurityGroupCompute(compute_fakes.TestComputev2):
35
27
  project = identity_fakes.FakeProject.create_one_project()
36
28
  domain = identity_fakes.FakeDomain.create_one_domain()
37
29
 
@@ -110,7 +102,7 @@ class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
110
102
 
111
103
 
112
104
  @mock.patch('openstackclient.api.compute_v2.APIv2.security_group_delete')
113
- class TestDeleteSecurityGroupCompute(TestSecurityGroupCompute):
105
+ class TestDeleteSecurityGroupCompute(compute_fakes.TestComputev2):
114
106
  # The security groups to be deleted.
115
107
  _security_groups = compute_fakes.create_security_groups()
116
108
 
@@ -119,7 +111,7 @@ class TestDeleteSecurityGroupCompute(TestSecurityGroupCompute):
119
111
 
120
112
  self.app.client_manager.network_endpoint_enabled = False
121
113
 
122
- self.compute.api.security_group_find = (
114
+ self.compute_client.api.security_group_find = (
123
115
  compute_fakes.get_security_groups(self._security_groups)
124
116
  )
125
117
 
@@ -192,7 +184,7 @@ class TestDeleteSecurityGroupCompute(TestSecurityGroupCompute):
192
184
 
193
185
 
194
186
  @mock.patch('openstackclient.api.compute_v2.APIv2.security_group_list')
195
- class TestListSecurityGroupCompute(TestSecurityGroupCompute):
187
+ class TestListSecurityGroupCompute(compute_fakes.TestComputev2):
196
188
  # The security group to be listed.
197
189
  _security_groups = compute_fakes.create_security_groups(count=3)
198
190
 
@@ -270,7 +262,7 @@ class TestListSecurityGroupCompute(TestSecurityGroupCompute):
270
262
 
271
263
 
272
264
  @mock.patch('openstackclient.api.compute_v2.APIv2.security_group_set')
273
- class TestSetSecurityGroupCompute(TestSecurityGroupCompute):
265
+ class TestSetSecurityGroupCompute(compute_fakes.TestComputev2):
274
266
  # The security group to be set.
275
267
  _security_group = compute_fakes.create_one_security_group()
276
268
 
@@ -279,7 +271,7 @@ class TestSetSecurityGroupCompute(TestSecurityGroupCompute):
279
271
 
280
272
  self.app.client_manager.network_endpoint_enabled = False
281
273
 
282
- self.compute.api.security_group_find = mock.Mock(
274
+ self.compute_client.api.security_group_find = mock.Mock(
283
275
  return_value=self._security_group
284
276
  )
285
277
 
@@ -337,7 +329,7 @@ class TestSetSecurityGroupCompute(TestSecurityGroupCompute):
337
329
 
338
330
 
339
331
  @mock.patch('openstackclient.api.compute_v2.APIv2.security_group_find')
340
- class TestShowSecurityGroupCompute(TestSecurityGroupCompute):
332
+ class TestShowSecurityGroupCompute(compute_fakes.TestComputev2):
341
333
  # The security group rule to be shown with the group.
342
334
  _security_group_rule = compute_fakes.create_one_security_group_rule()
343
335