python-openstackclient 6.1.0__py3-none-any.whl → 6.2.1__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 (39) hide show
  1. openstackclient/common/project_cleanup.py +3 -5
  2. openstackclient/common/quota.py +4 -6
  3. openstackclient/compute/v2/host.py +44 -16
  4. openstackclient/compute/v2/server.py +18 -24
  5. openstackclient/compute/v2/server_migration.py +53 -29
  6. openstackclient/compute/v2/server_volume.py +35 -38
  7. openstackclient/compute/v2/service.py +5 -5
  8. openstackclient/identity/common.py +12 -0
  9. openstackclient/identity/v3/access_rule.py +8 -6
  10. openstackclient/image/v2/image.py +8 -2
  11. openstackclient/network/v2/floating_ip_port_forwarding.py +70 -32
  12. openstackclient/network/v2/network_service_provider.py +16 -10
  13. openstackclient/tests/functional/compute/v2/test_server.py +0 -3
  14. openstackclient/tests/unit/compute/v2/fakes.py +122 -207
  15. openstackclient/tests/unit/compute/v2/test_host.py +63 -42
  16. openstackclient/tests/unit/compute/v2/test_server.py +1 -2
  17. openstackclient/tests/unit/compute/v2/test_server_migration.py +92 -95
  18. openstackclient/tests/unit/compute/v2/test_server_volume.py +103 -83
  19. openstackclient/tests/unit/identity/v3/test_access_rule.py +11 -11
  20. openstackclient/tests/unit/network/v2/fakes.py +31 -7
  21. openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +213 -18
  22. openstackclient/tests/unit/volume/v1/test_volume.py +48 -3
  23. openstackclient/tests/unit/volume/v2/test_consistency_group.py +2 -2
  24. openstackclient/tests/unit/volume/v2/test_volume.py +50 -3
  25. openstackclient/tests/unit/volume/v3/test_volume_group.py +47 -8
  26. openstackclient/volume/v1/volume.py +33 -4
  27. openstackclient/volume/v2/backup_record.py +8 -6
  28. openstackclient/volume/v2/consistency_group.py +32 -13
  29. openstackclient/volume/v2/volume.py +33 -4
  30. openstackclient/volume/v3/volume_group.py +91 -36
  31. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/AUTHORS +5 -0
  32. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/METADATA +1 -1
  33. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/RECORD +38 -38
  34. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/entry_points.txt +1 -0
  35. python_openstackclient-6.2.1.dist-info/pbr.json +1 -0
  36. python_openstackclient-6.1.0.dist-info/pbr.json +0 -1
  37. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/LICENSE +0 -0
  38. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/WHEEL +0 -0
  39. {python_openstackclient-6.1.0.dist-info → python_openstackclient-6.2.1.dist-info}/top_level.txt +0 -0
@@ -25,6 +25,61 @@ from openstackclient.network import common
25
25
  LOG = logging.getLogger(__name__)
26
26
 
27
27
 
28
+ def validate_ports_diff(ports):
29
+ if len(ports) == 0:
30
+ return 0
31
+
32
+ ports_diff = ports[-1] - ports[0]
33
+ if ports_diff < 0:
34
+ msg = _("The last number in port range must be"
35
+ " greater or equal to the first")
36
+ raise exceptions.CommandError(msg)
37
+ return ports_diff
38
+
39
+
40
+ def validate_ports_match(internal_ports, external_ports):
41
+ internal_ports_diff = validate_ports_diff(internal_ports)
42
+ external_ports_diff = validate_ports_diff(external_ports)
43
+
44
+ if internal_ports_diff != 0 and internal_ports_diff != external_ports_diff:
45
+ msg = _("The relation between internal and external ports does not "
46
+ "match the pattern 1:N and N:N")
47
+ raise exceptions.CommandError(msg)
48
+
49
+
50
+ def validate_and_assign_port_ranges(parsed_args, attrs):
51
+ internal_port_range = parsed_args.internal_protocol_port
52
+ external_port_range = parsed_args.external_protocol_port
53
+ external_ports = internal_ports = []
54
+ if external_port_range:
55
+ external_ports = list(map(int, str(external_port_range).split(':')))
56
+ if internal_port_range:
57
+ internal_ports = list(map(int, str(internal_port_range).split(':')))
58
+
59
+ validate_ports_match(internal_ports, external_ports)
60
+
61
+ for port in external_ports + internal_ports:
62
+ validate_port(port)
63
+
64
+ if internal_port_range:
65
+ if ':' in internal_port_range:
66
+ attrs['internal_port_range'] = internal_port_range
67
+ else:
68
+ attrs['internal_port'] = int(internal_port_range)
69
+
70
+ if external_port_range:
71
+ if ':' in external_port_range:
72
+ attrs['external_port_range'] = external_port_range
73
+ else:
74
+ attrs['external_port'] = int(external_port_range)
75
+
76
+
77
+ def validate_port(port):
78
+ if port <= 0 or port > 65535:
79
+ msg = _("The port number range is <1-65535>")
80
+ raise exceptions.CommandError(msg)
81
+
82
+
28
83
  def _get_columns(item):
