Skip to content

Commit 658f0a2

Browse files
committed
Updated command slcli block replica-order and updated some descriptions in group command
1 parent 09125be commit 658f0a2

File tree

10 files changed

+62
-45
lines changed

10 files changed

+62
-45
lines changed

SoftLayer/CLI/block/replication/disaster_recovery_failover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
After using this method, to failback to the original volume, please open a support ticket.
1616
If you wish to test failover, please use replica-failover.""")
1717
@click.argument('volume-id')
18-
@click.option('--replicant-id', help="ID of the replicant volume")
18+
@click.option('--replicant-id', help="ID of the replicant volume.")
1919
@environment.pass_env
2020
def cli(env, volume_id, replicant_id):
2121
"""Failover an inaccessible block volume to its available replicant volume."""

SoftLayer/CLI/block/replication/failback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@click.argument('volume-id')
1111
@environment.pass_env
1212
def cli(env, volume_id):
13-
"""Failback a block volume from the given replicant volume."""
13+
"""Failback a block volume from the given replica volume."""
1414
block_storage_manager = SoftLayer.BlockStorageManager(env.client)
1515

1616
success = block_storage_manager.failback_from_replicant(volume_id)

SoftLayer/CLI/block/replication/failover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1010
@click.argument('volume-id')
11-
@click.option('--replicant-id', help="ID of the replicant volume")
11+
@click.option('--replicant-id', help="ID of the replicant volume.")
1212
@environment.pass_env
1313
def cli(env, volume_id, replicant_id):
14-
"""Failover a block volume to the given replicant volume."""
14+
"""Failover a block volume to the given replica volume."""
1515
block_storage_manager = SoftLayer.BlockStorageManager(env.client)
1616

1717
success = block_storage_manager.failover_to_replicant(

SoftLayer/CLI/block/replication/locations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
2424
@click.argument('volume-id')
25-
@click.option('--sortby', help='Column to sort by', default='Long Name')
2625
@click.option('--columns',
2726
callback=column_helper.get_formatter(COLUMNS),
2827
help='Columns to display. Options: {0}'.format(
2928
', '.join(column.name for column in COLUMNS)),
3029
default=','.join(DEFAULT_COLUMNS))
30+
@click.option('--sortby', help='Column to sort by', default='Long Name')
3131
@environment.pass_env
3232
def cli(env, columns, sortby, volume_id):
3333
"""List suitable replication datacenters for the given volume."""

SoftLayer/CLI/block/replication/order.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,16 @@
1414

1515
@click.command(cls=SoftLayer.CLI.command.SLCommand, context_settings=CONTEXT_SETTINGS)
1616
@click.argument('volume_id')
17-
@click.option('--snapshot-schedule', '-s',
18-
help='Snapshot schedule to use for replication, '
19-
'(HOURLY | DAILY | WEEKLY)',
20-
required=True,
21-
type=click.Choice(['HOURLY', 'DAILY', 'WEEKLY']))
22-
@click.option('--location', '-l',
23-
help='Short name of the data center for the replicant '
24-
'(e.g.: dal09)',
17+
@click.option('--datacenter', '-d',
18+
help='Short name of the datacenter for the replica (e.g.: dal09)',
2519
required=True)
26-
@click.option('--tier',
27-
help='Endurance Storage Tier (IOPS per GB) of the primary'
28-
' volume for which a replicant is ordered [optional]',
29-
type=click.Choice(['0.25', '2', '4', '10']))
30-
@click.option('--os-type',
31-
help='Operating System Type (e.g.: LINUX) of the primary'
32-
' volume for which a replica is ordered [optional]',
20+
@click.option('--iops', '-i',
21+
help='Performance Storage IOPs, between 100 and 6000 in multiples of 100. If no IOPS value is specified,'
22+
' the IOPS value of the original volume will be used.',
23+
type=int)
24+
@click.option('--os-type', '-o',
25+
help='Operating System Type (eg. LINUX) of the primary volume for '
26+
'which a replica is ordered [optional].',
3327
type=click.Choice([
3428
'HYPER_V',
3529
'LINUX',
@@ -38,22 +32,39 @@
3832
'WINDOWS_GPT',
3933
'WINDOWS',
4034
'XEN']))
35+
@click.option('--snapshot-schedule', '-s',
36+
help='Snapshot schedule to use for replication. Options are: '
37+
'HOURLY, DAILY, WEEKLY',
38+
required=True,
39+
type=click.Choice(['HOURLY', 'DAILY', 'WEEKLY']))
40+
@click.option('--tier', '-t',
41+
help='Endurance Storage Tier (IOPS per GB) of the primary volume for which a replica is ordered '
42+
'[optional]. If no tier is specified, the tier of the original volume will be used',
43+
type=click.Choice(['0.25', '2', '4', '10']))
4144
@environment.pass_env
42-
def cli(env, volume_id, snapshot_schedule, location, tier, os_type):
45+
def cli(env, volume_id, snapshot_schedule, datacenter, tier, os_type, iops):
4346
"""Order a block storage replica volume."""
4447
block_manager = SoftLayer.BlockStorageManager(env.client)
4548
block_volume_id = helpers.resolve_id(block_manager.resolve_ids, volume_id, 'Block Volume')
4649

4750
if tier is not None:
4851
tier = float(tier)
4952

53+
if iops is not None:
54+
if iops < 100 or iops > 6000:
55+
raise exceptions.ArgumentError(f"Invalid value for '--iops' / '-i': '{iops}' is not one "
56+
"of between 100 and 6000.")
57+
if iops % 100 != 0:
58+
raise exceptions.ArgumentError(f"Invalid value for '--iops' / '-i': '{iops}' is not a multiple of 100.")
59+
5060
try:
5161
order = block_manager.order_replicant_volume(
5262
block_volume_id,
5363
snapshot_schedule=snapshot_schedule,
54-
location=location,
64+
location=datacenter,
5565
tier=tier,
5666
os_type=os_type,
67+
iops=iops
5768
)
5869
except ValueError as ex:
5970
raise exceptions.ArgumentError(str(ex))

SoftLayer/CLI/block/replication/partners.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1616
@click.argument('volume-id')
17-
@click.option('--sortby', help='Column to sort by', default='Username')
1817
@click.option('--columns',
1918
callback=column_helper.get_formatter(COLUMNS),
2019
help='Columns to display. Options: {0}'.format(
2120
', '.join(column.name for column in COLUMNS)),
2221
default=','.join(DEFAULT_COLUMNS))
22+
@click.option('--sortby', help='Column to sort by', default='Username')
2323
@environment.pass_env
2424
def cli(env, columns, sortby, volume_id):
25-
"""List existing replicant volumes for a block volume."""
25+
"""List existing replica volumes for a block volume."""
2626
block_storage_manager = SoftLayer.BlockStorageManager(env.client)
2727

2828
legal_volumes = block_storage_manager.get_replication_partners(

SoftLayer/managers/storage.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def order_replicant_volume(self,
217217
snapshot_schedule,
218218
location,
219219
tier=None,
220-
os_type=None):
220+
os_type=None,
221+
iops=None):
221222
"""Places an order for a replicant volume.
222223
223224
:param volume_id: The ID of the primary volume to be replicated
@@ -239,9 +240,12 @@ def order_replicant_volume(self,
239240
storage_class = storage_utils.block_or_file(
240241
block_volume['storageType']['keyName'])
241242

243+
if iops is None:
244+
iops = int(block_volume['provisionedIops'])
245+
242246
order = storage_utils.prepare_replicant_order_object(
243247
self, snapshot_schedule, location, tier, block_volume,
244-
storage_class)
248+
storage_class, iops)
245249

