Skip to content

Improved successful response to command - slcli vlan cancel #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SoftLayer/CLI/account/cancel_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ def cli(env, identifier):
manager = AccountManager(env.client)
item = manager.cancel_item(identifier)

env.fout(item)
if item:
env.fout("Item: {} was cancelled.".format(identifier))
13 changes: 9 additions & 4 deletions SoftLayer/CLI/virt/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ def cli(env, identifier, domain, userfile, tag, hostname, userdata,

vsi = SoftLayer.VSManager(env.client)
vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
if not vsi.edit(vs_id, **data):
raise exceptions.CLIAbort("Failed to update virtual server")

if vsi.edit(vs_id, **data):
for key, value in data.items():
if value is not None:
env.fout("The {} of virtual server instance: {} was updated.".format(key, vs_id))

if public_speed is not None:
vsi.change_port_speed(vs_id, True, int(public_speed))
if vsi.change_port_speed(vs_id, True, int(public_speed)):
env.fout("The public speed of virtual server instance: {} was updated.".format(vs_id))

if private_speed is not None:
vsi.change_port_speed(vs_id, False, int(private_speed))
if vsi.change_port_speed(vs_id, False, int(private_speed)):
env.fout("The private speed of virtual server instance: {} was updated.".format(vs_id))
9 changes: 5 additions & 4 deletions SoftLayer/CLI/vlan/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def cli(env, identifier):
raise exceptions.CLIAbort(reasons)
item = mgr.get_vlan(identifier).get('billingItem')
if item:
mgr.cancel_item(item.get('id'),
True,
'Cancel by cli command',
'Cancel by cli command')
if mgr.cancel_item(item.get('id'),
True,
'Cancel by cli command',
'Cancel by cli command'):
env.fout("VLAN {} was cancelled.".format(identifier))
else:
raise exceptions.CLIAbort(
"VLAN is an automatically assigned and free of charge VLAN,"
Expand Down
8 changes: 7 additions & 1 deletion tests/CLI/modules/vs/vs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,13 @@ def test_edit(self):
'100'])

self.assert_no_fail(result)
self.assertEqual(result.output, '')
expected_output = '"The userdata of virtual server instance: 100 was updated."\n' \
+ '"The hostname of virtual server instance: 100 was updated."\n' \
+ '"The domain of virtual server instance: 100 was updated."\n' \
+ '"The tags of virtual server instance: 100 was updated."\n' \
+ '"The public speed of virtual server instance: 100 was updated."\n' \
+ '"The private speed of virtual server instance: 100 was updated."\n'
self.assertEqual(result.output, expected_output)

self.assert_called_with(
'SoftLayer_Virtual_Guest', 'editObject',
Expand Down