python-openstackclient 6.4.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 (44) hide show
  1. openstackclient/common/availability_zone.py +4 -4
  2. openstackclient/compute/v2/server.py +173 -99
  3. openstackclient/identity/v3/mapping.py +25 -3
  4. openstackclient/identity/v3/policy.py +3 -1
  5. openstackclient/image/v2/image.py +37 -0
  6. openstackclient/image/v2/metadef_namespaces.py +25 -21
  7. openstackclient/image/v2/metadef_objects.py +26 -30
  8. openstackclient/image/v2/metadef_properties.py +60 -38
  9. openstackclient/network/v2/default_security_group_rule.py +23 -4
  10. openstackclient/network/v2/local_ip_association.py +1 -1
  11. openstackclient/network/v2/ndp_proxy.py +7 -3
  12. openstackclient/network/v2/network.py +2 -2
  13. openstackclient/network/v2/port.py +23 -7
  14. openstackclient/network/v2/subnet.py +1 -0
  15. openstackclient/tests/functional/base.py +7 -4
  16. openstackclient/tests/unit/compute/v2/test_server.py +72 -54
  17. openstackclient/tests/unit/identity/v3/test_mappings.py +9 -4
  18. openstackclient/tests/unit/identity/v3/test_trust.py +0 -2
  19. openstackclient/tests/unit/image/v1/fakes.py +1 -1
  20. openstackclient/tests/unit/image/v2/test_image.py +60 -0
  21. openstackclient/tests/unit/image/v2/test_metadef_namespaces.py +5 -19
  22. openstackclient/tests/unit/integ/cli/test_shell.py +0 -2
  23. openstackclient/tests/unit/network/v2/fakes.py +1 -0
  24. openstackclient/tests/unit/network/v2/test_network.py +33 -0
  25. openstackclient/tests/unit/network/v2/test_network_trunk.py +6 -8
  26. openstackclient/tests/unit/network/v2/test_port.py +60 -18
  27. openstackclient/tests/unit/network/v2/test_subnet.py +92 -0
  28. openstackclient/tests/unit/network/v2/test_subnet_pool.py +11 -13
  29. openstackclient/tests/unit/test_shell.py +1 -7
  30. openstackclient/tests/unit/utils.py +8 -1
  31. openstackclient/tests/unit/volume/v1/test_volume.py +4 -6
  32. openstackclient/tests/unit/volume/v2/test_volume.py +4 -6
  33. openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +3 -5
  34. openstackclient/volume/v2/volume_type.py +3 -3
  35. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/AUTHORS +4 -0
  36. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/METADATA +3 -1
  37. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/RECORD +42 -43
  38. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/entry_points.txt +6 -5
  39. python_openstackclient-6.5.0.dist-info/pbr.json +1 -0
  40. openstackclient/tests/unit/common/test_parseractions.py +0 -233
  41. python_openstackclient-6.4.0.dist-info/pbr.json +0 -1
  42. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/LICENSE +0 -0
  43. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/WHEEL +0 -0
  44. {python_openstackclient-6.4.0.dist-info → python_openstackclient-6.5.0.dist-info}/top_level.txt +0 -0
@@ -21,30 +21,16 @@ class TestMetadefNamespaceCreate(image_fakes.TestImagev2):
21
21
 
22
22
  expected_columns = (
23
23
  'created_at',
24
- 'description',
25
24
  'display_name',
26
- 'id',
27
- 'is_protected',
28
- 'location',
29
- 'name',
30
25
  'namespace',
31
26
  'owner',
32
- 'resource_type_associations',
33
- 'updated_at',
34
27
  'visibility',
35
28
  )
36
29
  expected_data = (
37
30
  _metadef_namespace.created_at,
38
- _metadef_namespace.description,
39
31
  _metadef_namespace.display_name,
40
- _metadef_namespace.id,
41
- _metadef_namespace.is_protected,
42
- _metadef_namespace.location,
43
- _metadef_namespace.name,
44
32
  _metadef_namespace.namespace,
45
33
  _metadef_namespace.owner,
46
- _metadef_namespace.resource_type_associations,
47
- _metadef_namespace.updated_at,
48
34
  _metadef_namespace.visibility,
49
35
  )
