Skip to content

Commit cd58715

Browse files
J JayasilanJ Jayasilan
J Jayasilan
authored and
J Jayasilan
committed
--force option for slcli file volume-modify command
1 parent 9d4a287 commit cd58715

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

SoftLayer/CLI/file/modify.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import SoftLayer
66
from SoftLayer.CLI import environment
77
from SoftLayer.CLI import exceptions
8+
from SoftLayer.CLI import formatting
89

910

1011
CONTEXT_SETTINGS = {'token_normalize_func': lambda x: x.upper()}
@@ -31,13 +32,19 @@
3132
'be 0.25. If original IOPS/GB for the volume is greater than 0.25, new IOPS/GB for the volume '
3233
'must also be greater than 0.25.]',
3334
type=click.Choice(['0.25', '2', '4', '10']))
35+
@click.option('--force', default=False, is_flag=True, help="Force modify")
3436
@environment.pass_env
35-
def cli(env, volume_id, new_size, new_iops, new_tier):
37+
def cli(env, volume_id, new_size, new_iops, new_tier, force):
3638
"""Modify an existing file storage volume.
3739
3840
Examples:
3941
slcli file volume-modify 12345678 --new-size 1000 --new-iops 400
4042
"""
43+
if not force:
44+
if not (env.skip_confirmations or
45+
formatting.confirm("This action will incur charges on your account. Continue?")):
46+
raise exceptions.CLIAbort('Aborted')
47+
4148
file_manager = SoftLayer.FileStorageManager(env.client)
4249

4350
if new_tier is not None:

tests/CLI/modules/file_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,3 +820,11 @@ def test_snapshot_get_notification_status(self, status):
820820
def test_volume_options(self):
821821
result = self.run_command(['file', 'volume-options'])
822822
self.assert_no_fail(result)
823+
824+
@mock.patch('SoftLayer.CLI.formatting.confirm')
825+
def test_modify_order_no_force(self, confirm_mock):
826+
confirm_mock.return_value = False
827+
result = self.run_command(['file', 'volume-modify', '102'])
828+
829+
self.assertEqual(2, result.exit_code)
830+
self.assertEqual('Aborted', result.exception.message)

0 commit comments

Comments
 (0)