python-openstackclient 8.0.0__py3-none-any.whl → 8.2.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.
- openstackclient/api/compute_v2.py +2 -2
- openstackclient/api/volume_v2.py +60 -0
- openstackclient/api/volume_v3.py +60 -0
- openstackclient/compute/client.py +5 -0
- openstackclient/compute/v2/console.py +7 -0
- openstackclient/compute/v2/console_connection.py +48 -0
- openstackclient/compute/v2/flavor.py +14 -1
- openstackclient/compute/v2/keypair.py +10 -3
- openstackclient/compute/v2/server.py +76 -13
- openstackclient/compute/v2/server_event.py +1 -1
- openstackclient/identity/common.py +85 -11
- openstackclient/identity/v3/application_credential.py +88 -87
- openstackclient/identity/v3/domain.py +67 -49
- openstackclient/identity/v3/group.py +113 -68
- openstackclient/identity/v3/project.py +42 -20
- openstackclient/identity/v3/role.py +7 -2
- openstackclient/identity/v3/user.py +38 -5
- openstackclient/image/client.py +5 -0
- openstackclient/image/v1/image.py +16 -1
- openstackclient/image/v2/cache.py +10 -6
- openstackclient/image/v2/image.py +59 -12
- openstackclient/image/v2/metadef_objects.py +8 -2
- openstackclient/image/v2/metadef_properties.py +9 -2
- openstackclient/network/client.py +0 -6
- openstackclient/network/v2/floating_ip.py +58 -29
- openstackclient/network/v2/network_qos_rule.py +3 -11
- openstackclient/network/v2/port.py +16 -0
- openstackclient/network/v2/router.py +1 -1
- openstackclient/network/v2/security_group.py +49 -7
- openstackclient/network/v2/security_group_rule.py +18 -1
- openstackclient/shell.py +1 -1
- openstackclient/tests/functional/base.py +5 -1
- openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
- openstackclient/tests/functional/identity/v3/test_access_rule.py +1 -1
- openstackclient/tests/functional/identity/v3/test_application_credential.py +7 -7
- openstackclient/tests/functional/image/v2/test_image.py +36 -14
- openstackclient/tests/functional/volume/v2/test_volume.py +1 -1
- openstackclient/tests/functional/volume/v3/test_volume.py +2 -2
- openstackclient/tests/unit/api/test_volume_v2.py +124 -0
- openstackclient/tests/unit/api/test_volume_v3.py +124 -0
- openstackclient/tests/unit/compute/v2/fakes.py +81 -305
- openstackclient/tests/unit/compute/v2/test_console.py +18 -1
- openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
- openstackclient/tests/unit/compute/v2/test_flavor.py +160 -175
- openstackclient/tests/unit/compute/v2/test_keypair.py +12 -5
- openstackclient/tests/unit/compute/v2/test_server.py +211 -97
- openstackclient/tests/unit/compute/v2/test_server_backup.py +32 -71
- openstackclient/tests/unit/compute/v2/test_server_event.py +2 -2
- openstackclient/tests/unit/compute/v2/test_server_image.py +33 -72
- openstackclient/tests/unit/compute/v2/test_server_migration.py +4 -4
- openstackclient/tests/unit/identity/v3/test_application_credential.py +93 -65
- openstackclient/tests/unit/identity/v3/test_domain.py +117 -107
- openstackclient/tests/unit/identity/v3/test_group.py +353 -202
- openstackclient/tests/unit/identity/v3/test_project.py +46 -53
- openstackclient/tests/unit/identity/v3/test_role.py +2 -8
- openstackclient/tests/unit/identity/v3/test_user.py +86 -6
- openstackclient/tests/unit/image/v1/test_image.py +55 -9
- openstackclient/tests/unit/image/v2/test_image.py +128 -58
- openstackclient/tests/unit/image/v2/test_metadef_objects.py +22 -0
- openstackclient/tests/unit/image/v2/test_metadef_properties.py +24 -10
- openstackclient/tests/unit/network/v2/fakes.py +406 -485
- openstackclient/tests/unit/network/v2/test_floating_ip_network.py +13 -19
- openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
- openstackclient/tests/unit/network/v2/test_ndp_proxy.py +3 -5
- openstackclient/tests/unit/network/v2/test_network.py +4 -4
- openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
- openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
- openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
- openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
- openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
- openstackclient/tests/unit/network/v2/test_port.py +57 -17
- openstackclient/tests/unit/network/v2/test_router.py +73 -57
- openstackclient/tests/unit/network/v2/test_security_group_network.py +31 -27
- openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +1 -3
- openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +82 -39
- openstackclient/tests/unit/volume/v2/fakes.py +1 -2
- openstackclient/tests/unit/volume/v2/test_service.py +57 -91
- openstackclient/tests/unit/volume/v2/test_volume.py +466 -410
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
- openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
- openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
- openstackclient/tests/unit/volume/v3/test_service.py +221 -141
- openstackclient/tests/unit/volume/v3/test_volume.py +569 -534
- openstackclient/tests/unit/volume/v3/test_volume_attachment.py +1 -1
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
- openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +682 -47
- openstackclient/volume/v2/service.py +41 -38
- openstackclient/volume/v2/volume.py +140 -88
- openstackclient/volume/v2/volume_backup.py +9 -3
- openstackclient/volume/v2/volume_snapshot.py +121 -84
- openstackclient/volume/v3/block_storage_log_level.py +22 -28
- openstackclient/volume/v3/service.py +105 -14
- openstackclient/volume/v3/volume.py +287 -99
- openstackclient/volume/v3/volume_backup.py +24 -19
- openstackclient/volume/v3/volume_group.py +1 -1
- openstackclient/volume/v3/volume_snapshot.py +485 -10
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/AUTHORS +13 -0
- python_openstackclient-8.2.0.dist-info/METADATA +264 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/RECORD +104 -98
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/entry_points.txt +7 -6
- python_openstackclient-8.2.0.dist-info/pbr.json +1 -0
- python_openstackclient-8.0.0.dist-info/METADATA +0 -166
- python_openstackclient-8.0.0.dist-info/pbr.json +0 -1
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/WHEEL +0 -0
- {python_openstackclient-8.0.0.dist-info → python_openstackclient-8.2.0.dist-info}/top_level.txt +0 -0
|
@@ -36,28 +36,34 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
36
36
|
project = identity_fakes.FakeProject.create_one_project()
|
|
37
37
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
|
38
38
|
# The security group to be created.
|
|
39
|
-
_security_group = (
|
|
40
|
-
network_fakes.FakeSecurityGroup.create_one_security_group()
|
|
41
|
-
)
|
|
39
|
+
_security_group = network_fakes.create_one_security_group()
|
|
42
40
|
|
|
43
41
|
columns = (
|
|
42
|
+
'created_at',
|
|
44
43
|
'description',
|
|
45
44
|
'id',
|
|
45
|
+
'is_shared',
|
|
46
46
|
'name',
|
|
47
47
|
'project_id',
|
|
48
|
+
'revision_number',
|
|
48
49
|
'rules',
|
|
49
50
|
'stateful',
|
|
50
51
|
'tags',
|
|
52
|
+
'updated_at',
|
|
51
53
|
)
|
|
52
54
|
|
|
53
55
|
data = (
|
|
56
|
+
_security_group.created_at,
|
|
54
57
|
_security_group.description,
|
|
55
58
|
_security_group.id,
|
|
59
|
+
_security_group.is_shared,
|
|
56
60
|
_security_group.name,
|
|
57
61
|
_security_group.project_id,
|
|
62
|
+
_security_group.revision_number,
|
|
58
63
|
security_group.NetworkSecurityGroupRulesColumn([]),
|
|
59
64
|
_security_group.stateful,
|
|
60
65
|
_security_group.tags,
|
|
66
|
+
_security_group.updated_at,
|
|
61
67
|
)
|
|
62
68
|
|
|
63
69
|
def setUp(self):
|
|
@@ -163,7 +169,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
163
169
|
else:
|
|
164
170
|
self.assertFalse(self.network_client.set_tags.called)
|
|
165
171
|
self.assertEqual(self.columns, columns)
|
|
166
|
-
self.
|
|
172
|
+
self.assertEqual(self.data, data)
|
|
167
173
|
|
|
168
174
|
def test_create_with_tags(self):
|
|
169
175
|
self._test_create_with_tag(add_tags=True)
|
|
@@ -174,7 +180,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
174
180
|
|
|
175
181
|
class TestDeleteSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
176
182
|
# The security groups to be deleted.
|
|
177
|
-
_security_groups = network_fakes.
|
|
183
|
+
_security_groups = network_fakes.create_security_groups()
|
|
178
184
|
|
|
179
185
|
def setUp(self):
|
|
180
186
|
super().setUp()
|
|
@@ -184,9 +190,7 @@ class TestDeleteSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
184
190
|
)
|
|
185
191
|
|
|
186
192
|
self.network_client.find_security_group = (
|
|
187
|
-
network_fakes.
|
|
188
|
-
self._security_groups
|
|
189
|
-
)
|
|
193
|
+
network_fakes.get_security_groups(self._security_groups)
|
|
190
194
|
)
|
|
191
195
|
|
|
192
196
|
# Get the command object to test
|
|
@@ -264,9 +268,7 @@ class TestDeleteSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
264
268
|
|
|
265
269
|
class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
266
270
|
# The security group to be listed.
|
|
267
|
-
_security_groups = network_fakes.
|
|
268
|
-
count=3
|
|
269
|
-
)
|
|
271
|
+
_security_groups = network_fakes.create_security_groups(count=3)
|
|
270
272
|
|
|
271
273
|
columns = (
|
|
272
274
|
'ID',
|
|
@@ -274,6 +276,7 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
274
276
|
'Description',
|
|
275
277
|
'Project',
|
|
276
278
|
'Tags',
|
|
279
|
+
'Shared',
|
|
277
280
|
)
|
|
278
281
|
|
|
279
282
|
data = []
|
|
@@ -285,6 +288,7 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
285
288
|
grp.description,
|
|
286
289
|
grp.project_id,
|
|
287
290
|
grp.tags,
|
|
291
|
+
grp.is_shared,
|
|
288
292
|
)
|
|
289
293
|
)
|
|
290
294
|
|
|
@@ -412,10 +416,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
412
416
|
|
|
413
417
|
class TestSetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
414
418
|
# The security group to be set.
|
|
415
|
-
_security_group = (
|
|
416
|
-
|
|
417
|
-
attrs={'tags': ['green', 'red']}
|
|
418
|
-
)
|
|
419
|
+
_security_group = network_fakes.create_one_security_group(
|
|
420
|
+
attrs={'tags': ['green', 'red']}
|
|
419
421
|
)
|
|
420
422
|
|
|
421
423
|
def setUp(self):
|
|
@@ -515,37 +517,41 @@ class TestSetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
515
517
|
|
|
516
518
|
class TestShowSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
517
519
|
# The security group rule to be shown with the group.
|
|
518
|
-
_security_group_rule = (
|
|
519
|
-
network_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
|
|
520
|
-
)
|
|
520
|
+
_security_group_rule = network_fakes.create_one_security_group_rule()
|
|
521
521
|
|
|
522
522
|
# The security group to be shown.
|
|
523
|
-
_security_group = (
|
|
524
|
-
|
|
525
|
-
attrs={'security_group_rules': [_security_group_rule._info]}
|
|
526
|
-
)
|
|
523
|
+
_security_group = network_fakes.create_one_security_group(
|
|
524
|
+
attrs={'security_group_rules': [dict(_security_group_rule)]}
|
|
527
525
|
)
|
|
528
526
|
|
|
529
527
|
columns = (
|
|
528
|
+
'created_at',
|
|
530
529
|
'description',
|
|
531
530
|
'id',
|
|
531
|
+
'is_shared',
|
|
532
532
|
'name',
|
|
533
533
|
'project_id',
|
|
534
|
+
'revision_number',
|
|
534
535
|
'rules',
|
|
535
536
|
'stateful',
|
|
536
537
|
'tags',
|
|
538
|
+
'updated_at',
|
|
537
539
|
)
|
|
538
540
|
|
|
539
541
|
data = (
|
|
542
|
+
_security_group.created_at,
|
|
540
543
|
_security_group.description,
|
|
541
544
|
_security_group.id,
|
|
545
|
+
_security_group.is_shared,
|
|
542
546
|
_security_group.name,
|
|
543
547
|
_security_group.project_id,
|
|
548
|
+
_security_group.revision_number,
|
|
544
549
|
security_group.NetworkSecurityGroupRulesColumn(
|
|
545
|
-
[_security_group_rule
|
|
550
|
+
[dict(_security_group_rule)]
|
|
546
551
|
),
|
|
547
552
|
_security_group.stateful,
|
|
548
553
|
_security_group.tags,
|
|
554
|
+
_security_group.updated_at,
|
|
549
555
|
)
|
|
550
556
|
|
|
551
557
|
def setUp(self):
|
|
@@ -583,10 +589,8 @@ class TestShowSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
|
583
589
|
|
|
584
590
|
class TestUnsetSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|
585
591
|
# The security group to be unset.
|
|
586
|
-
_security_group = (
|
|
587
|
-
|
|
588
|
-
attrs={'tags': ['green', 'red']}
|
|
589
|
-
)
|
|
592
|
+
_security_group = network_fakes.create_one_security_group(
|
|
593
|
+
attrs={'tags': ['green', 'red']}
|
|
590
594
|
)
|
|
591
595
|
|
|
592
596
|
def setUp(self):
|
|
@@ -383,7 +383,6 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
383
383
|
_security_group_rule_tcp = compute_fakes.create_one_security_group_rule(
|
|
384
384
|
{
|
|
385
385
|
'ip_protocol': 'tcp',
|
|
386
|
-
'ethertype': 'IPv4',
|
|
387
386
|
'from_port': 80,
|
|
388
387
|
'to_port': 80,
|
|
389
388
|
'group': {'name': _security_group['name']},
|
|
@@ -392,7 +391,6 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
392
391
|
_security_group_rule_icmp = compute_fakes.create_one_security_group_rule(
|
|
393
392
|
{
|
|
394
393
|
'ip_protocol': 'icmp',
|
|
395
|
-
'ethertype': 'IPv4',
|
|
396
394
|
'from_port': -1,
|
|
397
395
|
'to_port': -1,
|
|
398
396
|
'ip_range': {'cidr': '10.0.2.0/24'},
|
|
@@ -426,7 +424,7 @@ class TestListSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|
|
426
424
|
expected_rule_with_group = (
|
|
427
425
|
rule['id'],
|
|
428
426
|
rule['ip_protocol'],
|
|
429
|
-
|
|
427
|
+
'', # ethertype is a neutron-only thing
|
|
430
428
|
rule['ip_range'],
|
|
431
429
|
rule['port_range'],
|
|
432
430
|
rule['remote_security_group'],
|
|
@@ -40,14 +40,13 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
40
40
|
_security_group_rule = None
|
|
41
41
|
|
|
42
42
|
# The security group that will contain the rule created.
|
|
43
|
-
_security_group = (
|
|
44
|
-
network_fakes.FakeSecurityGroup.create_one_security_group()
|
|
45
|
-
)
|
|
43
|
+
_security_group = network_fakes.create_one_security_group()
|
|
46
44
|
|
|
47
45
|
# The address group to be used in security group rules
|
|
48
46
|
_address_group = network_fakes.create_one_address_group()
|
|
49
47
|
|
|
50
48
|
expected_columns = (
|
|
49
|
+
'created_at',
|
|
51
50
|
'description',
|
|
52
51
|
'direction',
|
|
53
52
|
'ether_type',
|
|
@@ -59,21 +58,22 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
59
58
|
'remote_address_group_id',
|
|
60
59
|
'remote_group_id',
|
|
61
60
|
'remote_ip_prefix',
|
|
61
|
+
'revision_number',
|
|
62
62
|
'security_group_id',
|
|
63
|
+
'updated_at',
|
|
63
64
|
)
|
|
64
65
|
|
|
65
66
|
expected_data = None
|
|
66
67
|
|
|
67
68
|
def _setup_security_group_rule(self, attrs=None):
|
|
68
69
|
self._security_group_rule = (
|
|
69
|
-
network_fakes.
|
|
70
|
-
attrs
|
|
71
|
-
)
|
|
70
|
+
network_fakes.create_one_security_group_rule(attrs)
|
|
72
71
|
)
|
|
73
72
|
self.network_client.create_security_group_rule = mock.Mock(
|
|
74
73
|
return_value=self._security_group_rule
|
|
75
74
|
)
|
|
76
75
|
self.expected_data = (
|
|
76
|
+
self._security_group_rule.created_at,
|
|
77
77
|
self._security_group_rule.description,
|
|
78
78
|
self._security_group_rule.direction,
|
|
79
79
|
self._security_group_rule.ether_type,
|
|
@@ -85,7 +85,9 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
85
85
|
self._security_group_rule.remote_address_group_id,
|
|
86
86
|
self._security_group_rule.remote_group_id,
|
|
87
87
|
self._security_group_rule.remote_ip_prefix,
|
|
88
|
+
self._security_group_rule.revision_number,
|
|
88
89
|
self._security_group_rule.security_group_id,
|
|
90
|
+
self._security_group_rule.updated_at,
|
|
89
91
|
)
|
|
90
92
|
|
|
91
93
|
def setUp(self):
|
|
@@ -963,11 +965,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
963
965
|
|
|
964
966
|
class TestDeleteSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
965
967
|
# The security group rules to be deleted.
|
|
966
|
-
_security_group_rules = (
|
|
967
|
-
network_fakes.FakeSecurityGroupRule.create_security_group_rules(
|
|
968
|
-
count=2
|
|
969
|
-
)
|
|
970
|
-
)
|
|
968
|
+
_security_group_rules = network_fakes.create_security_group_rules(count=2)
|
|
971
969
|
|
|
972
970
|
def setUp(self):
|
|
973
971
|
super().setUp()
|
|
@@ -977,9 +975,7 @@ class TestDeleteSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
977
975
|
)
|
|
978
976
|
|
|
979
977
|
self.network_client.find_security_group_rule = (
|
|
980
|
-
network_fakes.
|
|
981
|
-
self._security_group_rules
|
|
982
|
-
)
|
|
978
|
+
network_fakes.get_security_group_rules(self._security_group_rules)
|
|
983
979
|
)
|
|
984
980
|
|
|
985
981
|
# Get the command object to test
|
|
@@ -1057,33 +1053,27 @@ class TestDeleteSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
1057
1053
|
|
|
1058
1054
|
class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
1059
1055
|
# The security group to hold the rules.
|
|
1060
|
-
_security_group = (
|
|
1061
|
-
network_fakes.FakeSecurityGroup.create_one_security_group()
|
|
1062
|
-
)
|
|
1056
|
+
_security_group = network_fakes.create_one_security_group()
|
|
1063
1057
|
|
|
1064
1058
|
# The security group rule to be listed.
|
|
1065
|
-
_security_group_rule_tcp = (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
)
|
|
1059
|
+
_security_group_rule_tcp = network_fakes.create_one_security_group_rule(
|
|
1060
|
+
{
|
|
1061
|
+
'protocol': 'tcp',
|
|
1062
|
+
'port_range_max': 80,
|
|
1063
|
+
'port_range_min': 80,
|
|
1064
|
+
'security_group_id': _security_group.id,
|
|
1065
|
+
}
|
|
1074
1066
|
)
|
|
1075
|
-
_security_group_rule_icmp = (
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
)
|
|
1067
|
+
_security_group_rule_icmp = network_fakes.create_one_security_group_rule(
|
|
1068
|
+
{
|
|
1069
|
+
'protocol': 'icmp',
|
|
1070
|
+
'remote_ip_prefix': '10.0.2.0/24',
|
|
1071
|
+
'security_group_id': _security_group.id,
|
|
1072
|
+
}
|
|
1083
1073
|
)
|
|
1084
1074
|
_security_group.security_group_rules = [
|
|
1085
|
-
_security_group_rule_tcp
|
|
1086
|
-
_security_group_rule_icmp
|
|
1075
|
+
dict(_security_group_rule_tcp),
|
|
1076
|
+
dict(_security_group_rule_icmp),
|
|
1087
1077
|
]
|
|
1088
1078
|
_security_group_rules = [
|
|
1089
1079
|
_security_group_rule_tcp,
|
|
@@ -1261,14 +1251,62 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
1261
1251
|
self.assertEqual(self.expected_columns_no_group, columns)
|
|
1262
1252
|
self.assertEqual(self.expected_data_no_group, list(data))
|
|
1263
1253
|
|
|
1254
|
+
def test_list_with_project(self):
|
|
1255
|
+
project = identity_fakes.FakeProject.create_one_project()
|
|
1256
|
+
self._security_group_rule_tcp.port_range_min = 80
|
|
1257
|
+
self.projects_mock.get.return_value = project
|
|
1258
|
+
|
|
1259
|
+
arglist = [
|
|
1260
|
+
'--project',
|
|
1261
|
+
project.id,
|
|
1262
|
+
]
|
|
1263
|
+
verifylist = [
|
|
1264
|
+
('project', project.id),
|
|
1265
|
+
]
|
|
1266
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
1267
|
+
|
|
1268
|
+
columns, data = self.cmd.take_action(parsed_args)
|
|
1269
|
+
filters = {'tenant_id': project.id, 'project_id': project.id}
|
|
1270
|
+
|
|
1271
|
+
self.network_client.security_group_rules.assert_called_once_with(
|
|
1272
|
+
**filters
|
|
1273
|
+
)
|
|
1274
|
+
self.assertEqual(self.expected_columns_no_group, columns)
|
|
1275
|
+
self.assertEqual(self.expected_data_no_group, list(data))
|
|
1276
|
+
|
|
1277
|
+
def test_list_with_project_domain(self):
|
|
1278
|
+
project = identity_fakes.FakeProject.create_one_project()
|
|
1279
|
+
self._security_group_rule_tcp.port_range_min = 80
|
|
1280
|
+
self.projects_mock.get.return_value = project
|
|
1281
|
+
|
|
1282
|
+
arglist = [
|
|
1283
|
+
'--project',
|
|
1284
|
+
project.id,
|
|
1285
|
+
'--project-domain',
|
|
1286
|
+
project.domain_id,
|
|
1287
|
+
]
|
|
1288
|
+
verifylist = [
|
|
1289
|
+
('project', project.id),
|
|
1290
|
+
('project_domain', project.domain_id),
|
|
1291
|
+
]
|
|
1292
|
+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
1293
|
+
|
|
1294
|
+
columns, data = self.cmd.take_action(parsed_args)
|
|
1295
|
+
filters = {'tenant_id': project.id, 'project_id': project.id}
|
|
1296
|
+
|
|
1297
|
+
self.network_client.security_group_rules.assert_called_once_with(
|
|
1298
|
+
**filters
|
|
1299
|
+
)
|
|
1300
|
+
self.assertEqual(self.expected_columns_no_group, columns)
|
|
1301
|
+
self.assertEqual(self.expected_data_no_group, list(data))
|
|
1302
|
+
|
|
1264
1303
|
|
|
1265
1304
|
class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
1266
1305
|
# The security group rule to be shown.
|
|
1267
|
-
_security_group_rule = (
|
|
1268
|
-
network_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
|
|
1269
|
-
)
|
|
1306
|
+
_security_group_rule = network_fakes.create_one_security_group_rule()
|
|
1270
1307
|
|
|
1271
1308
|
columns = (
|
|
1309
|
+
'created_at',
|
|
1272
1310
|
'description',
|
|
1273
1311
|
'direction',
|
|
1274
1312
|
'ether_type',
|
|
@@ -1280,10 +1318,13 @@ class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
1280
1318
|
'remote_address_group_id',
|
|
1281
1319
|
'remote_group_id',
|
|
1282
1320
|
'remote_ip_prefix',
|
|
1321
|
+
'revision_number',
|
|
1283
1322
|
'security_group_id',
|
|
1323
|
+
'updated_at',
|
|
1284
1324
|
)
|
|
1285
1325
|
|
|
1286
1326
|
data = (
|
|
1327
|
+
_security_group_rule.created_at,
|
|
1287
1328
|
_security_group_rule.description,
|
|
1288
1329
|
_security_group_rule.direction,
|
|
1289
1330
|
_security_group_rule.ether_type,
|
|
@@ -1295,7 +1336,9 @@ class TestShowSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|
|
1295
1336
|
_security_group_rule.remote_address_group_id,
|
|
1296
1337
|
_security_group_rule.remote_group_id,
|
|
1297
1338
|
_security_group_rule.remote_ip_prefix,
|
|
1339
|
+
_security_group_rule.revision_number,
|
|
1298
1340
|
_security_group_rule.security_group_id,
|
|
1341
|
+
_security_group_rule.updated_at,
|
|
1299
1342
|
)
|
|
1300
1343
|
|
|
1301
1344
|
def setUp(self):
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
import copy
|
|
16
16
|
import random
|
|
17
|
-
import typing as ty
|
|
18
17
|
from unittest import mock
|
|
19
18
|
import uuid
|
|
20
19
|
|
|
@@ -92,7 +91,7 @@ class FakeClientMixin:
|
|
|
92
91
|
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
|
|
93
92
|
self.set_volume_api_version() # default to the lowest
|
|
94
93
|
|
|
95
|
-
def set_volume_api_version(self, version:
|
|
94
|
+
def set_volume_api_version(self, version: str | None = None):
|
|
96
95
|
"""Set a fake block storage API version.
|
|
97
96
|
|
|
98
97
|
:param version: The fake microversion to "support". This must be None
|
|
@@ -12,108 +12,83 @@
|
|
|
12
12
|
# under the License.
|
|
13
13
|
#
|
|
14
14
|
|
|
15
|
+
from unittest import mock
|
|
16
|
+
|
|
17
|
+
from openstack.block_storage.v2 import service as _service
|
|
18
|
+
from openstack.test import fakes as sdk_fakes
|
|
15
19
|
from osc_lib import exceptions
|
|
16
20
|
|
|
17
21
|
from openstackclient.tests.unit.volume.v2 import fakes as volume_fakes
|
|
18
22
|
from openstackclient.volume.v2 import service
|
|
19
23
|
|
|
20
24
|
|
|
21
|
-
class
|
|
25
|
+
class TestServiceList(volume_fakes.TestVolume):
|
|
22
26
|
def setUp(self):
|
|
23
27
|
super().setUp()
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
self.
|
|
27
|
-
self.service_mock.reset_mock()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class TestServiceList(TestService):
|
|
31
|
-
# The service to be listed
|
|
32
|
-
services = volume_fakes.create_one_service()
|
|
29
|
+
self.service = sdk_fakes.generate_fake_resource(_service.Service)
|
|
30
|
+
self.volume_sdk_client.services.return_value = [self.service]
|
|
33
31
|
|
|
34
|
-
def setUp(self):
|
|
35
|
-
super().setUp()
|
|
36
|
-
|
|
37
|
-
self.service_mock.list.return_value = [self.services]
|
|
38
|
-
|
|
39
|
-
# Get the command object to test
|
|
40
32
|
self.cmd = service.ListService(self.app, None)
|
|
41
33
|
|
|
42
34
|
def test_service_list(self):
|
|
43
35
|
arglist = [
|
|
44
36
|
'--host',
|
|
45
|
-
self.
|
|
37
|
+
self.service.host,
|
|
46
38
|
'--service',
|
|
47
|
-
self.
|
|
39
|
+
self.service.binary,
|
|
48
40
|
]
|
|
49
41
|
verifylist = [
|
|
50
|
-
('host', self.
|
|
51
|
-
('service', self.
|
|
42
|
+
('host', self.service.host),
|
|
43
|
+
('service', self.service.binary),
|
|
52
44
|
]
|
|
53
45
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
54
46
|
|
|
55
|
-
# In base command class Lister in cliff, abstract method take_action()
|
|
56
|
-
# returns a tuple containing the column names and an iterable
|
|
57
|
-
# containing the data to be listed.
|
|
58
47
|
columns, data = self.cmd.take_action(parsed_args)
|
|
59
48
|
|
|
60
|
-
expected_columns =
|
|
49
|
+
expected_columns = (
|
|
61
50
|
'Binary',
|
|
62
51
|
'Host',
|
|
63
52
|
'Zone',
|
|
64
53
|
'Status',
|
|
65
54
|
'State',
|
|
66
55
|
'Updated At',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
# confirming if all expected columns are present in the result.
|
|
70
|
-
self.assertEqual(expected_columns, columns)
|
|
71
|
-
|
|
56
|
+
)
|
|
72
57
|
datalist = (
|
|
73
58
|
(
|
|
74
|
-
self.
|
|
75
|
-
self.
|
|
76
|
-
self.
|
|
77
|
-
self.
|
|
78
|
-
self.
|
|
79
|
-
self.
|
|
59
|
+
self.service.binary,
|
|
60
|
+
self.service.host,
|
|
61
|
+
self.service.availability_zone,
|
|
62
|
+
self.service.status,
|
|
63
|
+
self.service.state,
|
|
64
|
+
self.service.updated_at,
|
|
80
65
|
),
|
|
81
66
|
)
|
|
82
|
-
|
|
83
|
-
# confirming if all expected values are present in the result.
|
|
67
|
+
self.assertEqual(expected_columns, columns)
|
|
84
68
|
self.assertEqual(datalist, tuple(data))
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
self.services.host,
|
|
89
|
-
self.services.binary,
|
|
69
|
+
self.volume_sdk_client.services.assert_called_with(
|
|
70
|
+
host=self.service.host,
|
|
71
|
+
binary=self.service.binary,
|
|
90
72
|
)
|
|
91
73
|
|
|
92
|
-
# checking if prohibited columns are present in output
|
|
93
|
-
self.assertNotIn("Disabled Reason", columns)
|
|
94
|
-
self.assertNotIn(self.services.disabled_reason, tuple(data))
|
|
95
|
-
|
|
96
74
|
def test_service_list_with_long_option(self):
|
|
97
75
|
arglist = [
|
|
98
76
|
'--host',
|
|
99
|
-
self.
|
|
77
|
+
self.service.host,
|
|
100
78
|
'--service',
|
|
101
|
-
self.
|
|
79
|
+
self.service.binary,
|
|
102
80
|
'--long',
|
|
103
81
|
]
|
|
104
82
|
verifylist = [
|
|
105
|
-
('host', self.
|
|
106
|
-
('service', self.
|
|
83
|
+
('host', self.service.host),
|
|
84
|
+
('service', self.service.binary),
|
|
107
85
|
('long', True),
|
|
108
86
|
]
|
|
109
87
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
110
88
|
|
|
111
|
-
# In base command class Lister in cliff, abstract method take_action()
|
|
112
|
-
# returns a tuple containing the column names and an iterable
|
|
113
|
-
# containing the data to be listed.
|
|
114
89
|
columns, data = self.cmd.take_action(parsed_args)
|
|
115
90
|
|
|
116
|
-
expected_columns =
|
|
91
|
+
expected_columns = (
|
|
117
92
|
'Binary',
|
|
118
93
|
'Host',
|
|
119
94
|
'Zone',
|
|
@@ -121,41 +96,34 @@ class TestServiceList(TestService):
|
|
|
121
96
|
'State',
|
|
122
97
|
'Updated At',
|
|
123
98
|
'Disabled Reason',
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
# confirming if all expected columns are present in the result.
|
|
127
|
-
self.assertEqual(expected_columns, columns)
|
|
128
|
-
|
|
99
|
+
)
|
|
129
100
|
datalist = (
|
|
130
101
|
(
|
|
131
|
-
self.
|
|
132
|
-
self.
|
|
133
|
-
self.
|
|
134
|
-
self.
|
|
135
|
-
self.
|
|
136
|
-
self.
|
|
137
|
-
self.
|
|
102
|
+
self.service.binary,
|
|
103
|
+
self.service.host,
|
|
104
|
+
self.service.availability_zone,
|
|
105
|
+
self.service.status,
|
|
106
|
+
self.service.state,
|
|
107
|
+
self.service.updated_at,
|
|
108
|
+
self.service.disabled_reason,
|
|
138
109
|
),
|
|
139
110
|
)
|
|
140
|
-
|
|
141
|
-
# confirming if all expected values are present in the result.
|
|
111
|
+
self.assertEqual(expected_columns, columns)
|
|
142
112
|
self.assertEqual(datalist, tuple(data))
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
self.
|
|
146
|
-
self.services.binary,
|
|
113
|
+
self.volume_sdk_client.services.assert_called_with(
|
|
114
|
+
host=self.service.host,
|
|
115
|
+
binary=self.service.binary,
|
|
147
116
|
)
|
|
148
117
|
|
|
149
118
|
|
|
150
|
-
class TestServiceSet(
|
|
151
|
-
service = volume_fakes.create_one_service()
|
|
152
|
-
|
|
119
|
+
class TestServiceSet(volume_fakes.TestVolume):
|
|
153
120
|
def setUp(self):
|
|
154
121
|
super().setUp()
|
|
155
122
|
|
|
156
|
-
self.
|
|
157
|
-
self.
|
|
158
|
-
self.
|
|
123
|
+
self.service = sdk_fakes.generate_fake_resource(_service.Service)
|
|
124
|
+
self.service.enable = mock.Mock(autospec=True)
|
|
125
|
+
self.service.disable = mock.Mock(autospec=True)
|
|
126
|
+
self.volume_sdk_client.find_service.return_value = self.service
|
|
159
127
|
|
|
160
128
|
self.cmd = service.SetService(self.app, None)
|
|
161
129
|
|
|
@@ -171,9 +139,8 @@ class TestServiceSet(TestService):
|
|
|
171
139
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
172
140
|
result = self.cmd.take_action(parsed_args)
|
|
173
141
|
|
|
174
|
-
self.
|
|
175
|
-
self.
|
|
176
|
-
self.service_mock.disable_log_reason.assert_not_called()
|
|
142
|
+
self.service.enable.assert_not_called()
|
|
143
|
+
self.service.disable.assert_not_called()
|
|
177
144
|
self.assertIsNone(result)
|
|
178
145
|
|
|
179
146
|
def test_service_set_enable(self):
|
|
@@ -191,11 +158,8 @@ class TestServiceSet(TestService):
|
|
|
191
158
|
|
|
192
159
|
result = self.cmd.take_action(parsed_args)
|
|
193
160
|
|
|
194
|
-
self.
|
|
195
|
-
|
|
196
|
-
)
|
|
197
|
-
self.service_mock.disable.assert_not_called()
|
|
198
|
-
self.service_mock.disable_log_reason.assert_not_called()
|
|
161
|
+
self.service.enable.assert_called_with(self.volume_sdk_client)
|
|
162
|
+
self.service.disable.assert_not_called()
|
|
199
163
|
self.assertIsNone(result)
|
|
200
164
|
|
|
201
165
|
def test_service_set_disable(self):
|
|
@@ -213,11 +177,10 @@ class TestServiceSet(TestService):
|
|
|
213
177
|
|
|
214
178
|
result = self.cmd.take_action(parsed_args)
|
|
215
179
|
|
|
216
|
-
self.
|
|
217
|
-
|
|
180
|
+
self.service.enable.assert_not_called()
|
|
181
|
+
self.service.disable.assert_called_with(
|
|
182
|
+
self.volume_sdk_client, reason=None
|
|
218
183
|
)
|
|
219
|
-
self.service_mock.enable.assert_not_called()
|
|
220
|
-
self.service_mock.disable_log_reason.assert_not_called()
|
|
221
184
|
self.assertIsNone(result)
|
|
222
185
|
|
|
223
186
|
def test_service_set_disable_with_reason(self):
|
|
@@ -239,8 +202,9 @@ class TestServiceSet(TestService):
|
|
|
239
202
|
|
|
240
203
|
result = self.cmd.take_action(parsed_args)
|
|
241
204
|
|
|
242
|
-
self.
|
|
243
|
-
|
|
205
|
+
self.service.enable.assert_not_called()
|
|
206
|
+
self.service.disable.assert_called_with(
|
|
207
|
+
self.volume_sdk_client, reason=reason
|
|
244
208
|
)
|
|
245
209
|
self.assertIsNone(result)
|
|
246
210
|
|
|
@@ -258,6 +222,7 @@ class TestServiceSet(TestService):
|
|
|
258
222
|
('service', self.service.binary),
|
|
259
223
|
]
|
|
260
224
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
225
|
+
|
|
261
226
|
try:
|
|
262
227
|
self.cmd.take_action(parsed_args)
|
|
263
228
|
self.fail("CommandError should be raised.")
|
|
@@ -284,6 +249,7 @@ class TestServiceSet(TestService):
|
|
|
284
249
|
('service', self.service.binary),
|
|
285
250
|
]
|
|
286
251
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
|
252
|
+
|
|
287
253
|
try:
|
|
288
254
|
self.cmd.take_action(parsed_args)
|
|
289
255
|
self.fail("CommandError should be raised.")
|