50
36
 
@@ -54,7 +40,7 @@ class TestMetadefNamespaceCreate(image_fakes.TestImagev2):
54
40
  self.image_client.create_metadef_namespace.return_value = (
55
41
  self._metadef_namespace
56
42
  )
57
- self.cmd = metadef_namespaces.CreateMetadefNameSpace(self.app, None)
43
+ self.cmd = metadef_namespaces.CreateMetadefNamespace(self.app, None)
58
44
  self.datalist = self._metadef_namespace
59
45
 
60
46
  def test_namespace_create(self):
@@ -78,7 +64,7 @@ class TestMetadefNamespaceDelete(image_fakes.TestImagev2):
78
64
  self.image_client.delete_metadef_namespace.return_value = (
79
65
  self._metadef_namespace
80
66
  )
81
- self.cmd = metadef_namespaces.DeleteMetadefNameSpace(self.app, None)
67
+ self.cmd = metadef_namespaces.DeleteMetadefNamespace(self.app, None)
82
68
  self.datalist = self._metadef_namespace
83
69
 
84
70
  def test_namespace_create(self):
@@ -111,7 +97,7 @@ class TestMetadefNamespaceList(image_fakes.TestImagev2):
111
97
  self.image_client.metadef_namespaces.return_value = iter(
112
98
  self._metadef_namespace
113
99
  )
114
- self.cmd = metadef_namespaces.ListMetadefNameSpaces(self.app, None)
100
+ self.cmd = metadef_namespaces.ListMetadefNamespace(self.app, None)
115
101
  self.datalist = self._metadef_namespace
116
102
 
117
103
  def test_namespace_list_no_options(self):
@@ -136,7 +122,7 @@ class TestMetadefNamespaceSet(image_fakes.TestImagev2):
136
122
  self.image_client.update_metadef_namespace.return_value = (
137
123
  self._metadef_namespace
138
124
  )
139
- self.cmd = metadef_namespaces.SetMetadefNameSpace(self.app, None)
125
+ self.cmd = metadef_namespaces.SetMetadefNamespace(self.app, None)
140
126
  self.datalist = self._metadef_namespace
141
127
 
142
128
  def test_namespace_set_no_options(self):
@@ -176,7 +162,7 @@ class TestMetadefNamespaceShow(image_fakes.TestImagev2):
176
162
  self.image_client.get_metadef_namespace.return_value = (
177
163
  self._metadef_namespace
178
164
  )
179
- self.cmd = metadef_namespaces.ShowMetadefNameSpace(self.app, None)
165
+ self.cmd = metadef_namespaces.ShowMetadefNamespace(self.app, None)
180
166
 
181
167
  def test_namespace_show_no_options(self):
182
168
  arglist = [self._metadef_namespace.namespace]
@@ -502,7 +502,6 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg):
502
502
  )
503
503
 
504
504
  # +env, -cli, +occ
505
- print("auth_req: %s" % auth_req['auth'])
506
505
  self.assertEqual(
507
506
  test_shell.DEFAULT_USERNAME,
508
507
  auth_req['auth']['identity']['password']['user']['name'],
@@ -559,7 +558,6 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg):
559
558
  )
560
559
 
561
560
  # +env, +cli, +occ
562
- print("auth_req: %s" % auth_req['auth'])
563
561
  self.assertEqual(
564
562
  'zarquon',
565
563
  auth_req['auth']['identity']['password']['user']['name'],
@@ -1761,6 +1761,7 @@ def create_one_port(attrs=None):
1761
1761
  'subnet_id': 'subnet-id-' + uuid.uuid4().hex,
1762
1762
  }
1763
1763
  ],
1764
+ 'hardware_offload_type': None,
1764
1765
  'hints': {},
1765
1766
  'id': 'port-id-' + uuid.uuid4().hex,
1766
1767
  'mac_address': 'fa:16:3e:a9:4e:72',
