Skip to content
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
5 changes: 4 additions & 1 deletion SoftLayer/CLI/modules/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ class CancelServer(environment.CLIRunnable):
Cancel a dedicated server

Options:
--immediate Cancels the server immediately (instead of on the billing
anniversary)
--comment=COMMENT An optional comment to add to the cancellation ticket
--reason=REASON An optional cancellation reason. See cancel-reasons for a
list of available options
Expand All @@ -271,9 +273,10 @@ def execute(self, args):
comment = self.env.input("(Optional) Add a cancellation comment:")

reason = args.get('--reason')
immediate = args.get('--immediate')

if args['--really'] or formatting.no_going_back(hw_id):
mgr.cancel_hardware(hw_id, reason, comment)
mgr.cancel_hardware(hw_id, reason, comment, immediate)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this change, a test needs to be adjusted to pass: https://travis-ci.org/softlayer/softlayer-python/jobs/34486666#L601

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

else:
raise exceptions.CLIAbort('Aborted')

Expand Down
7 changes: 4 additions & 3 deletions SoftLayer/managers/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def __init__(self, client, ordering_manager=None):
else:
self.ordering_manager = ordering_manager

def cancel_hardware(self, hardware_id, reason='unneeded', comment=''):
def cancel_hardware(self, hardware_id, reason='unneeded', comment='',
immediate=False):
""" Cancels the specified dedicated server.

:param int hardware_id: The ID of the hardware to be cancelled.
Expand All @@ -48,7 +49,7 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment=''):
mask='id,bareMetalInstanceFlag')

if server.get('bareMetalInstanceFlag'):
return self.cancel_metal(hardware_id)
return self.cancel_metal(hardware_id, immediate)

reasons = self.get_cancellation_reasons()
cancel_reason = reasons['unneeded']
Expand Down Expand Up @@ -224,7 +225,7 @@ def get_available_dedicated_server_packages(self):

for package in packages:
available_packages.append((package['id'], package['name'],
package['description']))
package.get('description', None)))

return available_packages

Expand Down
4 changes: 2 additions & 2 deletions SoftLayer/managers/ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def filter_outlet_packages(packages):
non_outlet_packages = []

for package in packages:
if all(['OUTLET' not in package['description'].upper(),
'OUTLET' not in package['name'].upper()]):
if all(['OUTLET' not in package.get('description', '').upper(),
'OUTLET' not in package.get('name', '').upper()]):
non_outlet_packages.append(package)

return non_outlet_packages
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/tests/CLI/modules/server_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def test_cancel_server(self, resolve_mock, cancel_mock, ngb_mock):
args = {'--really': True, '--reason': 'Test'}
runnable.execute(args)

cancel_mock.assert_called_with(hw_id, args['--reason'], None)
cancel_mock.assert_called_with(hw_id, args['--reason'], None, None)

# Now check to make sure we properly call CLIAbort in the negative case
env_mock = mock.Mock()
Expand Down