Skip to content

Commit 677f434

Browse files
committed
Changes for snapshot notification enable and disable option from slcli
Changes for snapshot notification enable and disable option from slcli
1 parent 8503904 commit 677f434

File tree

8 files changed

+152
-1
lines changed

8 files changed

+152
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Get the snapshots space usage threshold warning flag setting for specific volume"""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import exceptions
8+
9+
10+
@click.command()
11+
@click.argument('volume_id')
12+
@environment.pass_env
13+
def cli(env, volume_id):
14+
"""Get snapshots space usage threshold warning flag setting for a given volume"""
15+
16+
block_manager = SoftLayer.BlockStorageManager(env.client)
17+
enabled = block_manager.get_block_snapshots_notification_status(volume_id)
18+
19+
20+
if (enabled == ''):
21+
click.echo('Snapshots space usage threshold warning flag setting is null. Set to default value enable. For volume %s'
22+
% (volume_id))
23+
elif (enabled == 'True'):
24+
click.echo('Snapshots space usage threshold warning flag setting is enabled for volume %s'
25+
% (volume_id))
26+
else:
27+
click.echo('DISABLED: Snapshots space usage threshold warning flag setting is disabled for volume %s'
28+
% (volume_id))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Disable/Enable snapshots space usage threshold warning for a specific volume"""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import exceptions
8+
9+
10+
@click.command()
11+
@click.argument('volume_id')
12+
@click.option('--notification_flag',
13+
help='Enable / disable sending sending notifications for snapshots space usage threshold warning [True|False]',
14+
required=True)
15+
@environment.pass_env
16+
def cli(env, volume_id, notification_flag):
17+
"""Enables/Disables snapshot space usage threshold warning for a given volume"""
18+
19+
if (notification_flag not in ['True', 'False']):
20+
raise exceptions.CLIAbort(
21+
'--notification-flag must be True or False')
22+
23+
block_manager = SoftLayer.BlockStorageManager(env.client)
24+
disabled = block_manager.set_block_volume_snapshot_notification(volume_id, notification_flag)
25+
26+
if disabled:
27+
click.echo('Snapshots space usage threshold warning notification has bee set to %s for volume %s'
28+
% (notification-flag, volume_id))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Get the snapshots space usage threshold warning flag setting for specific volume"""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import exceptions
8+
9+
10+
@click.command()
11+
@click.argument('volume_id')
12+
@environment.pass_env
13+
def cli(env, volume_id):
14+
"""Get snapshots space usage threshold warning flag setting for a given volume"""
15+
16+
file_manager = SoftLayer.FileStorageManager(env.client)
17+
enabled = file_manager.get_file_snapshots_notification_status(volume_id)
18+
19+
if (enabled == ''):
20+
click.echo('Snapshots space usage threshold warning flag setting is null. Set to default value enable. For volume %s'
21+
% (volume_id))
22+
elif (enabled == 'True'):
23+
click.echo('Snapshots space usage threshold warning flag setting is enabled for volume %s'
24+
% (volume_id))
25+
else:
26+
click.echo('Snapshots space usage threshold warning flag setting is disabled for volume %s'
27+
% (volume_id))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Disable/Enable snapshots space usage threshold warning for a specific volume"""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import exceptions
8+
9+
10+
@click.command()
11+
@click.argument('volume_id')
12+
@click.option('--notification_flag',
13+
help='Enable / disable sending sending notifications for snapshots space usage threshold warning [True|False]',
14+
required=True)
15+
@environment.pass_env
16+
def cli(env, volume_id, notification_flag):
17+
"""Enables/Disables snapshot space usage threshold warning for a given volume"""
18+
19+
if (notification_flag not in ['True', 'False']):
20+
raise exceptions.CLIAbort(
21+
'--notification-flag must be True or False')
22+
23+
file_manager = SoftLayer.FileStorageManager(env.client)
24+
disabled = file_manager.set_file_volume_snapshot_notification(volume_id, notification_flag)
25+
26+
if disabled:
27+
click.echo('Snapshots space usage threshold warning notification has bee set to %s for volume %s'
28+
% (notification-flag, volume_id))