@@ -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,
@@ -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,
@@ -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,
@@ -733,7 +733,7 @@ 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)
@@ -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
  )
@@ -1070,6 +1070,48 @@ class TestCreatePort(TestPort):
1070
1070
  self.assertCountEqual(self.columns, columns)
1071
1071
  self.assertCountEqual(self.data, data)
1072
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
+
1106
+ self.assertEqual(set(self.columns), set(columns))
1107
+ self.assertCountEqual(self.data, data)
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.
@@ -1905,7 +1947,7 @@ class TestSetPort(TestPort):
1905
1947
  'test-port',
1906
1948
  ]
1907
1949
  self.assertRaises(
1908
- argparse.ArgumentTypeError,
1950
+ test_utils.ParserException,
1909
1951
  self.check_parser,
1910
1952
  self.cmd,
1911
1953
  arglist,
@@ -1919,7 +1961,7 @@ class TestSetPort(TestPort):
1919
1961
  'test-port',
1920
1962
  ]
1921
1963
  self.assertRaises(
1922
- argparse.ArgumentTypeError,
1964
+ test_utils.ParserException,
1923
1965
  self.check_parser,
1924
1966
  self.cmd,
1925
1967
  arglist,
@@ -2285,7 +2327,7 @@ class TestSetPort(TestPort):
2285
2327
  'test-port',
2286
2328
  ]
2287
2329
  self.assertRaises(
2288
- tests_utils.ParserException,
2330
+ test_utils.ParserException,
2289
2331
  self.check_parser,
2290
2332
  self.cmd,
2291
2333
  arglist,
@@ -2309,7 +2351,7 @@ class TestSetPort(TestPort):
2309
2351
 
2310
2352
  self.assertFalse(self.network_client.update_port.called)
2311
2353
  self.network_client.set_tags.assert_called_once_with(
2312
- self._port, tests_utils.CompareBySet(expected_args)
2354
+ self._port, test_utils.CompareBySet(expected_args)
2313
2355
  )
2314
2356
  self.assertIsNone(result)
2315
2357
 
@@ -2358,7 +2400,7 @@ class TestSetPort(TestPort):
2358
2400
  'test-port',
2359
2401
  ]
2360
2402
  self.assertRaises(
2361
- argparse.ArgumentTypeError,
2403
+ test_utils.ParserException,
2362
2404
  self.check_parser,
2363
2405
  self.cmd,
2364
2406
  arglist,
@@ -2377,7 +2419,7 @@ class TestSetPort(TestPort):
2377
2419
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2378
2420
 
2379
2421
  self.assertRaises(
2380
- argparse.ArgumentTypeError,
2422
+ exceptions.CommandError,
2381
2423
  self.cmd.take_action,
2382
2424
  parsed_args,
2383
2425
  )
@@ -2394,7 +2436,7 @@ class TestSetPort(TestPort):
2394
2436
  parsed_args = self.check_parser(self.cmd, arglist, verifylist)
2395
2437
 
2396
2438
  self.assertRaises(
2397
- argparse.ArgumentTypeError,
2439
+ exceptions.CommandError,
2398
2440
  self.cmd.take_action,
2399
2441
  parsed_args,
2400
2442
  )
@@ -2477,7 +2519,7 @@ class TestShowPort(TestPort):
2477
2519
  verifylist = []
2478
2520
 
2479
2521
  self.assertRaises(
2480
- tests_utils.ParserException,
2522
+ test_utils.ParserException,
2481
2523
  self.check_parser,
2482
2524
  self.cmd,
2483
2525
  arglist,
@@ -2756,7 +2798,7 @@ class TestUnsetPort(TestPort):
2756
2798
 
2757
2799
  self.assertFalse(self.network_client.update_port.called)
2758
2800
  self.network_client.set_tags.assert_called_once_with(
2759
- self._testport, tests_utils.CompareBySet(expected_args)
2801
+ self._testport, test_utils.CompareBySet(expected_args)
2760
2802
  )
2761
2803
  self.assertIsNone(result)
2762
2804
 
@@ -108,6 +108,26 @@ class TestCreateSubnet(TestSubnet):
108
108
  }
109
109
  )
