Skip to content

Commit da4593e

Browse files
committed
Incorporating review comments
1 parent 854087e commit da4593e

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

SoftLayer/CLI/block/snapshot/set_notify_status.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99

1010
@click.command()
1111
@click.argument('volume_id')
12-
@click.option(
13-
'--notification_flag',
12+
@click.option('--enable/--disable', default=True,
1413
help=
15-
'Enable / disable sending sending notifications for snapshots space usage threshold warning [True|False]',
14+
'Enable/Disable snapshot usage warning notification. Use `slcli block snapshot-set-notification volumeId --enable` to enable',
1615
required=True)
1716
@environment.pass_env
18-
def cli(env, volume_id, notification_flag):
17+
def cli(env, volume_id, enable):
1918
"""Enables/Disables snapshot space usage threshold warning for a given volume"""
20-
if (notification_flag not in ['True', 'False']):
21-
raise exceptions.CLIAbort('--notification-flag must be True or False')
22-
2319
block_manager = SoftLayer.BlockStorageManager(env.client)
24-
disabled = block_manager.set_block_volume_snapshot_notification(
25-
volume_id, notification_flag)
2620

27-
if disabled:
21+
if enable:
22+
enabled = 'True'
23+
else:
24+
enabled = 'False'
25+
status = block_manager.set_block_volume_snapshot_notification(
26+
volume_id, enabled)
27+
28+
if status:
2829
click.echo(
2930
'Snapshots space usage threshold warning notification has bee set to %s for volume %s'
30-
% (notification - flag, volume_id))
31+
% (enabled, volume_id))

SoftLayer/CLI/file/snapshot/set_notify_status.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99

1010
@click.command()
1111
@click.argument('volume_id')
12-
@click.option(
13-
'--notification_flag',
12+
@click.option('--enable/--disable', default=True,
1413
help=
15-
'Enable / disable sending sending notifications for snapshots space usage threshold warning [True|False]',
14+
'Enable/Disable snapshot usage warning notification. Use `slcli block snapshot-set-notification volumeId --enable` to enable' ,
1615
required=True)
1716
@environment.pass_env
18-
def cli(env, volume_id, notification_flag):
17+
def cli(env, volume_id, enable):
1918
"""Enables/Disables snapshot space usage threshold warning for a given volume"""
20-
21-
if (notification_flag not in ['True', 'False']):
22-
raise exceptions.CLIAbort('--notification-flag must be True or False')
23-
2419
file_manager = SoftLayer.FileStorageManager(env.client)
25-
disabled = file_manager.set_file_volume_snapshot_notification(
26-
volume_id, notification_flag)
2720

28-
if disabled:
21+
if enable:
22+
enabled = 'True'
23+
else:
24+
enabled = 'False'
25+
26+
status = file_manager.set_file_volume_snapshot_notification(
27+
volume_id, enabled)
28+
if status:
2929
click.echo(
3030
'Snapshots space usage threshold warning notification has bee set to %s for volume %s'
31-
% (notification - flag, volume_id))
31+
% (enable, volume_id))

SoftLayer/managers/storage.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,23 @@ def get_volume_snapshot_list(self, volume_id, **kwargs):
112112
kwargs['mask'] = ','.join(items)
113113

114114
return self.client.call('Network_Storage', 'getSnapshots', id=volume_id, **kwargs)
115-
def set_volume_snapshot_notification(self, volume_id, notification_flag, **kwargs):
116-
"""Returns a list of snapshots for the specified volume.
115+
def set_volume_snapshot_notification(self, volume_id, enable):
116+
"""Enables/Disables snapshot space usage threshold warning for a given volume.
117117
118118
:param volume_id: ID of volume.
119-
:param kwargs:
120-
:return: Returns a list of snapshots for the specified volume.
119+
:param enable: Enable/Disable flag for snapshot warning notification.
120+
:return: Enables/Disables snapshot space usage threshold warning for a given volume.
121121
"""
122122

123-
return self.client.call('Network_Storage', 'setSnapshotNotification', notification_flag, id=volume_id , **kwargs)
123+
return self.client.call('Network_Storage', 'setSnapshotNotification', enable, id=volume_id)
124+
125+
def get_volume_snapshot_notification_status(self, volume_id):
126+
"""returns Enabled/Disabled status of snapshot space usage threshold warning for a given volume.
127+
128+
:param volume_id: ID of volume.
129+
:return: Enables/Disables snapshot space usage threshold warning for a given volume.
130+
"""
131+
return self.client.call('Network_Storage', 'getSnapshotNotificationStatus', id=volume_id)
124132

125133
def authorize_host_to_volume(self, volume_id, hardware_ids=None, virtual_guest_ids=None,
126134
ip_address_ids=None, subnet_ids=None):

0 commit comments

Comments
 (0)