Skip to content

Commit 0d0f8e6

Browse files
caberoscaberos
authored andcommitted
fix the team code review comments
1 parent 170fff3 commit 0d0f8e6

File tree

10 files changed

+50
-7
lines changed

10 files changed

+50
-7
lines changed

SoftLayer/CLI/routes.py

Lines changed: 2 additions & 1 deletion
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'),
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 hardware 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_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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ def create_credential(self, template):
11111111
return self.client.call('SoftLayer_Software_Component_Password', 'createObject', template)
11121112

11131113
def remove_notification(self, identifier):
1114-
"""Create a password for a software component"""
1114+
"""Remove a user hardware notification entry"""
11151115

11161116
template = [{'id': identifier}]
11171117
return self.client.call('SoftLayer_User_Customer_Notification_Hardware', 'deleteObjects', template)

SoftLayer/managers/vs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,3 +1470,9 @@ def add_notification(self, virtual_id, user_id):
14701470
mask = 'user'
14711471
return self.client.call('SoftLayer_User_Customer_Notification_Virtual_Guest',
14721472
'createObject', template, mask=mask)
1473+
1474+
def remove_notification(self, identifier):
1475+
"""Remove a user vs notification entry"""
1476+
1477+
template = [{'id': identifier}]
1478+
return self.client.call('SoftLayer_User_Customer_Notification_Virtual_Guest', 'deleteObjects', template)

docs/cli/vs.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,12 @@ If no timezone is specified, IMS local time (CST) will be assumed, which might n
283283
:prog: virtual notifications
284284
:show-nested:
285285

286-
.. click:: SoftLayer.CLI.virt.add_notification:cli
287-
:prog: virtual add-notification
286+
.. click:: SoftLayer.CLI.virt.notification_add:cli
287+
:prog: virtual notification-add
288+
:show-nested:
289+
290+
.. click:: SoftLayer.CLI.virt.notification_delete:cli
291+
:prog: virtual notification-delete
288292
:show-nested:
289293

290294
Manages the migration of virutal guests. Supports migrating virtual guests on Dedicated Hosts as well.

tests/CLI/modules/vs/vs_tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,5 +984,9 @@ def test_notifications(self):
984984
self.assert_no_fail(result)
985985

986986
def test_add_notification(self):
987-
result = self.run_command(['vs', 'add-notification', '100', '--users', '123456'])
987+
result = self.run_command(['vs', 'notification-add', '100', '--users', '123456'])
988+
self.assert_no_fail(result)
989+
990+
def test_notification_delete(self):
991+
result = self.run_command(['vs', 'notification-delete', '100'])
988992
self.assert_no_fail(result)

tests/managers/vs/vs_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,3 +1338,7 @@ def test_notification(self):
13381338
def test_add_notification(self):
13391339
self.vs.add_notification(100, 123456)
13401340
self.assert_called_with('SoftLayer_User_Customer_Notification_Virtual_Guest', 'createObject')
1341+
1342+
def test_notification_del(self):
1343+
self.vs.remove_notification(100)
1344+
self.assert_called_with('SoftLayer_User_Customer_Notification_Virtual_Guest', 'deleteObjects')

0 commit comments

Comments
 (0)