110
110
 
111
+ # An IPv6 subnet to be created with Prefix Delegation options specified
112
+ self._subnet_ipv6_pd = network_fakes.FakeSubnet.create_one_subnet(
113
+ attrs={
114
+ 'project_id': self.project.id,
115
+ 'cidr': '::/64',
116
+ 'enable_dhcp': True,
117
+ 'allocation_pools': [
118
+ {
119
+ 'start': '::1',
120
+ 'end': '::ffff:ffff:ffff:ffff',
121
+ },
122
+ ],
123
+ 'ip_version': 6,
124
+ 'gateway_ip': '::',
125
+ 'ipv6_address_mode': 'slaac',
126
+ 'ipv6_ra_mode': 'slaac',
127
+ 'subnetpool_id': 'prefix_delegation',
128
+ }
129
+ )
130
+
111
131
  # The network to be returned from find_network
112
132
  self._network = network_fakes.create_one_network(
113
133
  attrs={
@@ -210,6 +230,29 @@ class TestCreateSubnet(TestSubnet):
210
230
  format_columns.ListColumn(self._subnet_ipv6.tags),
211
231
  )
212
232
 
233
+ self.data_ipv6_pd = (
234
+ subnet_v2.AllocationPoolsColumn(
235
+ self._subnet_ipv6_pd.allocation_pools
236
+ ),
237
+ self._subnet_ipv6_pd.cidr,
238
+ self._subnet_ipv6_pd.description,
239
+ format_columns.ListColumn(self._subnet_ipv6_pd.dns_nameservers),
240
+ self._subnet_ipv6_pd.enable_dhcp,
241
+ self._subnet_ipv6_pd.gateway_ip,
242
+ subnet_v2.HostRoutesColumn(self._subnet_ipv6_pd.host_routes),
243
+ self._subnet_ipv6_pd.id,
244
+ self._subnet_ipv6_pd.ip_version,
245
+ self._subnet_ipv6_pd.ipv6_address_mode,
246
+ self._subnet_ipv6_pd.ipv6_ra_mode,
247
+ self._subnet_ipv6_pd.name,
248
+ self._subnet_ipv6_pd.network_id,
249
+ self._subnet_ipv6_pd.project_id,
250
+ self._subnet_ipv6_pd.segment_id,
251
+ format_columns.ListColumn(self._subnet_ipv6_pd.service_types),
252
+ self._subnet_ipv6_pd.subnetpool_id,
253
+ format_columns.ListColumn(self._subnet_ipv6_pd.tags),
254
+ )
255
+
213
256
  def setUp(self):
214
257
  self._init_subnet_variables()
215
258
  super(TestCreateSubnet, self).setUp()
@@ -455,6 +498,55 @@ class TestCreateSubnet(TestSubnet):
455
498
  self.assertEqual(self.columns, columns)
456
499
  self.assertCountEqual(self.data_ipv6, data)
457
500
 
501
+ def test_create_options_subnet_ipv6_pd(self):
502
+ # Mock SDK calls for this test.
503
+ self.network_client.create_subnet.return_value = self._subnet_ipv6_pd
504
+ self._network.id = self._subnet_ipv6_pd.network_id
505
+
506
+ arglist = [
507
+ self._subnet_ipv6_pd.name,
508
+ "--network",
509
+ self._subnet_ipv6_pd.network_id,
510
+ "--ip-version",
511
+ str(self._subnet_ipv6_pd.ip_version),
512
+ "--ipv6-ra-mode",
513
+ self._subnet_ipv6_pd.ipv6_ra_mode,
514
+ "--ipv6-address-mode",
515
+ self._subnet_ipv6_pd.ipv6_address_mode,
516
+ "--dhcp",
517
+ "--use-prefix-delegation",
518
+ ]
519
+
520
+ verifylist = [
521
+ ('name', self._subnet_ipv6_pd.name),
522
+ ('network', self._subnet_ipv6_pd.network_id),
523
+ ('ip_version', self._subnet_ipv6_pd.ip_version),
524
+ ('ipv6_ra_mode', self._subnet_ipv6_pd.ipv6_ra_mode),
525
+ ('ipv6_address_mode', self._subnet_ipv6_pd.ipv6_address_mode),
526
+ ('dhcp', self._subnet_ipv6_pd.enable_dhcp),
527
+ ('use_prefix_delegation', True),
528
+ ]
529
+
530
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
531
+ columns, data = self.cmd.take_action(parsed_args)
532
+
533
+ # Calling with --use-prefix-delegation will set the subnetpool_id
534
+ # to 'prefix_delegation'
535
+ self.network_client.create_subnet.assert_called_once_with(
536
+ **{
537
+ 'enable_dhcp': self._subnet_ipv6_pd.enable_dhcp,
538
+ 'ip_version': self._subnet_ipv6_pd.ip_version,
539
+ 'ipv6_address_mode': self._subnet_ipv6_pd.ipv6_address_mode,
540
+ 'ipv6_ra_mode': self._subnet_ipv6_pd.ipv6_ra_mode,
541
+ 'name': self._subnet_ipv6_pd.name,
542
+ 'network_id': self._subnet_ipv6_pd.network_id,
543
+ 'subnetpool_id': self._subnet_ipv6_pd.subnetpool_id,
544
+ }
545
+ )
546
+ self.assertFalse(self.network_client.set_tags.called)
547
+ self.assertEqual(self.columns, columns)
548
+ self.assertCountEqual(self.data_ipv6_pd, data)
549
+
458
550
  def test_create_with_network_segment(self):
459
551
  # Mock SDK calls for this test.
460
552
  self._network.id = self._subnet.network_id
@@ -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
 
@@ -21,7 +19,7 @@ from osc_lib import exceptions
21
19
  from openstackclient.network.v2 import subnet_pool
22
20
  from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes_v3
23
21
  from openstackclient.tests.unit.network.v2 import fakes as network_fakes
24
- from openstackclient.tests.unit import utils as tests_utils
22
+ from openstackclient.tests.unit import utils as test_utils
25
23
 
26
24
 
27
25
  class TestSubnetPool(network_fakes.TestNetworkV2):
@@ -98,7 +96,7 @@ class TestCreateSubnetPool(TestSubnetPool):
98
96
  verifylist = []
99
97
 
100
98
  self.assertRaises(
101
- tests_utils.ParserException,
99
+ test_utils.ParserException,
102
100
  self.check_parser,
103
101
  self.cmd,
104
102
  arglist,
@@ -115,7 +113,7 @@ class TestCreateSubnetPool(TestSubnetPool):
115
113
  ('name', self._subnet_pool.name),
116
114
  ]
117
115
  self.assertRaises(
118
- tests_utils.ParserException,
116
+ test_utils.ParserException,
119
117
  self.check_parser,
120
118
  self.cmd,
121
119
  arglist,
@@ -196,7 +194,7 @@ class TestCreateSubnetPool(TestSubnetPool):
196
194
  ]
197
195
 
198
196
  self.assertRaises(
199
- argparse.ArgumentTypeError,
197
+ test_utils.ParserException,
200
198
  self.check_parser,
201
199
  self.cmd,
202
200
  arglist,
@@ -368,7 +366,7 @@ class TestCreateSubnetPool(TestSubnetPool):
368
366
  )
369
367
  if add_tags:
370
368
  self.network_client.set_tags.assert_called_once_with(
371
- self._subnet_pool, tests_utils.CompareBySet(['red', 'blue'])
369
+ self._subnet_pool, test_utils.CompareBySet(['red', 'blue'])
372
370
  )
373
371
  else:
374
372
  self.assertFalse(self.network_client.set_tags.called)
@@ -837,7 +835,7 @@ class TestSetSubnetPool(TestSubnetPool):
837
835
  ]
