|
5 | 5 | import SoftLayer |
6 | 6 | from SoftLayer.CLI import environment |
7 | 7 | from SoftLayer.CLI import exceptions |
| 8 | +from SoftLayer import utils |
8 | 9 |
|
9 | 10 |
|
10 | 11 | CONTEXT_SETTINGS = {'token_normalize_func': lambda x: x.upper()} |
|
20 | 21 | 'Potential Sizes: [20, 40, 80, 100, 250, ' |
21 | 22 | '500, 1000, 2000, 4000, 8000, 12000] ' |
22 | 23 | 'Minimum: [the size of the origin volume] ' |
23 | | - 'Maximum: [the minimum of 12000 GB or ' |
24 | | - '10*(origin volume size)]') |
| 24 | + 'Maximum: 12000 GB.') |
25 | 25 | @click.option('--new-iops', '-i', |
26 | 26 | type=int, |
27 | 27 | help='Performance Storage IOPS, between 100 and 6000 in ' |
|
37 | 37 | help='Endurance Storage Tier (IOPS per GB) [only used for ' |
38 | 38 | 'endurance volumes] ***If no tier is specified, the original tier ' |
39 | 39 | 'of the volume will be used.***\n' |
40 | | - 'Requirements: [IOPS/GB for the volume is 0.25, ' |
| 40 | + 'Requirements: [If original IOPS/GB for the volume is 0.25, ' |
41 | 41 | 'new IOPS/GB for the volume must also be 0.25. If original IOPS/GB ' |
42 | 42 | 'for the volume is greater than 0.25, new IOPS/GB ' |
43 | 43 | 'for the volume must also be greater than 0.25.]', |
|
46 | 46 | def cli(env, volume_id, new_size, new_iops, new_tier): |
47 | 47 | """Modify an existing file storage volume.""" |
48 | 48 | file_manager = SoftLayer.FileStorageManager(env.client) |
| 49 | + |
| 50 | + file_volume = file_manager.get_file_volume_details(volume_id) |
| 51 | + file_volume = utils.NestedDict(file_volume) |
| 52 | + |
| 53 | + storage_type = file_volume['storageType']['keyName'].split('_').pop(0) |
| 54 | + help_message = "For help, try \"slcli file volume-modify --help\"" |
| 55 | + |
| 56 | + if storage_type == 'ENDURANCE': |
| 57 | + if new_iops is not None: |
| 58 | + raise exceptions.CLIAbort( |
| 59 | + 'Invalid option --new-iops for Endurance volume. Please use --new-tier instead.') |
| 60 | + |
| 61 | + if new_size is None and new_tier is None: |
| 62 | + raise exceptions.CLIAbort( |
| 63 | + 'Option --new-size or --new-tier must be specified for modifying an Endurance volume. \n'+ |
| 64 | + help_message |
| 65 | + ) |
| 66 | + |
| 67 | + if storage_type == 'PERFORMANCE': |
| 68 | + if new_tier is not None: |
| 69 | + raise exceptions.CLIAbort( |
| 70 | + 'Invalid option --new-tier for Performance volume. Please use --new-iops instead.') |
| 71 | + |
| 72 | + if new_size is None and new_iops is None: |
| 73 | + raise exceptions.CLIAbort( |
| 74 | + 'Option --new-size or --new-iops must be specified for modifying a Performance volume. \n' + |
| 75 | + help_message |
| 76 | + ) |
49 | 77 |
|
50 | 78 | if new_tier is not None: |
51 | 79 | new_tier = float(new_tier) |
|
0 commit comments