Skip to content

Commit

Permalink
Merge pull request #2121 from allmightyspiff/issues2107
Browse files Browse the repository at this point in the history
Removed requirements in volume-modify commands
  • Loading branch information
allmightyspiff authored Jan 2, 2024
2 parents ed587b5 + fead52b commit 3e8bd0e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion SoftLayer/CLI/block/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def cli(env, sortby, datacenter):
Example::
slcli block volume-limits
This command lists the storage limits per datacenter for this account.
"""
"""

block_manager = SoftLayer.BlockStorageManager(env.client)
block_volumes = block_manager.list_block_volume_limit()
Expand Down
19 changes: 9 additions & 10 deletions SoftLayer/CLI/block/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@
@click.option('--new-iops', '-i',
type=int,
help='Performance Storage IOPS, between 100 and 6000 in multiples of 100 [only for performance volumes] '
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***\n'
'Requirements: [If original IOPS/GB for the volume is less than 0.3, new IOPS/GB must also be '
'less than 0.3. If original IOPS/GB for the volume is greater than or equal to 0.3, new IOPS/GB '
'for the volume must also be greater than or equal to 0.3.]')
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***')
@click.option('--new-tier', '-t',
help='Endurance Storage Tier (IOPS per GB) [only for endurance volumes] '
'***If no tier is specified, the original tier of the volume will be used.***\n'
'Requirements: [If original IOPS/GB for the volume is 0.25, new IOPS/GB for the volume must also '
'be 0.25. If original IOPS/GB for the volume is greater than 0.25, new IOPS/GB for the volume '
'must also be greater than 0.25.]',
help='Endurance Storage Tier (IOPS per GB) [only for endurance volumes] Classic Choices: '
'***If no tier is specified, the original tier of the volume will be used.***',
type=click.Choice(['0.25', '2', '4', '10']))
@environment.pass_env
def cli(env, volume_id, new_size, new_iops, new_tier):
"""Modify an existing block storage volume.
"""Modify an existing block storage volume. Choices.
Valid size and iops options can be found here:
https://cloud.ibm.com/docs/BlockStorage/index.html#provisioning-considerations
https://cloud.ibm.com/docs/BlockStorage?topic=BlockStorage-orderingBlockStorage&interface=cli
Example::
slcli block volume-modify 12345678 --new-size 1000 --new-iops 4000
This command modify a volume 12345678 with size is 1000GB, IOPS is 4000.
Expand Down
9 changes: 6 additions & 3 deletions SoftLayer/CLI/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class OptionHighlighter(RegexHighlighter):
r"(?P<option>\-\-[\w\-]+)", # long options like --verbose
r"(?P<default_option>\[[^\]]+\])", # anything between [], usually default options
r"(?P<option_choices>Choices: )",
r"(?P<example_block>Example::)",
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)"
r"(?P<args_keyword>^[A-Z]+$)",
]