838
836
 
839
837
  self.assertRaises(
840
- argparse.ArgumentTypeError,
838
+ test_utils.ParserException,
841
839
  self.check_parser,
842
840
  self.cmd,
843
841
  arglist,
@@ -902,7 +900,7 @@ class TestSetSubnetPool(TestSubnetPool):
902
900
 
903
901
  # Exclusive arguments will conflict here.
904
902
  self.assertRaises(
905
- tests_utils.ParserException,
903
+ test_utils.ParserException,
906
904
  self.check_parser,
907
905
  self.cmd,
908
906
  arglist,
@@ -963,7 +961,7 @@ class TestSetSubnetPool(TestSubnetPool):
963
961
 
964
962
  # Exclusive arguments will conflict here.
965
963
  self.assertRaises(
966
- tests_utils.ParserException,
964
+ test_utils.ParserException,
967
965
  self.check_parser,
968
966
  self.cmd,
969
967
  arglist,
@@ -1029,7 +1027,7 @@ class TestSetSubnetPool(TestSubnetPool):
1029
1027
 
1030
1028
  self.assertFalse(self.network_client.update_subnet_pool.called)
1031
1029
  self.network_client.set_tags.assert_called_once_with(
1032
- self._subnet_pool, tests_utils.CompareBySet(expected_args)
1030
+ self._subnet_pool, test_utils.CompareBySet(expected_args)
1033
1031
  )
1034
1032
  self.assertIsNone(result)
1035
1033
 
@@ -1093,7 +1091,7 @@ class TestShowSubnetPool(TestSubnetPool):
1093
1091
  verifylist = []
1094
1092
 
1095
1093
  self.assertRaises(
1096
- tests_utils.ParserException,
1094
+ test_utils.ParserException,
1097
1095
  self.check_parser,
1098
1096
  self.cmd,
1099
1097
  arglist,
@@ -1149,7 +1147,7 @@ class TestUnsetSubnetPool(TestSubnetPool):
1149
1147
 
1150
1148
  self.assertFalse(self.network_client.update_subnet_pool.called)
1151
1149
  self.network_client.set_tags.assert_called_once_with(
1152
- self._subnetpool, tests_utils.CompareBySet(expected_args)
1150
+ self._subnetpool, test_utils.CompareBySet(expected_args)
1153
1151
  )
1154
1152
  self.assertIsNone(result)
1155
1153
 
@@ -141,10 +141,6 @@ class TestShell(osc_lib_test_utils.TestShell):
141
141
  # Full name of the OpenStackShell class to test (cliff.app.App subclass)
142
142
  shell_class_name = "openstackclient.shell.OpenStackShell"
143
143
 
144
- # TODO(dtroyer): remove this once the shell_class_patch patch is released
145
- # in osc-lib
146
- app_patch = shell_class_name
147
-
148
144
  def setUp(self):
149
145
  super(TestShell, self).setUp()
150
146
  # TODO(dtroyer): remove this once the shell_class_patch patch is
@@ -162,7 +158,6 @@ class TestShell(osc_lib_test_utils.TestShell):
162
158
  )
163
159
  _cmd = cmd_options + " list role"
164
160
  osc_lib_test_utils.fake_execute(_shell, _cmd)
165
- print("_shell: %s" % _shell)
166
161
 
167
162
  self.app.assert_called_with(["list", "role"])
168
163
  self.assertEqual(
@@ -178,7 +173,7 @@ class TestShell(osc_lib_test_utils.TestShell):
178
173
 
179
174
  def _assert_token_auth(self, cmd_options, default_args):
180
175
  with mock.patch(
181
- self.app_patch + ".initialize_app",
176
+ self.shell_class_name + ".initialize_app",
182
177
  self.app,
183
178
  ):
184
179
  _shell = osc_lib_test_utils.make_shell(
@@ -186,7 +181,6 @@ class TestShell(osc_lib_test_utils.TestShell):
186
181
  )
187
182
  _cmd = cmd_options + " list role"
188
183
  osc_lib_test_utils.fake_execute(_shell, _cmd)
189
- print("_shell: %s" % _shell)
190
184
 
191
185
  self.app.assert_called_with(["list", "role"])
192
186
  self.assertEqual(