|
5 | 5 | import SoftLayer |
6 | 6 | from SoftLayer.CLI import environment |
7 | 7 | from SoftLayer.CLI import exceptions |
| 8 | +from SoftLayer.CLI import formatting |
8 | 9 | from SoftLayer.CLI import helpers |
9 | 10 | from SoftLayer import utils |
10 | 11 |
|
|
27 | 28 | help='Endurance Storage Tier (IOPS per GB) of the primary' |
28 | 29 | ' volume for which a replicant is ordered [optional]', |
29 | 30 | type=click.Choice(['0.25', '2', '4', '10'])) |
| 31 | +@click.option('--iops', '-i', type=int, |
| 32 | + help='Performance Storage IOPs, between 100 and 6000 in multiples of 100,' |
| 33 | + 'if no IOPS value is specified, the IOPS value of the original volume will be used', |
| 34 | + ) |
| 35 | +@click.option('--force', default=False, is_flag=True, help="Force cancel block volume without confirmation") |
30 | 36 | @environment.pass_env |
31 | | -def cli(env, volume_id, snapshot_schedule, location, tier): |
32 | | - """Order a file storage replica volume.""" |
| 37 | +def cli(env, volume_id, snapshot_schedule, location, tier, iops, force): |
| 38 | + """Order a file storage replica volume. |
| 39 | +
|
| 40 | + Example:: |
| 41 | + slcli file replica-order 12345678 -s DAILY -d dal09 --tier 4 --os-type LINUX |
| 42 | + This command orders a replica for volume with ID 12345678, which performs DAILY |
| 43 | + replication, is located at dal09, tier level is 4, OS type is Linux. |
| 44 | + """ |
33 | 45 | file_manager = SoftLayer.FileStorageManager(env.client) |
34 | 46 | file_volume_id = helpers.resolve_id(file_manager.resolve_ids, volume_id, 'File Storage') |
35 | 47 |
|
36 | 48 | if tier is not None: |
37 | 49 | tier = float(tier) |
38 | 50 |
|
| 51 | + if iops is not None: |
| 52 | + if iops < 100 or iops > 6000: |
| 53 | + raise exceptions.CLIHalt("-i|--iops must be between 100 and 6000, inclusive. " |
| 54 | + "Run 'slcli block volume-options' to check available options.") |
| 55 | + |
| 56 | + if iops % 100 != 0: |
| 57 | + raise exceptions.CLIHalt("-i|--iops must be a multiple of 100. " |
| 58 | + "Run 'slcli block volume-options' to check available options.") |
| 59 | + |
| 60 | + if not force: |
| 61 | + if not (env.skip_confirmations or |
| 62 | + formatting.confirm(f"This will Order a file storage replica volume: {volume_id} " |
| 63 | + "and cannot be undone. Continue?")): |
| 64 | + raise exceptions.CLIAbort('Aborted.') |
| 65 | + |
39 | 66 | try: |
40 | 67 | order = file_manager.order_replicant_volume( |
41 | 68 | file_volume_id, |
42 | 69 | snapshot_schedule=snapshot_schedule, |
43 | 70 | location=location, |
44 | | - tier=tier, |
| 71 | + tier=tier, iops=iops, |
45 | 72 | ) |
46 | 73 | except ValueError as ex: |
47 | 74 | raise exceptions.ArgumentError(str(ex)) |
|
0 commit comments