Skip to content

Commit 4af5860

Browse files
Merge branch 'issue1772' of https://github.com/caberos/softlayer-python into caberos-issue1772
2 parents 4db35de + 6dd9da9 commit 4af5860

17 files changed

+98
-12
lines changed
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Remove a user hardware notification entry."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
9+
10+
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
11+
@click.argument('identifier')
12+
@environment.pass_env
13+
def cli(env, identifier):
14+
"""Remove a user hardware notification entry."""
15+
16+
hardware = SoftLayer.HardwareManager(env.client)
17+
18+
result = hardware.remove_notification(identifier)
19+
20+
if result:
21+
env.fout("The hardware notification instance: {} was deleted.".format(identifier))

SoftLayer/CLI/hardware/notifications.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ def cli(env, identifier):
1818

1919
notifications = hardware.get_notifications(identifier)
2020

21-
table = formatting.KeyValueTable(['Domain', 'Hostmane', 'Username', 'Email', 'FirstName', 'Lastname'])
21+
table = formatting.KeyValueTable(['Id', 'Domain', 'Hostmane', 'Username', 'Email', 'FirstName', 'Lastname'])
2222
table.align['Domain'] = 'r'
2323
table.align['Username'] = 'l'
2424

2525
for notification in notifications:
26-
table.add_row([notification['hardware']['fullyQualifiedDomainName'], notification['hardware']['hostname'],
26+
table.add_row([notification['id'],
27+
notification['hardware']['fullyQualifiedDomainName'], notification['hardware']['hostname'],
2728
notification['user']['username'], notification['user']['email'],
2829
notification['user']['firstName'], notification['user']['lastName']])
2930

SoftLayer/CLI/routes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
('virtual:access', 'SoftLayer.CLI.virt.access:cli'),
5656
('virtual:monitoring', 'SoftLayer.CLI.virt.monitoring:cli'),
5757
('virtual:notifications', 'SoftLayer.CLI.virt.notifications:cli'),
58-
('virtual:add-notification', 'SoftLayer.CLI.virt.add_notification:cli'),
58+
('virtual:notification-add', 'SoftLayer.CLI.virt.notification_add:cli'),
59+
('virtual:notification-delete', 'SoftLayer.CLI.virt.notification_delete:cli'),
5960

6061
('dedicatedhost', 'SoftLayer.CLI.dedicatedhost'),
6162
('dedicatedhost:list', 'SoftLayer.CLI.dedicatedhost.list:cli'),
@@ -295,7 +296,8 @@
295296
('hardware:sensor', 'SoftLayer.CLI.hardware.sensor:cli'),
296297
('hardware:monitoring', 'SoftLayer.CLI.hardware.monitoring:cli'),
297298
('hardware:notifications', 'SoftLayer.CLI.hardware.notifications:cli'),
298-
('hardware:add-notification', 'SoftLayer.CLI.hardware.add_notification:cli'),
299+
('hardware:notification-add', 'SoftLayer.CLI.hardware.notification_add:cli'),
300+
('hardware:notification-delete', 'SoftLayer.CLI.hardware.notification_delete:cli'),
299301
('hardware:create-credential', 'SoftLayer.CLI.hardware.create_credential:cli'),
300302

301303
('securitygroup', 'SoftLayer.CLI.securitygroup'),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Remove a user VS notification entry."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
9+
10+
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
11+
@click.argument('identifier')
12+
@environment.pass_env
13+
def cli(env, identifier):
14+
"""Remove a user VS notification entry."""
15+
16+
virtual = SoftLayer.VSManager(env.client)
17+
18+
result = virtual.remove_notification(identifier)
19+
20+
if result:
21+
env.fout("The virtual server notification instance: {} was deleted.".format(identifier))

SoftLayer/CLI/virt/notifications.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ def cli(env, identifier):
1818

1919
notifications = virtual.get_notifications(identifier)
2020

21-
table = formatting.KeyValueTable(['Domain', 'Hostmane', 'Username', 'Email', 'FirstName', 'Lastname'])
21+
table = formatting.KeyValueTable(['Id', 'Domain', 'Hostmane', 'Username', 'Email', 'FirstName', 'Lastname'])
2222
table.align['Domain'] = 'r'
2323
table.align['Username'] = 'l'
2424

2525
for notification in notifications:
26-
table.add_row([notification['guest']['fullyQualifiedDomainName'], notification['guest']['hostname'],
26+
table.add_row([notification['id'],
27+
notification['guest']['fullyQualifiedDomainName'], notification['guest']['hostname'],
2728
notification['user']['username'], notification['user']['email'],
2829
notification['user']['lastName'], notification['user']['firstName']])
2930

SoftLayer/fixtures/SoftLayer_User_Customer_Notification_Hardware.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@
6868

6969
}
7070
}
71+
72+
deleteObjects = True

SoftLayer/fixtures/SoftLayer_User_Customer_Notification_Virtual_Guest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@
5353
'username': 'test',
5454
}
5555
}
56+
57+
deleteObjects = True

SoftLayer/managers/hardware.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,12 @@ def create_credential(self, template):
11101110
"""Create a password for a software component"""
11111111
return self.client.call('SoftLayer_Software_Component_Password', 'createObject', template)
11121112

1113+
def remove_notification(self, identifier):
1114+
"""Remove a user hardware notification entry"""
1115+
1116+
template = [{'id': identifier}]
1117+
return self.client.call('SoftLayer_User_Customer_Notification_Hardware', 'deleteObjects', template)
1118+
11131119

11141120
def _get_bandwidth_key(items, hourly=True, no_public=False, location=None):
11151121
"""Picks a valid Bandwidth Item, returns the KeyName"""

0 commit comments

Comments
 (0)