Skip to content

Commit 76c4203

Browse files
Merge pull request #1554 from harihkrishna/snapshot_notify
Snapshot notify
2 parents e68ff9b + e23440d commit 76c4203

File tree

8 files changed

+326
-72
lines changed

8 files changed

+326
-72
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+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@environment.pass_env
12+
def cli(env, volume_id):
13+
"""Get snapshots space usage threshold warning flag setting for a given volume"""
14+
block_manager = SoftLayer.BlockStorageManager(env.client)
15+
enabled = block_manager.get_volume_snapshot_notification_status(volume_id)
16+
17+
if enabled == '':
18+
click.echo("""
19+
Enabled:Snapshots space usage warning flag is null. Set to default value enable. For volume %s
20+
""" % (volume_id))
21+
elif enabled == 'True':
22+
click.echo(
23+
'Enabled:Snapshots space usage threshold warning flag setting is enabled for volume %s'
24+
% (volume_id))
25+
else:
26+
click.echo(
27+
'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+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@click.option(
12+
'--enable/--disable',
13+
default=True,
14+
help="""
15+
Enable/Disable snapshot notification. Use `slcli block snapshot-set-notification volumeId --enable` to enable
16+
""",
17+
required=True)
18+
@environment.pass_env
19+
def cli(env, volume_id, enable):
20+
"""Enables/Disables snapshot space usage threshold warning for a given volume"""
21+
block_manager = SoftLayer.BlockStorageManager(env.client)
22+
23+
status = block_manager.set_volume_snapshot_notification(volume_id, enable)
24+
25+
if status:
26+
click.echo(
27+
'Snapshots space usage threshold warning notification has bee set to %s for volume %s'
28+
% (enable, volume_id))
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@environment.pass_env
12+
def cli(env, volume_id):
13+
"""Get snapshots space usage threshold warning flag setting for a given volume"""
14+
15+
file_manager = SoftLayer.FileStorageManager(env.client)
16+
enabled = file_manager.get_volume_snapshot_notification_status(volume_id)
17+
18+
if enabled == '':
19+
click.echo(
20+
'Enabled:Snapshots space usage threshold warning flag is null. Set to default value enable. For volume %s'
21+
% (volume_id))
22+
elif enabled == 'True':
23+
click.echo(
24+
'Enabled:Snapshots space usage threshold warning flag setting is enabled for volume %s'
25+
% (volume_id))
26+
else:
27+
click.echo(
28+
'Disabled:Snapshots space usage threshold warning flag setting is disabled for volume %s'
29+
% (volume_id))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@click.option(
12+
'--enable/--disable',
13+
default=True,
14+
help='Enable/Disable snapshot notification. Use `slcli file snapshot-set-notification volumeId --enable` to enable',
15+
required=True)
16+
@environment.pass_env
17+
def cli(env, volume_id, enable):
18+
"""Enables/Disables snapshot space usage threshold warning for a given volume"""
19+
file_manager = SoftLayer.FileStorageManager(env.client)
20+
21+
status = file_manager.set_volume_snapshot_notification(volume_id, enable)
22+
if status:
23+
click.echo(
24+
'Snapshots space usage threshold warning notification has bee set to %s for volume %s'
25+
% (enable, 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'),

0 commit comments

Comments
 (0)