Expand Down Expand Up @@ -91,7 +93,7 @@ def format_help_text(self, ctx: click.Context, formatter: click.formatting.HelpF

if text:
text = inspect.cleandoc(text).partition("\f")[0]
self.console.print(f"\n\t{text}\n")
self.console.print(f"\n\t{text}\n", highlight=True)

def format_epilog(self, ctx: click.Context, formatter: click.formatting.HelpFormatter) -> None:
"""Writes the epilog if it exists, then prints out any sub-commands if they exist."""
Expand Down Expand Up @@ -191,9 +193,10 @@ def format_help_text(self, ctx: click.Context, formatter: click.formatting.HelpF
text = f"(Deprecated) {text}"

if text:
text = inspect.cleandoc(text)
text = f"\n\t{inspect.cleandoc(text)}\n"

self.console.print(f"\n\t{text}\n", highlight=False)
# Can't use F-string here because it messes with highlights
self.console.print(self.highlighter(text))

def format_epilog(self, ctx: click.Context, formatter: click.formatting.HelpFormatter) -> None:
"""Writes the epilog if it exists, then prints out any sub-commands if they exist."""
Expand Down
15 changes: 7 additions & 8 deletions SoftLayer/CLI/file/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,22 @@
@click.option('--new-iops', '-i',
type=int,
help='Performance Storage IOPS, between 100 and 6000 in multiples of 100 [only for performance volumes] '
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***\n'
'Requirements: [If original IOPS/GB for the volume is less than 0.3, new IOPS/GB must also be '
'less than 0.3. If original IOPS/GB for the volume is greater than or equal to 0.3, new IOPS/GB '
'for the volume must also be greater than or equal to 0.3.]')
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***')
@click.option('--new-tier', '-t',
help='Endurance Storage Tier (IOPS per GB) [only for endurance volumes] '
'***If no tier is specified, the original tier of the volume will be used.***\n'
'Requirements: [If original IOPS/GB for the volume is 0.25, new IOPS/GB for the volume must also '
'be 0.25. If original IOPS/GB for the volume is greater than 0.25, new IOPS/GB for the volume '
'must also be greater than 0.25.]',
'***If no tier is specified, the original tier of the volume will be used.***',
type=click.Choice(['0.25', '2', '4', '10']))
@click.option('--force', default=False, is_flag=True, help="Force modify")
@environment.pass_env
def cli(env, volume_id, new_size, new_iops, new_tier, force):
"""Modify an existing file storage volume.
Valid size and iops options can be found here:
https://cloud.ibm.com/docs/FileStorage/index.html#provisioning-considerations
https://cloud.ibm.com/docs/FileStorage?topic=FileStorage-orderingFileStorage&interface=cli
Example::
slcli file volume-modify 12345678 --new-size 1000 --new-iops 400
"""
if not force:
Expand Down
6 changes: 1 addition & 5 deletions SoftLayer/managers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,7 @@ def order_duplicate_volume(self,

return self.client.call('Product_Order', 'placeOrder', order)

def order_modified_volume(self,
volume_id,
new_size=None,
new_iops=None,
new_tier_level=None):
def order_modified_volume(self, volume_id, new_size=None, new_iops=None, new_tier_level=None):
"""Places an order for modifying an existing block volume.
:param volume_id: The ID of the volume to be modified
Expand Down
6 changes: 2 additions & 4 deletions SoftLayer/managers/storage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ def find_snapshot_schedule_id(volume, snapshot_schedule_keyname):
if schedule['type']['keyname'] == snapshot_schedule_keyname:
return schedule['id']

raise ValueError("The given snapshot schedule ID was not found for "
"the given storage volume")
raise ValueError("The given snapshot schedule ID was not found for the given storage volume")


def prepare_snapshot_order_object(manager, volume, capacity, tier, upgrade, iops):
Expand All @@ -436,8 +435,7 @@ def prepare_snapshot_order_object(manager, volume, capacity, tier, upgrade, iops
"""
# Ensure the storage volume has not been cancelled
if 'billingItem' not in volume:
raise exceptions.SoftLayerError(
'This volume has been cancelled; unable to order snapshot space')
raise exceptions.SoftLayerError('This volume has been cancelled; unable to order snapshot space')

# Determine and validate the storage volume's billing item category
billing_item_category_code = volume['billingItem']['categoryCode']
Expand Down
4 changes: 4 additions & 0 deletions SoftLayer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ def console_color_themes(theme):
"option_keyword": "bold dark_cyan",
"args_keyword": "underline orange4",
"option_choices": "gold3",
"example_block": "underline deep_pink3",
"url": "underline blue",
})
)
return Console(theme=Theme(
Expand All @@ -509,6 +511,8 @@ def console_color_themes(theme):
"option_keyword": "bold cyan",
"args_keyword": "underline yellow",
"option_choices": "gold3",
"example_block": "underline light_coral",
"url": "underline blue",
})
)

Expand Down

0 comments on commit 3e8bd0e

Please sign in to comment.