SoftLayer/CLI/routes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
('block:snapshot-create', 'SoftLayer.CLI.block.snapshot.create:cli'),
104104
('block:snapshot-delete', 'SoftLayer.CLI.block.snapshot.delete:cli'),
105105
('block:snapshot-disable', 'SoftLayer.CLI.block.snapshot.disable:cli'),
106+
('block:snapshot-set-notification', 'SoftLayer.CLI.block.snapshot.set_notify_status:cli'),
107+
('block:snapshot-get-notification-status', 'SoftLayer.CLI.block.snapshot.get_notify_status:cli'),
106108
('block:snapshot-enable', 'SoftLayer.CLI.block.snapshot.enable:cli'),
107109
('block:snapshot-schedule-list', 'SoftLayer.CLI.block.snapshot.schedule_list:cli'),
108110
('block:snapshot-list', 'SoftLayer.CLI.block.snapshot.list:cli'),
@@ -148,6 +150,8 @@
148150
('file:snapshot-delete', 'SoftLayer.CLI.file.snapshot.delete:cli'),
149151
('file:snapshot-disable', 'SoftLayer.CLI.file.snapshot.disable:cli'),
150152
('file:snapshot-enable', 'SoftLayer.CLI.file.snapshot.enable:cli'),
153+
('file:snapshot-set-notification', 'SoftLayer.CLI.file.snapshot.set_notify_status:cli'),
154+
('file:snapshot-get-notification-status', 'SoftLayer.CLI.file.snapshot.get_notify_status:cli'),
151155
('file:snapshot-schedule-list', 'SoftLayer.CLI.file.snapshot.schedule_list:cli'),
152156
('file:snapshot-list', 'SoftLayer.CLI.file.snapshot.list:cli'),
153157
('file:snapshot-order', 'SoftLayer.CLI.file.snapshot.order:cli'),

SoftLayer/managers/block.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ def get_block_volume_snapshot_list(self, volume_id, **kwargs):
102102
"""
103103
return self.get_volume_snapshot_list(volume_id, **kwargs)
104104

105+
def set_block_volume_snapshot_notification(self, volume_id, notification_flag, **kwargs):
106+
"""Enables/Disables snapshot space usage threshold warning for a given volume.
107+
108+
:param volume_id: ID of volume.
109+
:param kwargs:
110+
:param notification-flag: Enable/Disable flag for snapshot warning notification.
111+
:return: Enables/Disables snapshot space usage threshold warning for a given volume.
112+
"""
113+
return self.client.call('Network_Storage', 'setSnapshotNotification', notification_flag, id=volume_id,)
114+
115+
def get_block_snapshots_notification_status(self, volume_id, **kwargs):
116+
"""returns Enabled/Disabled snapshot space usage threshold warning for a given volume.
117+
118+
:param volume_id: ID of volume.
119+
:param kwargs:
120+
:return: Enabled/Disabled snapshot space usage threshold warning for a given volume.
121+
"""
122+
return self.client.call('Network_Storage', 'getSnapshotNotificationStatus', id=volume_id,)
123+
105124
def assign_subnets_to_acl(self, access_id, subnet_ids):
106125
"""Assigns subnet records to ACL for the access host.
107126

SoftLayer/managers/file.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,24 @@ def get_file_volume_snapshot_list(self, volume_id, **kwargs):
129129
:return: Returns a list of snapshots for the specified volume.
130130
"""
131131
return self.get_volume_snapshot_list(volume_id, **kwargs)
132+
def set_file_volume_snapshot_notification(self, volume_id, notification_flag, **kwargs):
133+
"""Enables/Disables snapshot space usage threshold warning for a given volume.
132134
135+
:param volume_id: ID of volume.
136+
:param kwargs:
137+
:param notification-flag: Enable/Disable flag for snapshot warning notification.
138+
:return: Enables/Disables snapshot space usage threshold warning for a given volume.
139+
"""
140+
return self.client.call('Network_Storage', 'setSnapshotNotification', notification_flag, id=volume_id,)
141+
142+
def get_file_snapshots_notification_status(self, volume_id, **kwargs):
143+
"""returns Enabled/Disabled snapshot space usage threshold warning for a given volume.
144+
145+
:param volume_id: ID of volume.
146+
:param kwargs:
147+
:return: Enabled/Disabled snapshot space usage threshold warning for a given volume.
148+
"""
149+
return self.client.call('Network_Storage', 'getSnapshotNotificationStatus', id=volume_id,)
133150
def order_file_volume(self, storage_type, location, size,
134151
iops=None, tier_level=None, snapshot_size=None,
135152
service_offering='storage_as_a_service',

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
setup(
1818
name='SoftLayer',
19-
version='5.9.7',
19+
version='5.9.7-dev',
2020
description=DESCRIPTION,
2121
long_description=LONG_DESCRIPTION,
2222
author='SoftLayer, Inc., an IBM Company',

0 commit comments

Comments
 (0)