246250
if storage_class == 'block':
247251
if os_type is None:

SoftLayer/managers/storage_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def _get_order_type_and_category(service_offering, storage_type, volume_type):
645645

646646

647647
def prepare_replicant_order_object(manager, snapshot_schedule, location,
648-
tier, volume, volume_type):
648+
tier, volume, volume_type, iops):
649649
"""Prepare the order object which is submitted to the placeOrder() method
650650
651651
:param manager: The File or Block manager calling this function
@@ -730,7 +730,7 @@ def prepare_replicant_order_object(manager, snapshot_schedule, location,
730730
"A replica volume cannot be ordered for this performance "
731731
"volume since it does not support Encryption at Rest.")
732732
volume_is_performance = True
733-
iops = int(volume['provisionedIops'])
733+
734734
prices = [
735735
find_price_by_category(package, billing_item_category_code),
736736
find_price_by_category(package, 'storage_' + volume_type),

tests/CLI/modules/block_tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ def test_replicant_order_order_not_placed(self, order_mock):
625625

626626
result = self.run_command(['block', 'replica-order', '100',
627627
'--snapshot-schedule=DAILY',
628-
'--location=dal05'])
628+
'--datacenter=dal05',
629+
'--iops=100'])
629630

630631
self.assert_no_fail(result)
631632
self.assertEqual(result.output,
@@ -650,7 +651,8 @@ def test_replicant_order(self, order_mock):
650651

651652
result = self.run_command(['block', 'replica-order', '100',
652653
'--snapshot-schedule=DAILY',
653-
'--location=dal05', '--tier=2'])
654+
'--datacenter=dal05', '--tier=2',
655+
'--iops=100'])
654656

655657
self.assert_no_fail(result)
656658
self.assertEqual(result.output,

tests/managers/storage_utils_tests.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,7 +3259,7 @@ def test_prep_replicant_order_volume_cancelled(self):
32593259
exception = self.assertRaises(
32603260
exceptions.SoftLayerError,
32613261
storage_utils.prepare_replicant_order_object,
3262-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3262+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
32633263
)
32643264

32653265
self.assertEqual(
@@ -3275,7 +3275,7 @@ def test_prep_replicant_order_volume_cancellation_date_set(self):
32753275
exception = self.assertRaises(
32763276
exceptions.SoftLayerError,
32773277
storage_utils.prepare_replicant_order_object,
3278-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3278+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
32793279
)
32803280

32813281
self.assertEqual(
@@ -3292,7 +3292,7 @@ def test_prep_replicant_order_snapshot_space_cancelled(self):
32923292
exception = self.assertRaises(
32933293
exceptions.SoftLayerError,
32943294
storage_utils.prepare_replicant_order_object,
3295-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3295+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
32963296
)
32973297

32983298
self.assertEqual(
@@ -3310,7 +3310,7 @@ def test_prep_replicant_order_invalid_location(self):
33103310
exception = self.assertRaises(
33113311
exceptions.SoftLayerError,
33123312
storage_utils.prepare_replicant_order_object,
3313-
self.block, 'WEEKLY', 'hoth02', None, mock_volume, 'block'
3313+
self.block, 'WEEKLY', 'hoth02', None, mock_volume, 'block', 100
33143314
)
33153315

33163316
self.assertEqual(
@@ -3329,7 +3329,7 @@ def test_prep_replicant_order_enterprise_offering_invalid_type(self):
33293329
exception = self.assertRaises(
33303330
exceptions.SoftLayerError,
33313331
storage_utils.prepare_replicant_order_object,
3332-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3332+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
33333333
)
33343334

33353335
self.assertEqual(
@@ -3348,7 +3348,7 @@ def test_prep_replicant_order_snapshot_capacity_not_found(self):
33483348
exception = self.assertRaises(
33493349
exceptions.SoftLayerError,
33503350
storage_utils.prepare_replicant_order_object,
3351-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3351+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
33523352
)
33533353

33543354
self.assertEqual(
@@ -3385,7 +3385,7 @@ def test_prep_replicant_order_saas_endurance(self):
33853385
}
33863386

33873387
result = storage_utils.prepare_replicant_order_object(
3388-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3388+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
33893389
)
33903390

33913391
self.assertEqual(expected_object, result)
@@ -3419,7 +3419,7 @@ def test_prep_replicant_order_saas_endurance_tier_is_not_none(self):
34193419
}
34203420

34213421
result = storage_utils.prepare_replicant_order_object(
3422-
self.block, 'WEEKLY', 'wdc04', 2, mock_volume, 'block'
3422+
self.block, 'WEEKLY', 'wdc04', 2, mock_volume, 'block', 100
34233423
)
34243424

34253425
self.assertEqual(expected_object, result)
@@ -3437,7 +3437,7 @@ def test_prep_replicant_order_saas_performance_volume_below_staas_v2(self):
34373437
exception = self.assertRaises(
34383438
exceptions.SoftLayerError,
34393439
storage_utils.prepare_replicant_order_object,
3440-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3440+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
34413441
)
34423442

34433443
self.assertEqual(
@@ -3472,12 +3472,12 @@ def test_prep_replicant_order_saas_performance(self):
34723472
'originVolumeId': 102,
34733473
'originVolumeScheduleId': 978,
34743474
'volumeSize': 500,
3475-
'iops': 1000,
3475+
'iops': 100,
34763476
'useHourlyPricing': False
34773477
}
34783478

34793479
result = storage_utils.prepare_replicant_order_object(
3480-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3480+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
34813481
)
34823482

34833483
self.assertEqual(expected_object, result)
@@ -3494,7 +3494,7 @@ def test_prep_replicant_order_saas_invalid_storage_type(self):
34943494
exception = self.assertRaises(
34953495
exceptions.SoftLayerError,
34963496
storage_utils.prepare_replicant_order_object,
3497-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3497+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
34983498
)
34993499

35003500
self.assertEqual(
@@ -3534,7 +3534,7 @@ def test_prep_replicant_order_ent_endurance(self):
35343534
}
35353535

35363536
result = storage_utils.prepare_replicant_order_object(
3537-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3537+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
35383538
)
35393539

35403540
self.assertEqual(expected_object, result)
@@ -3569,7 +3569,7 @@ def test_prep_replicant_order_ent_endurance_tier_is_not_none(self):
35693569
}
35703570

35713571
result = storage_utils.prepare_replicant_order_object(
3572-
self.block, 'WEEKLY', 'wdc04', 2, mock_volume, 'block'
3572+
self.block, 'WEEKLY', 'wdc04', 2, mock_volume, 'block', 100
35733573
)
35743574

35753575
self.assertEqual(expected_object, result)
@@ -3604,7 +3604,7 @@ def test_prep_replicant_order_hourly_billing(self):
36043604
}
36053605

36063606
result = storage_utils.prepare_replicant_order_object(
3607-
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block'
3607+
self.block, 'WEEKLY', 'wdc04', None, mock_volume, 'block', 100
36083608
)
36093609

36103610
self.assertEqual(expected_object, result)

0 commit comments

Comments
 (0)