29
84
  column_map = {}
30
85
  hidden_columns = ['location', 'tenant_id']
@@ -58,7 +113,6 @@ class CreateFloatingIPPortForwarding(command.ShowOne,
58
113
  )
59
114
  parser.add_argument(
60
115
  '--internal-protocol-port',
61
- type=int,
62
116
  metavar='<port-number>',
63
117
  required=True,
64
118
  help=_("The protocol port number "
@@ -67,7 +121,6 @@ class CreateFloatingIPPortForwarding(command.ShowOne,
67
121
  )
68
122
  parser.add_argument(
69
123
  '--external-protocol-port',
70
- type=int,
71
124
  metavar='<port-number>',
72
125
  required=True,
73
126
  help=_("The protocol port number of "
@@ -92,6 +145,7 @@ class CreateFloatingIPPortForwarding(command.ShowOne,
92
145
  help=_("Floating IP that the port forwarding belongs to "
93
146
  "(IP address or ID)")
94
147
  )
148
+
95
149
  return parser
96
150
 
97
151
  def take_action(self, parsed_args):
@@ -102,19 +156,7 @@ class CreateFloatingIPPortForwarding(command.ShowOne,
102
156
  ignore_missing=False,
103
157
  )
104
158
 
105
- if parsed_args.internal_protocol_port is not None:
106
- if (parsed_args.internal_protocol_port <= 0 or
107
- parsed_args.internal_protocol_port > 65535):
108
- msg = _("The port number range is <1-65535>")
109
- raise exceptions.CommandError(msg)
110
- attrs['internal_port'] = parsed_args.internal_protocol_port
111
-
112
- if parsed_args.external_protocol_port is not None:
113
- if (parsed_args.external_protocol_port <= 0 or
114
- parsed_args.external_protocol_port > 65535):
115
- msg = _("The port number range is <1-65535>")
116
- raise exceptions.CommandError(msg)
117
- attrs['external_port'] = parsed_args.external_protocol_port
159
+ validate_and_assign_port_ranges(parsed_args, attrs)
118
160
 
119
161
  if parsed_args.port:
120
162
  port = client.find_port(parsed_args.port,
@@ -226,7 +268,9 @@ class ListFloatingIPPortForwarding(command.Lister):
226
268
  'internal_port_id',
227
269
  'internal_ip_address',
228
270
  'internal_port',
271
+ 'internal_port_range',
229
272
  'external_port',
273
+ 'external_port_range',
230
274
  'protocol',
231
275
  'description',
232
276
  )
@@ -235,7 +279,9 @@ class ListFloatingIPPortForwarding(command.Lister):
235
279
  'Internal Port ID',
236
280
  'Internal IP Address',
237
281
  'Internal Port',
282
+ 'Internal Port Range',
238
283
  'External Port',
284
+ 'External Port Range',
239
285
  'Protocol',
240
286
  'Description',
241
287
  )
@@ -246,8 +292,13 @@ class ListFloatingIPPortForwarding(command.Lister):
246
292
  port = client.find_port(parsed_args.port,
247
293
  ignore_missing=False)
248
294
  query['internal_port_id'] = port.id
249
- if parsed_args.external_protocol_port is not None:
250
- query['external_port'] = parsed_args.external_protocol_port
295
+ external_port = parsed_args.external_protocol_port
296
+ if external_port:
297
+ if ':' in external_port:
298
+ query['external_port_range'] = external_port
299
+ else:
300
+ query['external_port'] = int(
301
+ parsed_args.external_protocol_port)
251
302
  if parsed_args.protocol is not None:
252
303
  query['protocol'] = parsed_args.protocol
253
304
 
@@ -297,14 +348,12 @@ class SetFloatingIPPortForwarding(common.NeutronCommandWithExtraArgs):
297
348
  parser.add_argument(
298
349
  '--internal-protocol-port',
299
350
  metavar='<port-number>',
300
- type=int,
301
351
  help=_("The TCP/UDP/other protocol port number of the "
302
352
  "network port fixed IPv4 address associated to "
303
353
  "the floating IP port forwarding")
304
354
  )
305
355
  parser.add_argument(
306
356
  '--external-protocol-port',
307
- type=int,
308
357
  metavar='<port-number>',
309
358
  help=_("The TCP/UDP/other protocol port number of the "
310
359
  "port forwarding's floating IP address")
@@ -339,19 +388,8 @@ class SetFloatingIPPortForwarding(common.NeutronCommandWithExtraArgs):
339
388
 
340
389
  if parsed_args.internal_ip_address:
341
390
  attrs['internal_ip_address'] = parsed_args.internal_ip_address
342
- if parsed_args.internal_protocol_port is not None:
343
- if (parsed_args.internal_protocol_port <= 0 or
344
- parsed_args.internal_protocol_port > 65535):
345
- msg = _("The port number range is <1-65535>")
346
- raise exceptions.CommandError(msg)
347
- attrs['internal_port'] = parsed_args.internal_protocol_port
348
-
349
- if parsed_args.external_protocol_port is not None:
350
- if (parsed_args.external_protocol_port <= 0 or
351
- parsed_args.external_protocol_port > 65535):
352
- msg = _("The port number range is <1-65535>")
353
- raise exceptions.CommandError(msg)
354
- attrs['external_port'] = parsed_args.external_protocol_port
391
+
392
+ validate_and_assign_port_ranges(parsed_args, attrs)
355
393
 
356
394
  if parsed_args.protocol:
357
395
  attrs['protocol'] = parsed_args.protocol
@@ -26,18 +26,24 @@ class ListNetworkServiceProvider(command.Lister):
26
26
  client = self.app.client_manager.network
27
27
 
28
28
  columns = (
29
- 'service_type',
30
- 'name',
31
- 'is_default',
29
+ "service_type",
30
+ "name",
31
+ "is_default",
32
32
  )
33
33
  column_headers = (
34
- 'Service Type',
35
- 'Name',
36
- 'Default',
34
+ "Service Type",
35
+ "Name",
36
+ "Default",
37
37
  )
38
38
 
39
39
  data = client.service_providers()
40
- return(column_headers,
41
- (utils.get_item_properties(
42
- s, columns,
43
- ) for s in data))
40
+ return (
41
+ column_headers,
42
+ (
43
+ utils.get_item_properties(
44
+ s,
45
+ columns,
46
+ )
47
+ for s in data
48
+ ),
49
+ )
@@ -1375,10 +1375,8 @@ class ServerTests(common.ComputeTestCase):
1375
1375
  parse_output=True,
1376
1376
  )
1377
1377
 
1378
- self.assertIsNotNone(cmd_output['ID'])
1379
1378
  self.assertEqual(server_id, cmd_output['Server ID'])
1380
1379
  self.assertEqual(volume_id, cmd_output['Volume ID'])
1381
- volume_attachment_id = cmd_output['ID']
1382
1380
 
1383
1381
  cmd_output = self.openstack(
1384
1382
  'server volume list ' +
@@ -1386,7 +1384,6 @@ class ServerTests(common.ComputeTestCase):
1386
1384
  parse_output=True,
1387
1385
  )
1388
1386
 
1389
- self.assertEqual(volume_attachment_id, cmd_output[0]['ID'])
1390
1387
  self.assertEqual(server_id, cmd_output[0]['Server ID'])
1391
1388
  self.assertEqual(volume_id, cmd_output[0]['Volume ID'])
1392
1389
 
@@ -21,9 +21,11 @@ import uuid
21
21
  from novaclient import api_versions
22
22
  from openstack.compute.v2 import flavor as _flavor
23
23
  from openstack.compute.v2 import hypervisor as _hypervisor
24
+ from openstack.compute.v2 import migration as _migration
24
25
  from openstack.compute.v2 import server as _server
25
26
  from openstack.compute.v2 import server_group as _server_group
26
27
  from openstack.compute.v2 import server_interface as _server_interface
28
+ from openstack.compute.v2 import server_migration as _server_migration
27
29
  from openstack.compute.v2 import service
28
30
  from openstack.compute.v2 import volume_attachment
29
31
 
@@ -1433,242 +1435,155 @@ class FakeRateLimit(object):
1433
1435
  self.next_available = next_available
1434
1436
 
1435
1437
 
1436
- class FakeMigration(object):
1437
- """Fake one or more migrations."""
1438
+ def create_one_migration(attrs=None):
1439
+ """Create a fake migration.
1438
1440
 
1439
- @staticmethod
1440
- def create_one_migration(attrs=None, methods=None):
1441
- """Create a fake migration.
1442
-
1443
- :param dict attrs:
1444
- A dictionary with all attributes
1445
- :param dict methods:
1446
- A dictionary with all methods
1447
- :return:
1448
- A FakeResource object, with id, type, and so on
1449
- """
1450
- attrs = attrs or {}
1451
- methods = methods or {}
1441
+ :param dict attrs: A dictionary with all attributes
1442
+ :return: A fake openstack.compute.v2.migration.Migration object
1443
+ """
1444
+ attrs = attrs or {}
1452
1445
 
1453
- # Set default attributes.
1454
- migration_info = {
1455
- "dest_host": "10.0.2.15",
1456
- "status": "migrating",
1457
- "migration_type": "migration",
1458
- "updated_at": "2017-01-31T08:03:25.000000",
1459
- "created_at": "2017-01-31T08:03:21.000000",
1460
- "dest_compute": "compute-" + uuid.uuid4().hex,
1461
- "id": random.randint(1, 999),
1462
- "source_node": "node-" + uuid.uuid4().hex,
1463
- "instance_uuid": uuid.uuid4().hex,
1464
- "dest_node": "node-" + uuid.uuid4().hex,
1465
- "source_compute": "compute-" + uuid.uuid4().hex,
1466
- "uuid": uuid.uuid4().hex,
1467
- "old_instance_type_id": uuid.uuid4().hex,
1468
- "new_instance_type_id": uuid.uuid4().hex,
1469
- "project_id": uuid.uuid4().hex,
1470
- "user_id": uuid.uuid4().hex
1471
- }
1446
+ # Set default attributes.
1447
+ migration_info = {
1448
+ "created_at": "2017-01-31T08:03:21.000000",
1449
+ "dest_compute": "compute-" + uuid.uuid4().hex,
1450
+ "dest_host": "10.0.2.15",
1451
+ "dest_node": "node-" + uuid.uuid4().hex,
1452
+ "id": random.randint(1, 999),
1453
+ "migration_type": "migration",
1454
+ "new_flavor_id": uuid.uuid4().hex,
1455
+ "old_flavor_id": uuid.uuid4().hex,
1456
+ "project_id": uuid.uuid4().hex,
1457
+ "server_id": uuid.uuid4().hex,
1458
+ "source_compute": "compute-" + uuid.uuid4().hex,
1459
+ "source_node": "node-" + uuid.uuid4().hex,
1460
+ "status": "migrating",
1461
+ "updated_at": "2017-01-31T08:03:25.000000",
1462
+ "user_id": uuid.uuid4().hex,
1463
+ "uuid": uuid.uuid4().hex,
1464
+ }
1472
1465
 
1473
- # Overwrite default attributes.
1474
- migration_info.update(attrs)
1466
+ # Overwrite default attributes.
1467
+ migration_info.update(attrs)
1475
1468
 
1476
- migration = fakes.FakeResource(info=copy.deepcopy(migration_info),
1477
- methods=methods,
1478
- loaded=True)
1479
- return migration
1469
+ migration = _migration.Migration(**migration_info)
1470
+ return migration
1480
1471
 
1481
- @staticmethod
1482
- def create_migrations(attrs=None, methods=None, count=2):
1483
- """Create multiple fake migrations.
1484
1472
 
1485
- :param dict attrs:
1486
- A dictionary with all attributes
1487
- :param dict methods:
1488
- A dictionary with all methods
1489
- :param int count:
1490
- The number of migrations to fake
1491
- :return:
1492
- A list of FakeResource objects faking the migrations
1493
- """
1494
- migrations = []
1495
- for i in range(0, count):
1496
- migrations.append(
1497
- FakeMigration.create_one_migration(
1498
- attrs, methods))
1473
+ def create_migrations(attrs=None, count=2):
1474
+ """Create multiple fake migrations.
1499
1475
 
1500
- return migrations
1476
+ :param dict attrs: A dictionary with all attributes
1477
+ :param int count: The number of migrations to fake
1478
+ :return: A list of fake openstack.compute.v2.migration.Migration objects
1479
+ """
1480
+ migrations = []
1481
+ for i in range(0, count):
1482
+ migrations.append(create_one_migration(attrs))
1501
1483
 
1484
+ return migrations
1502
1485
 
1503
- class FakeServerMigration(object):
1504
- """Fake one or more server migrations."""
1505
1486
 
1506
- @staticmethod
1507
- def create_one_server_migration(attrs=None, methods=None):
1508
- """Create a fake server migration.
1509
-
1510
- :param dict attrs:
1511
- A dictionary with all attributes
1512
- :param dict methods:
1513
- A dictionary with all methods
1514
- :return:
1515
- A FakeResource object, with id, type, and so on
1516
- """
1517
- attrs = attrs or {}
1518
- methods = methods or {}
1487
+ def create_one_server_migration(attrs=None):
1488
+ """Create a fake server migration.
1519
1489
 
1520
- # Set default attributes.
1490
+ :param dict attrs: A dictionary with all attributes
1491
+ :return A fake openstack.compute.v2.server_migration.ServerMigration object
1492
+ """
1493
+ attrs = attrs or {}
1521
1494
 
1522
- migration_info = {
1523
- "created_at": "2016-01-29T13:42:02.000000",
1524
- "dest_compute": "compute2",
1525
- "dest_host": "1.2.3.4",
1526
- "dest_node": "node2",
1527
- "id": random.randint(1, 999),
1528
- "server_uuid": uuid.uuid4().hex,
1529
- "source_compute": "compute1",
1530
- "source_node": "node1",
1531
- "status": "running",
1532
- "memory_total_bytes": random.randint(1, 99999),
1533
- "memory_processed_bytes": random.randint(1, 99999),
1534
- "memory_remaining_bytes": random.randint(1, 99999),
1535
- "disk_total_bytes": random.randint(1, 99999),
1536
- "disk_processed_bytes": random.randint(1, 99999),
1537
- "disk_remaining_bytes": random.randint(1, 99999),
1538
- "updated_at": "2016-01-29T13:42:02.000000",
1539
- # added in 2.59
1540
- "uuid": uuid.uuid4().hex,
1541
- # added in 2.80
1542
- "user_id": uuid.uuid4().hex,
1543
- "project_id": uuid.uuid4().hex,
1544
- }
1495
+ # Set default attributes.
1545
1496
 
1546
- # Overwrite default attributes.
1547
- migration_info.update(attrs)
1497
+ migration_info = {
1498
+ "created_at": "2016-01-29T13:42:02.000000",
1499
+ "dest_compute": "compute2",
1500
+ "dest_host": "1.2.3.4",
1501
+ "dest_node": "node2",
1502
+ "id": random.randint(1, 999),
1503
+ "server_uuid": uuid.uuid4().hex,
1504
+ "source_compute": "compute1",
1505
+ "source_node": "node1",
1506
+ "status": "running",
1507
+ "memory_total_bytes": random.randint(1, 99999),
1508
+ "memory_processed_bytes": random.randint(1, 99999),
1509
+ "memory_remaining_bytes": random.randint(1, 99999),
1510
+ "disk_total_bytes": random.randint(1, 99999),
1511
+ "disk_processed_bytes": random.randint(1, 99999),
1512
+ "disk_remaining_bytes": random.randint(1, 99999),
1513
+ "updated_at": "2016-01-29T13:42:02.000000",
1514
+ # added in 2.59
1515
+ "uuid": uuid.uuid4().hex,
1516
+ # added in 2.80
1517
+ "user_id": uuid.uuid4().hex,
1518
+ "project_id": uuid.uuid4().hex,
1519
+ }
1548
1520
 
1549
- migration = fakes.FakeResource(
1550
- info=copy.deepcopy(migration_info),
1551
- methods=methods,
1552
- loaded=True)
1553
- return migration
1521
+ # Overwrite default attributes.
1522
+ migration_info.update(attrs)
1554
1523
 
1524
+ migration = _server_migration.ServerMigration(**migration_info)
1525
+ return migration
1555
1526
 
1556
- class FakeVolumeAttachment(object):
1557
- """Fake one or more volume attachments (BDMs)."""
1558
1527
 
1559
- @staticmethod
1560
- def create_one_volume_attachment(attrs=None, methods=None):
1561
- """Create a fake volume attachment.
1528
+ def create_server_migrations(attrs=None, methods=None, count=2):
1529
+ """Create multiple server migrations.
1562
1530
 
1563
- :param dict attrs:
1564
- A dictionary with all attributes
1565
- :param dict methods:
1566
- A dictionary with all methods
1567
- :return:
1568
- A FakeResource object, with id, device, and so on
1569
- """
1570
- attrs = attrs or {}
1571
- methods = methods or {}
1572
-
1573
- # Set default attributes.
1574
- volume_attachment_info = {
1575
- "id": uuid.uuid4().hex,
1576
- "device": "/dev/sdb",
1577
- "serverId": uuid.uuid4().hex,
1578
- "volumeId": uuid.uuid4().hex,
1579
- # introduced in API microversion 2.70
1580
- "tag": "foo",
1581
- # introduced in API microversion 2.79
1582
- "delete_on_termination": True,
1583
- # introduced in API microversion 2.89
1584
- "attachment_id": uuid.uuid4().hex,
1585
- "bdm_uuid": uuid.uuid4().hex
1586
- }
1587
-
1588
- # Overwrite default attributes.
1589
- volume_attachment_info.update(attrs)
1590
-
1591
- volume_attachment = fakes.FakeResource(
1592
- info=copy.deepcopy(volume_attachment_info),
1593
- methods=methods,
1594
- loaded=True)
1595
- return volume_attachment
1531
+ :param dict attrs: A dictionary with all attributes
1532
+ :param int count: The number of server migrations to fake
1533
+ :return A list of fake
1534
+ openstack.compute.v2.server_migration.ServerMigration objects
1535
+ """
1536
+ migrations = []
1537
+ for i in range(0, count):
1538
+ migrations.append(
1539
+ create_one_server_migration(attrs, methods))
1596
1540
 
1597
- @staticmethod
1598
- def create_volume_attachments(attrs=None, methods=None, count=2):
1599
- """Create multiple fake volume attachments (BDMs).
1541
+ return migrations
1600
1542
 
1601
- :param dict attrs:
1602
- A dictionary with all attributes
1603
- :param dict methods:
1604
- A dictionary with all methods
1605
- :param int count:
1606
- The number of volume attachments to fake
1607
- :return:
1608
- A list of FakeResource objects faking the volume attachments.
1609
- """
1610
- volume_attachments = []
1611
- for i in range(0, count):
1612
- volume_attachments.append(
1613
- FakeVolumeAttachment.create_one_volume_attachment(
1614
- attrs, methods))
1615
1543
 
1616
- return volume_attachments
1544
+ def create_one_volume_attachment(attrs=None):
1545
+ """Create a fake volume attachment.
1617
1546
 
1618
- @staticmethod
1619
- def create_one_sdk_volume_attachment(attrs=None, methods=None):
1620
- """Create a fake sdk VolumeAttachment.
1547
+ :param dict attrs: A dictionary with all attributes
1548
+ :return: A fake openstack.compute.v2.volume_attachment.VolumeAttachment
1549
+ object
1550
+ """
1551
+ attrs = attrs or {}
1621
1552
 
1622
- :param dict attrs:
1623
- A dictionary with all attributes
1624
- :param dict methods:
1625
- A dictionary with all methods
1626
- :return:
1627
- A fake VolumeAttachment object, with id, device, and so on
1628
- """
1629
- attrs = attrs or {}
1630
- methods = methods or {}
1553
+ # Set default attributes.
1554
+ volume_attachment_info = {
1555
+ "id": uuid.uuid4().hex,
1556
+ "device": "/dev/sdb",
1557
+ "server_id": uuid.uuid4().hex,
1558
+ "volume_id": uuid.uuid4().hex,
1559
+ # introduced in API microversion 2.70
1560
+ "tag": "foo",
1561
+ # introduced in API microversion 2.79
1562
+ "delete_on_termination": True,
1563
+ # introduced in API microversion 2.89
1564
+ "attachment_id": uuid.uuid4().hex,
1565
+ "bdm_id": uuid.uuid4().hex,
1566
+ }
1631
1567
 
1632
- # Set default attributes.
1633
- volume_attachment_info = {
1634
- "id": uuid.uuid4().hex,
1635
- "device": "/dev/sdb",
1636
- "server_id": uuid.uuid4().hex,
1637
- "volume_id": uuid.uuid4().hex,
1638
- # introduced in API microversion 2.70
1639
- "tag": "foo",
1640
- # introduced in API microversion 2.79
1641
- "delete_on_termination": True,
1642
- # introduced in API microversion 2.89
1643
- "attachment_id": uuid.uuid4().hex,
1644
- "bdm_uuid": uuid.uuid4().hex
1645
- }
1568
+ # Overwrite default attributes.
1569
+ volume_attachment_info.update(attrs)
1646
1570
 
1647
- # Overwrite default attributes.
1648
- volume_attachment_info.update(attrs)
1571
+ return volume_attachment.VolumeAttachment(**volume_attachment_info)
1649
1572
 
1650
- return volume_attachment.VolumeAttachment(**volume_attachment_info)
1651
1573
 
1652
- @staticmethod
1653
- def create_sdk_volume_attachments(attrs=None, methods=None, count=2):
1654
- """Create multiple fake VolumeAttachment objects (BDMs).
1574
+ def create_volume_attachments(attrs=None, count=2):
1575
+ """Create multiple fake volume attachments.
1655
1576
 
1656
- :param dict attrs:
1657
- A dictionary with all attributes
1658
- :param dict methods:
1659
- A dictionary with all methods
1660
- :param int count:
1661
- The number of volume attachments to fake
1662
- :return:
1663
- A list of VolumeAttachment objects faking the volume attachments.
1664
- """
1665
- volume_attachments = []
1666
- for i in range(0, count):
1667
- volume_attachments.append(
1668
- FakeVolumeAttachment.create_one_sdk_volume_attachment(
1669
- attrs, methods))
1577
+ :param dict attrs: A dictionary with all attributes
1578
+ :param int count: The number of volume attachments to fake
1579
+ :return: A list of fake
1580
+ openstack.compute.v2.volume_attachment.VolumeAttachment objects
1581
+ """
1582
+ volume_attachments = []
1583
+ for i in range(0, count):
1584
+ volume_attachments.append(create_one_volume_attachment(attrs))
1670
1585
 
1671
- return volume_attachments
1586
+ return volume_attachments
1672
1587
 
1673
1588
 
1674
1589
  def create_one_hypervisor(attrs=None):