python-openstackclient 7.2.0__py3-none-any.whl → 7.3.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/common/clientmanager.py +6 -1
- openstackclient/common/limits.py +1 -1
- openstackclient/common/quota.py +7 -2
- openstackclient/compute/v2/server.py +38 -22
- openstackclient/compute/v2/usage.py +2 -2
- openstackclient/identity/common.py +22 -34
- openstackclient/identity/v3/credential.py +45 -28
- openstackclient/identity/v3/limit.py +15 -0
- openstackclient/identity/v3/region.py +23 -22
- openstackclient/identity/v3/registered_limit.py +18 -0
- openstackclient/identity/v3/role.py +287 -117
- openstackclient/identity/v3/role_assignment.py +1 -1
- openstackclient/identity/v3/service_provider.py +95 -45
- openstackclient/identity/v3/trust.py +114 -75
- openstackclient/image/v2/image.py +3 -0
- openstackclient/network/v2/network.py +33 -0
- openstackclient/network/v2/network_flavor_profile.py +1 -17
- openstackclient/network/v2/port.py +73 -19
- openstackclient/tests/functional/compute/v2/test_server.py +87 -1
- openstackclient/tests/functional/identity/v3/common.py +1 -1
- openstackclient/tests/functional/identity/v3/test_application_credential.py +2 -1
- openstackclient/tests/functional/identity/v3/test_role.py +24 -0
- openstackclient/tests/functional/identity/v3/test_role_assignment.py +8 -0
- openstackclient/tests/functional/identity/v3/test_service_provider.py +1 -5
- openstackclient/tests/functional/network/v2/test_port.py +28 -1
- openstackclient/tests/unit/compute/v2/fakes.py +0 -304
- openstackclient/tests/unit/compute/v2/test_aggregate.py +40 -31
- openstackclient/tests/unit/compute/v2/test_console.py +7 -3
- openstackclient/tests/unit/compute/v2/test_hypervisor.py +60 -53
- openstackclient/tests/unit/compute/v2/test_keypair.py +57 -69
- openstackclient/tests/unit/compute/v2/test_server.py +63 -5
- openstackclient/tests/unit/compute/v2/test_server_group.py +99 -105
- openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -5
- openstackclient/tests/unit/compute/v2/test_service.py +83 -37
- openstackclient/tests/unit/compute/v2/test_usage.py +12 -7
- openstackclient/tests/unit/identity/v2_0/test_catalog.py +3 -6
- openstackclient/tests/unit/identity/v2_0/test_role.py +1 -2
- openstackclient/tests/unit/identity/v2_0/test_role_assignment.py +2 -1
- openstackclient/tests/unit/identity/v2_0/test_token.py +6 -20
- openstackclient/tests/unit/identity/v3/test_catalog.py +2 -5
- openstackclient/tests/unit/identity/v3/test_credential.py +74 -63
- openstackclient/tests/unit/identity/v3/test_project.py +1 -3
- openstackclient/tests/unit/identity/v3/test_region.py +74 -96
- openstackclient/tests/unit/identity/v3/test_role.py +679 -603
- openstackclient/tests/unit/identity/v3/test_role_assignment.py +263 -1
- openstackclient/tests/unit/identity/v3/test_service_provider.py +159 -209
- openstackclient/tests/unit/identity/v3/test_token.py +5 -20
- openstackclient/tests/unit/identity/v3/test_trust.py +137 -155
- openstackclient/tests/unit/image/v2/test_image.py +6 -0
- openstackclient/tests/unit/network/v2/fakes.py +3 -0
- openstackclient/tests/unit/network/v2/test_network.py +25 -0
- openstackclient/tests/unit/network/v2/test_network_flavor_profile.py +0 -35
- openstackclient/tests/unit/network/v2/test_port.py +129 -16
- openstackclient/tests/unit/utils.py +8 -2
- openstackclient/tests/unit/volume/v2/test_volume_backup.py +31 -13
- openstackclient/tests/unit/volume/v3/test_volume_backup.py +34 -13
- openstackclient/volume/v2/volume_backup.py +11 -2
- openstackclient/volume/v3/volume_backup.py +13 -2
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/AUTHORS +2 -0
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/METADATA +14 -16
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/RECORD +66 -66
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/WHEEL +1 -1
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/entry_points.txt +0 -1
- python_openstackclient-7.3.0.dist-info/pbr.json +1 -0
- python_openstackclient-7.2.0.dist-info/pbr.json +0 -1
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/LICENSE +0 -0
- {python_openstackclient-7.2.0.dist-info → python_openstackclient-7.3.0.dist-info}/top_level.txt +0 -0
|
@@ -21,21 +21,15 @@ import uuid
|
|
|
21
21
|
|
|
22
22
|
from keystoneauth1 import discover
|
|
23
23
|
from openstack.compute.v2 import _proxy
|
|
24
|
-
from openstack.compute.v2 import aggregate as _aggregate
|
|
25
24
|
from openstack.compute.v2 import availability_zone as _availability_zone
|
|
26
25
|
from openstack.compute.v2 import extension as _extension
|
|
27
26
|
from openstack.compute.v2 import flavor as _flavor
|
|
28
|
-
from openstack.compute.v2 import hypervisor as _hypervisor
|
|
29
|
-
from openstack.compute.v2 import keypair as _keypair
|
|
30
27
|
from openstack.compute.v2 import limits as _limits
|
|
31
28
|
from openstack.compute.v2 import migration as _migration
|
|
32
29
|
from openstack.compute.v2 import server as _server
|
|
33
30
|
from openstack.compute.v2 import server_action as _server_action
|
|
34
|
-
from openstack.compute.v2 import server_group as _server_group
|
|
35
31
|
from openstack.compute.v2 import server_interface as _server_interface
|
|
36
32
|
from openstack.compute.v2 import server_migration as _server_migration
|
|
37
|
-
from openstack.compute.v2 import service as _service
|
|
38
|
-
from openstack.compute.v2 import usage as _usage
|
|
39
33
|
from openstack.compute.v2 import volume_attachment as _volume_attachment
|
|
40
34
|
|
|
41
35
|
from openstackclient.tests.unit import fakes
|
|
@@ -142,63 +136,6 @@ class TestComputev2(
|
|
|
142
136
|
): ...
|
|
143
137
|
|
|
144
138
|
|
|
145
|
-
def create_one_aggregate(attrs=None):
|
|
146
|
-
"""Create a fake aggregate.
|
|
147
|
-
|
|
148
|
-
:param dict attrs: A dictionary with all attributes
|
|
149
|
-
:return: A fake openstack.compute.v2.aggregate.Aggregate object
|
|
150
|
-
"""
|
|
151
|
-
attrs = attrs or {}
|
|
152
|
-
|
|
153
|
-
# Set default attribute
|
|
154
|
-
aggregate_info = {
|
|
155
|
-
"name": "aggregate-name-" + uuid.uuid4().hex,
|
|
156
|
-
"availability_zone": "ag_zone",
|
|
157
|
-
"hosts": [],
|
|
158
|
-
"id": "aggregate-id-" + uuid.uuid4().hex,
|
|
159
|
-
"metadata": {
|
|
160
|
-
"availability_zone": "ag_zone",
|
|
161
|
-
"key1": "value1",
|
|
162
|
-
},
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
# Overwrite default attributes.
|
|
166
|
-
aggregate_info.update(attrs)
|
|
167
|
-
|
|
168
|
-
aggregate = _aggregate.Aggregate(**aggregate_info)
|
|
169
|
-
return aggregate
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def create_aggregates(attrs=None, count=2):
|
|
173
|
-
"""Create multiple fake aggregates.
|
|
174
|
-
|
|
175
|
-
:param dict attrs: A dictionary with all attributes
|
|
176
|
-
:param int count: The number of aggregates to fake
|
|
177
|
-
:return: A list of fake openstack.compute.v2.aggregate.Aggregate objects
|
|
178
|
-
"""
|
|
179
|
-
aggregates = []
|
|
180
|
-
for i in range(0, count):
|
|
181
|
-
aggregates.append(create_one_aggregate(attrs))
|
|
182
|
-
|
|
183
|
-
return aggregates
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def get_aggregates(aggregates=None, count=2):
|
|
187
|
-
"""Get an iterable MagicMock object with a list of faked aggregates.
|
|
188
|
-
|
|
189
|
-
If aggregates list is provided, then initialize the Mock object
|
|
190
|
-
with the list. Otherwise create one.
|
|
191
|
-
|
|
192
|
-
:return: A list of fake openstack.compute.v2.aggregate.Aggregate objects
|
|
193
|
-
:param int count: The number of aggregates to fake
|
|
194
|
-
:return: An iterable Mock object with side_effect set to a list of faked
|
|
195
|
-
aggregates
|
|
196
|
-
"""
|
|
197
|
-
if aggregates is None:
|
|
198
|
-
aggregates = create_aggregates(count)
|
|
199
|
-
return mock.Mock(side_effect=aggregates)
|
|
200
|
-
|
|
201
|
-
|
|
202
139
|
def create_one_agent(attrs=None):
|
|
203
140
|
"""Create a fake agent.
|
|
204
141
|
|
|
@@ -544,51 +481,6 @@ def create_one_server_action(attrs=None):
|
|
|
544
481
|
return server_action
|
|
545
482
|
|
|
546
483
|
|
|
547
|
-
def create_one_service(attrs=None):
|
|
548
|
-
"""Create a fake service.
|
|
549
|
-
|
|
550
|
-
:param dict attrs: A dictionary with all attributes
|
|
551
|
-
:return: A fake openstack.compute.v2.service.Service object
|
|
552
|
-
"""
|
|
553
|
-
attrs = attrs or {}
|
|
554
|
-
|
|
555
|
-
# Set default attributes.
|
|
556
|
-
service_info = {
|
|
557
|
-
'id': 'id-' + uuid.uuid4().hex,
|
|
558
|
-
'host': 'host-' + uuid.uuid4().hex,
|
|
559
|
-
'binary': 'binary-' + uuid.uuid4().hex,
|
|
560
|
-
'status': 'enabled',
|
|
561
|
-
'availability_zone': 'zone-' + uuid.uuid4().hex,
|
|
562
|
-
'state': 'state-' + uuid.uuid4().hex,
|
|
563
|
-
'updated_at': 'time-' + uuid.uuid4().hex,
|
|
564
|
-
'disabled_reason': 'earthquake',
|
|
565
|
-
# Introduced in API microversion 2.11
|
|
566
|
-
'is_forced_down': False,
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
# Overwrite default attributes.
|
|
570
|
-
service_info.update(attrs)
|
|
571
|
-
|
|
572
|
-
return _service.Service(**service_info)
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
def create_services(attrs=None, count=2):
|
|
576
|
-
"""Create multiple fake services.
|
|
577
|
-
|
|
578
|
-
:param dict attrs:
|
|
579
|
-
A dictionary with all attributes
|
|
580
|
-
:param int count:
|
|
581
|
-
The number of services to fake
|
|
582
|
-
:return:
|
|
583
|
-
A list of FakeResource objects faking the services
|
|
584
|
-
"""
|
|
585
|
-
services = []
|
|
586
|
-
for i in range(0, count):
|
|
587
|
-
services.append(create_one_service(attrs))
|
|
588
|
-
|
|
589
|
-
return services
|
|
590
|
-
|
|
591
|
-
|
|
592
484
|
def create_one_flavor(attrs=None):
|
|
593
485
|
"""Create a fake flavor.
|
|
594
486
|
|
|
@@ -678,61 +570,6 @@ def create_one_flavor_access(attrs=None):
|
|
|
678
570
|
return flavor_access
|
|
679
571
|
|
|
680
572
|
|
|
681
|
-
def create_one_keypair(attrs=None):
|
|
682
|
-
"""Create a fake keypair
|
|
683
|
-
|
|
684
|
-
:param dict attrs: A dictionary with all attributes
|
|
685
|
-
:return: A fake openstack.compute.v2.keypair.Keypair object
|
|
686
|
-
"""
|
|
687
|
-
attrs = attrs or {}
|
|
688
|
-
|
|
689
|
-
# Set default attributes.
|
|
690
|
-
keypair_info = {
|
|
691
|
-
'name': 'keypair-name-' + uuid.uuid4().hex,
|
|
692
|
-
'type': 'ssh',
|
|
693
|
-
'fingerprint': 'dummy',
|
|
694
|
-
'public_key': 'dummy',
|
|
695
|
-
'user_id': 'user',
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
# Overwrite default attributes.
|
|
699
|
-
keypair_info.update(attrs)
|
|
700
|
-
|
|
701
|
-
return _keypair.Keypair(**keypair_info)
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
def create_keypairs(attrs=None, count=2):
|
|
705
|
-
"""Create multiple fake keypairs.
|
|
706
|
-
|
|
707
|
-
:param dict attrs: A dictionary with all attributes
|
|
708
|
-
:param int count: The number of keypairs to fake
|
|
709
|
-
:return: A list of fake openstack.compute.v2.keypair.Keypair objects
|
|
710
|
-
"""
|
|
711
|
-
|
|
712
|
-
keypairs = []
|
|
713
|
-
for i in range(0, count):
|
|
714
|
-
keypairs.append(create_one_keypair(attrs))
|
|
715
|
-
|
|
716
|
-
return keypairs
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
def get_keypairs(keypairs=None, count=2):
|
|
720
|
-
"""Get an iterable MagicMock object with a list of faked keypairs.
|
|
721
|
-
|
|
722
|
-
If keypairs list is provided, then initialize the Mock object with the
|
|
723
|
-
list. Otherwise create one.
|
|
724
|
-
|
|
725
|
-
:param list keypairs: A list of fake openstack.compute.v2.keypair.Keypair
|
|
726
|
-
objects
|
|
727
|
-
:param int count: The number of keypairs to fake
|
|
728
|
-
:return: An iterable Mock object with side_effect set to a list of faked
|
|
729
|
-
keypairs
|
|
730
|
-
"""
|
|
731
|
-
if keypairs is None:
|
|
732
|
-
keypairs = create_keypairs(count)
|
|
733
|
-
return mock.Mock(side_effect=keypairs)
|
|
734
|
-
|
|
735
|
-
|
|
736
573
|
def create_one_availability_zone(attrs=None):
|
|
737
574
|
"""Create a fake AZ.
|
|
738
575
|
|
|
@@ -970,62 +807,6 @@ def get_networks(networks=None, count=2):
|
|
|
970
807
|
return mock.Mock(side_effect=networks)
|
|
971
808
|
|
|
972
809
|
|
|
973
|
-
def create_one_usage(attrs=None):
|
|
974
|
-
"""Create a fake usage.
|
|
975
|
-
|
|
976
|
-
:param dict attrs:
|
|
977
|
-
A dictionary with all attributes
|
|
978
|
-
:return:
|
|
979
|
-
A FakeResource object, with tenant_id and other attributes
|
|
980
|
-
"""
|
|
981
|
-
if attrs is None:
|
|
982
|
-
attrs = {}
|
|
983
|
-
|
|
984
|
-
# Set default attributes.
|
|
985
|
-
usage_info = {
|
|
986
|
-
'project_id': 'usage-tenant-id-' + uuid.uuid4().hex,
|
|
987
|
-
'total_memory_mb_usage': 512.0,
|
|
988
|
-
'total_vcpus_usage': 1.0,
|
|
989
|
-
'total_local_gb_usage': 1.0,
|
|
990
|
-
'server_usages': [
|
|
991
|
-
{
|
|
992
|
-
'ended_at': None,
|
|
993
|
-
'flavor': 'usage-flavor-' + uuid.uuid4().hex,
|
|
994
|
-
'hours': 1.0,
|
|
995
|
-
'local_gb': 1,
|
|
996
|
-
'memory_mb': 512,
|
|
997
|
-
'name': 'usage-name-' + uuid.uuid4().hex,
|
|
998
|
-
'instance_id': uuid.uuid4().hex,
|
|
999
|
-
'state': 'active',
|
|
1000
|
-
'uptime': 3600,
|
|
1001
|
-
'vcpus': 1,
|
|
1002
|
-
}
|
|
1003
|
-
],
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
# Overwrite default attributes.
|
|
1007
|
-
usage_info.update(attrs)
|
|
1008
|
-
|
|
1009
|
-
return _usage.Usage(**usage_info)
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
def create_usages(attrs=None, count=2):
|
|
1013
|
-
"""Create multiple fake services.
|
|
1014
|
-
|
|
1015
|
-
:param dict attrs:
|
|
1016
|
-
A dictionary with all attributes
|
|
1017
|
-
:param int count:
|
|
1018
|
-
The number of services to fake
|
|
1019
|
-
:return:
|
|
1020
|
-
A list of FakeResource objects faking the services
|
|
1021
|
-
"""
|
|
1022
|
-
usages = []
|
|
1023
|
-
for i in range(0, count):
|
|
1024
|
-
usages.append(create_one_usage(attrs))
|
|
1025
|
-
|
|
1026
|
-
return usages
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
810
|
def create_limits(attrs=None):
|
|
1030
811
|
"""Create a fake limits object."""
|
|
1031
812
|
attrs = attrs or {}
|
|
@@ -1237,91 +1018,6 @@ def create_volume_attachments(attrs=None, count=2):
|
|
|
1237
1018
|
return volume_attachments
|
|
1238
1019
|
|
|
1239
1020
|
|
|
1240
|
-
def create_one_hypervisor(attrs=None):
|
|
1241
|
-
"""Create a fake hypervisor.
|
|
1242
|
-
|
|
1243
|
-
:param dict attrs: A dictionary with all attributes
|
|
1244
|
-
:return: A fake openstack.compute.v2.hypervisor.Hypervisor object
|
|
1245
|
-
"""
|
|
1246
|
-
attrs = attrs or {}
|
|
1247
|
-
|
|
1248
|
-
# Set default attributes.
|
|
1249
|
-
hypervisor_info = {
|
|
1250
|
-
'id': 'hypervisor-id-' + uuid.uuid4().hex,
|
|
1251
|
-
'hypervisor_hostname': 'hypervisor-hostname-' + uuid.uuid4().hex,
|
|
1252
|
-
'status': 'enabled',
|
|
1253
|
-
'host_ip': '192.168.0.10',
|
|
1254
|
-
'cpu_info': {
|
|
1255
|
-
'aaa': 'aaa',
|
|
1256
|
-
},
|
|
1257
|
-
'free_disk_gb': 50,
|
|
1258
|
-
'hypervisor_version': 2004001,
|
|
1259
|
-
'disk_available_least': 50,
|
|
1260
|
-
'local_gb': 50,
|
|
1261
|
-
'free_ram_mb': 1024,
|
|
1262
|
-
'service': {
|
|
1263
|
-
'host': 'aaa',
|
|
1264
|
-
'disabled_reason': None,
|
|
1265
|
-
'id': 1,
|
|
1266
|
-
},
|
|
1267
|
-
'vcpus_used': 0,
|
|
1268
|
-
'hypervisor_type': 'QEMU',
|
|
1269
|
-
'local_gb_used': 0,
|
|
1270
|
-
'vcpus': 4,
|
|
1271
|
-
'memory_mb_used': 512,
|
|
1272
|
-
'memory_mb': 1024,
|
|
1273
|
-
'current_workload': 0,
|
|
1274
|
-
'state': 'up',
|
|
1275
|
-
'running_vms': 0,
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
# Overwrite default attributes.
|
|
1279
|
-
hypervisor_info.update(attrs)
|
|
1280
|
-
|
|
1281
|
-
hypervisor = _hypervisor.Hypervisor(**hypervisor_info, loaded=True)
|
|
1282
|
-
return hypervisor
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
def create_hypervisors(attrs=None, count=2):
|
|
1286
|
-
"""Create multiple fake hypervisors.
|
|
1287
|
-
|
|
1288
|
-
:param dict attrs: A dictionary with all attributes
|
|
1289
|
-
:param int count: The number of hypervisors to fake
|
|
1290
|
-
:return: A list of fake openstack.compute.v2.hypervisor.Hypervisor objects
|
|
1291
|
-
"""
|
|
1292
|
-
hypervisors = []
|
|
1293
|
-
for i in range(0, count):
|
|
1294
|
-
hypervisors.append(create_one_hypervisor(attrs))
|
|
1295
|
-
|
|
1296
|
-
return hypervisors
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
def create_one_server_group(attrs=None):
|
|
1300
|
-
"""Create a fake server group
|
|
1301
|
-
|
|
1302
|
-
:param dict attrs: A dictionary with all attributes
|
|
1303
|
-
:return: A fake openstack.compute.v2.server_group.ServerGroup object
|
|
1304
|
-
"""
|
|
1305
|
-
if attrs is None:
|
|
1306
|
-
attrs = {}
|
|
1307
|
-
|
|
1308
|
-
# Set default attributes.
|
|
1309
|
-
server_group_info = {
|
|
1310
|
-
'id': 'server-group-id-' + uuid.uuid4().hex,
|
|
1311
|
-
'member_ids': '',
|
|
1312
|
-
'metadata': {},
|
|
1313
|
-
'name': 'server-group-name-' + uuid.uuid4().hex,
|
|
1314
|
-
'project_id': 'server-group-project-id-' + uuid.uuid4().hex,
|
|
1315
|
-
'user_id': 'server-group-user-id-' + uuid.uuid4().hex,
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
# Overwrite default attributes.
|
|
1319
|
-
server_group_info.update(attrs)
|
|
1320
|
-
|
|
1321
|
-
server_group = _server_group.ServerGroup(**server_group_info)
|
|
1322
|
-
return server_group
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
1021
|
def create_one_server_interface(attrs=None):
|
|
1326
1022
|
"""Create a fake SDK ServerInterface.
|
|
1327
1023
|
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
from unittest import mock
|
|
17
17
|
from unittest.mock import call
|
|
18
18
|
|
|
19
|
+
from openstack.compute.v2 import aggregate as _aggregate
|
|
19
20
|
from openstack import exceptions as sdk_exceptions
|
|
21
|
+
from openstack.test import fakes as sdk_fakes
|
|
20
22
|
from osc_lib.cli import format_columns
|
|
21
23
|
from osc_lib import exceptions
|
|
22
24
|
|
|
@@ -26,8 +28,6 @@ from openstackclient.tests.unit.image.v2 import fakes as image_fakes
|
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
class TestAggregate(compute_fakes.TestComputev2):
|
|
29
|
-
fake_ag = compute_fakes.create_one_aggregate()
|
|
30
|
-
|
|
31
31
|
columns = (
|
|
32
32
|
'availability_zone',
|
|
33
33
|
'created_at',
|
|
@@ -41,18 +41,25 @@ class TestAggregate(compute_fakes.TestComputev2):
|
|
|
41
41
|
'uuid',
|
|
42
42
|
)
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
fake_ag.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
def setUp(self):
|
|
45
|
+
super().setUp()
|
|
46
|
+
|
|
47
|
+
self.fake_ag = sdk_fakes.generate_fake_resource(
|
|
48
|
+
_aggregate.Aggregate,
|
|
49
|
+
metadata={'availability_zone': 'ag_zone', 'key1': 'value1'},
|
|
50
|
+
)
|
|
51
|
+
self.data = (
|
|
52
|
+
self.fake_ag.availability_zone,
|
|
53
|
+
self.fake_ag.created_at,
|
|
54
|
+
self.fake_ag.deleted_at,
|
|
55
|
+
format_columns.ListColumn(self.fake_ag.hosts),
|
|
56
|
+
self.fake_ag.id,
|
|
57
|
+
self.fake_ag.is_deleted,
|
|
58
|
+
self.fake_ag.name,
|
|
59
|
+
format_columns.DictColumn(self.fake_ag.metadata),
|
|
60
|
+
self.fake_ag.updated_at,
|
|
61
|
+
self.fake_ag.uuid,
|
|
62
|
+
)
|
|
56
63
|
|
|
57
64
|
|
|
58
65
|
class TestAggregateAddHost(TestAggregate):
|
|
@@ -155,13 +162,15 @@ class TestAggregateCreate(TestAggregate):
|
|
|
155
162
|
|
|
156
163
|
|
|
157
164
|
class TestAggregateDelete(TestAggregate):
|
|
158
|
-
fake_ags = compute_fakes.create_aggregates(count=2)
|
|
159
|
-
|
|
160
165
|
def setUp(self):
|
|
161
166
|
super().setUp()
|
|
162
167
|
|
|
163
|
-
self.
|
|
164
|
-
|
|
168
|
+
self.fake_ags = list(
|
|
169
|
+
sdk_fakes.generate_fake_resources(_aggregate.Aggregate, 2)
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
self.compute_sdk_client.find_aggregate = mock.Mock(
|
|
173
|
+
side_effect=[self.fake_ags[0], self.fake_ags[1]]
|
|
165
174
|
)
|
|
166
175
|
self.cmd = aggregate.DeleteAggregate(self.app, None)
|
|
167
176
|
|
|
@@ -526,25 +535,25 @@ class TestAggregateShow(TestAggregate):
|
|
|
526
535
|
'uuid',
|
|
527
536
|
)
|
|
528
537
|
|
|
529
|
-
data = (
|
|
530
|
-
TestAggregate.fake_ag.availability_zone,
|
|
531
|
-
TestAggregate.fake_ag.created_at,
|
|
532
|
-
TestAggregate.fake_ag.deleted_at,
|
|
533
|
-
format_columns.ListColumn(TestAggregate.fake_ag.hosts),
|
|
534
|
-
TestAggregate.fake_ag.id,
|
|
535
|
-
TestAggregate.fake_ag.is_deleted,
|
|
536
|
-
TestAggregate.fake_ag.name,
|
|
537
|
-
format_columns.DictColumn(TestAggregate.fake_ag.metadata),
|
|
538
|
-
TestAggregate.fake_ag.updated_at,
|
|
539
|
-
TestAggregate.fake_ag.uuid,
|
|
540
|
-
)
|
|
541
|
-
|
|
542
538
|
def setUp(self):
|
|
543
539
|
super().setUp()
|
|
544
540
|
|
|
545
541
|
self.compute_sdk_client.find_aggregate.return_value = self.fake_ag
|
|
546
542
|
self.cmd = aggregate.ShowAggregate(self.app, None)
|
|
547
543
|
|
|
544
|
+
self.data = (
|
|
545
|
+
self.fake_ag.availability_zone,
|
|
546
|
+
self.fake_ag.created_at,
|
|
547
|
+
self.fake_ag.deleted_at,
|
|
548
|
+
format_columns.ListColumn(self.fake_ag.hosts),
|
|
549
|
+
self.fake_ag.id,
|
|
550
|
+
self.fake_ag.is_deleted,
|
|
551
|
+
self.fake_ag.name,
|
|
552
|
+
format_columns.DictColumn(self.fake_ag.metadata),
|
|
553
|
+
self.fake_ag.updated_at,
|
|
554
|
+
self.fake_ag.uuid,
|
|
555
|
+
)
|
|
556
|
+
|
|
548
557
|
def test_aggregate_show(self):
|
|
549
558
|
arglist = [
|
|
550
559
|
'ag1',
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
from unittest import mock
|
|
17
17
|
|
|
18
|
+
from openstack.compute.v2 import server as _server
|
|
19
|
+
from openstack.test import fakes as sdk_fakes
|
|
20
|
+
|
|
18
21
|
from openstackclient.compute.v2 import console
|
|
19
22
|
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
|
20
23
|
from openstackclient.tests.unit import utils
|
|
@@ -24,7 +27,7 @@ class TestConsoleLog(compute_fakes.TestComputev2):
|
|
|
24
27
|
def setUp(self):
|
|
25
28
|
super().setUp()
|
|
26
29
|
|
|
27
|
-
self._server =
|
|
30
|
+
self._server = sdk_fakes.generate_fake_resource(_server.Server)
|
|
28
31
|
self.compute_sdk_client.find_server.return_value = self._server
|
|
29
32
|
|
|
30
33
|
self.cmd = console.ShowConsoleLog(self.app, None)
|
|
@@ -76,11 +79,12 @@ class TestConsoleLog(compute_fakes.TestComputev2):
|
|
|
76
79
|
|
|
77
80
|
|
|
78
81
|
class TestConsoleUrlShow(compute_fakes.TestComputev2):
|
|
79
|
-
_server = compute_fakes.create_one_sdk_server()
|
|
80
|
-
|
|
81
82
|
def setUp(self):
|
|
82
83
|
super().setUp()
|
|
84
|
+
|
|
85
|
+
self._server = sdk_fakes.generate_fake_resource(_server.Server)
|
|
83
86
|
self.compute_sdk_client.find_server.return_value = self._server
|
|
87
|
+
|
|
84
88
|
fake_console_data = {
|
|
85
89
|
'url': 'http://localhost',
|
|
86
90
|
'protocol': 'fake_protocol',
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
import json
|
|
16
16
|
|
|
17
|
+
from openstack.compute.v2 import hypervisor as _hypervisor
|
|
17
18
|
from openstack import exceptions as sdk_exceptions
|
|
19
|
+
from openstack.test import fakes as sdk_fakes
|
|
18
20
|
from osc_lib.cli import format_columns
|
|
19
21
|
from osc_lib import exceptions
|
|
20
22
|
|
|
@@ -27,8 +29,12 @@ class TestHypervisorList(compute_fakes.TestComputev2):
|
|
|
27
29
|
super().setUp()
|
|
28
30
|
|
|
29
31
|
# Fake hypervisors to be listed up
|
|
30
|
-
self.hypervisors =
|
|
31
|
-
|
|
32
|
+
self.hypervisors = list(
|
|
33
|
+
sdk_fakes.generate_fake_resources(_hypervisor.Hypervisor, count=2)
|
|
34
|
+
)
|
|
35
|
+
self.compute_sdk_client.hypervisors.return_value = iter(
|
|
36
|
+
self.hypervisors
|
|
37
|
+
)
|
|
32
38
|
|
|
33
39
|
self.columns = (
|
|
34
40
|
"ID",
|
|
@@ -125,9 +131,9 @@ class TestHypervisorList(compute_fakes.TestComputev2):
|
|
|
125
131
|
(
|
|
126
132
|
self.hypervisors[0].id,
|
|
127
133
|
self.hypervisors[0].name,
|
|
128
|
-
self.hypervisors[
|
|
129
|
-
self.hypervisors[
|
|
130
|
-
self.hypervisors[
|
|
134
|
+
self.hypervisors[0].hypervisor_type,
|
|
135
|
+
self.hypervisors[0].host_ip,
|
|
136
|
+
self.hypervisors[0].state,
|
|
131
137
|
),
|
|
132
138
|
)
|
|
133
139
|
|
|
@@ -290,10 +296,11 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
|
|
290
296
|
)
|
|
291
297
|
|
|
292
298
|
# Fake hypervisors to be listed up
|
|
293
|
-
self.hypervisor =
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
299
|
+
self.hypervisor = sdk_fakes.generate_fake_resource(
|
|
300
|
+
_hypervisor.Hypervisor,
|
|
301
|
+
uptime=uptime_string,
|
|
302
|
+
service={"id": 1, "host": "aaa"},
|
|
303
|
+
cpu_info={"aaa": "aaa"},
|
|
297
304
|
)
|
|
298
305
|
|
|
299
306
|
self.compute_sdk_client.find_hypervisor.return_value = self.hypervisor
|
|
@@ -332,18 +339,18 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
|
|
332
339
|
|
|
333
340
|
self.data_v288 = (
|
|
334
341
|
[],
|
|
335
|
-
format_columns.DictColumn(
|
|
336
|
-
|
|
342
|
+
format_columns.DictColumn(self.hypervisor.cpu_info),
|
|
343
|
+
self.hypervisor.host_ip,
|
|
337
344
|
'01:28:24',
|
|
338
345
|
self.hypervisor.name,
|
|
339
|
-
|
|
340
|
-
|
|
346
|
+
self.hypervisor.hypervisor_type,
|
|
347
|
+
self.hypervisor.hypervisor_version,
|
|
341
348
|
self.hypervisor.id,
|
|
342
349
|
'0.94, 0.62, 0.50',
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
350
|
+
self.hypervisor.service_details["host"],
|
|
351
|
+
self.hypervisor.service_details["id"],
|
|
352
|
+
self.hypervisor.state,
|
|
353
|
+
self.hypervisor.status,
|
|
347
354
|
'3 days, 11:15',
|
|
348
355
|
'1',
|
|
349
356
|
)
|
|
@@ -378,31 +385,31 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
|
|
378
385
|
)
|
|
379
386
|
self.data = (
|
|
380
387
|
[],
|
|
381
|
-
format_columns.DictColumn(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
388
|
+
format_columns.DictColumn(self.hypervisor.cpu_info),
|
|
389
|
+
self.hypervisor.current_workload,
|
|
390
|
+
self.hypervisor.disk_available,
|
|
391
|
+
self.hypervisor.local_disk_free,
|
|
392
|
+
self.hypervisor.memory_free,
|
|
393
|
+
self.hypervisor.host_ip,
|
|
387
394
|
'01:28:24',
|
|
388
395
|
self.hypervisor.name,
|
|
389
|
-
|
|
390
|
-
|
|
396
|
+
self.hypervisor.hypervisor_type,
|
|
397
|
+
self.hypervisor.hypervisor_version,
|
|
391
398
|
self.hypervisor.id,
|
|
392
399
|
'0.94, 0.62, 0.50',
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
400
|
+
self.hypervisor.local_disk_size,
|
|
401
|
+
self.hypervisor.local_disk_used,
|
|
402
|
+
self.hypervisor.memory_size,
|
|
403
|
+
self.hypervisor.memory_used,
|
|
404
|
+
self.hypervisor.running_vms,
|
|
405
|
+
self.hypervisor.service_details["host"],
|
|
399
406
|
1,
|
|
400
|
-
|
|
401
|
-
|
|
407
|
+
self.hypervisor.state,
|
|
408
|
+
self.hypervisor.status,
|
|
402
409
|
'3 days, 11:15',
|
|
403
410
|
'1',
|
|
404
|
-
|
|
405
|
-
|
|
411
|
+
self.hypervisor.vcpus,
|
|
412
|
+
self.hypervisor.vcpus_used,
|
|
406
413
|
)
|
|
407
414
|
|
|
408
415
|
# Get the command object to test
|
|
@@ -537,27 +544,27 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
|
|
537
544
|
)
|
|
538
545
|
expected_data = (
|
|
539
546
|
[],
|
|
540
|
-
format_columns.DictColumn(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
547
|
+
format_columns.DictColumn(self.hypervisor.cpu_info),
|
|
548
|
+
self.hypervisor.current_workload,
|
|
549
|
+
self.hypervisor.disk_available,
|
|
550
|
+
self.hypervisor.local_disk_free,
|
|
551
|
+
self.hypervisor.memory_free,
|
|
552
|
+
self.hypervisor.host_ip,
|
|
546
553
|
self.hypervisor.name,
|
|
547
|
-
|
|
548
|
-
|
|
554
|
+
self.hypervisor.hypervisor_type,
|
|
555
|
+
self.hypervisor.hypervisor_version,
|
|
549
556
|
self.hypervisor.id,
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
557
|
+
self.hypervisor.local_disk_size,
|
|
558
|
+
self.hypervisor.local_disk_used,
|
|
559
|
+
self.hypervisor.memory_size,
|
|
560
|
+
self.hypervisor.memory_used,
|
|
561
|
+
self.hypervisor.running_vms,
|
|
562
|
+
self.hypervisor.service_details["host"],
|
|
556
563
|
1,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
564
|
+
self.hypervisor.state,
|
|
565
|
+
self.hypervisor.status,
|
|
566
|
+
self.hypervisor.vcpus,
|
|
567
|
+
self.hypervisor.vcpus_used,
|
|
561
568
|
)
|
|
562
569
|
|
|
563
570
|
self.assertEqual(expected_columns, columns)
|