-
Notifications
You must be signed in to change notification settings - Fork 194
dedicatedhost cancel, cancel-guests, and list-guests commands #1075
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
Conversation
…ded and some unittests
It failed due to my latest commit, I will fix it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just need a few changes to cancel_guest.
""" | ||
return self.host.deleteObject(id=host_id) | ||
|
||
def cancel_guests(self, host_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this function, I'd like it to be able to return a structure that has a bit more information about what guests were canceled so the slcli
can print out a receipt.
Ideally id, FQDN, and whether the guest was canceled or got an error
return = [
{'id': 1234, 'fqdn': 'test01.test.com', 'status': 'canceled' },
{'id': 1235, 'fqdn': 'test02.test.com', 'status': 'Exception: Running Transaction or something' },
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, it returns a dictionary and it is empty if there isn't any guest in the dedicated host. The slcli
prints a table or a message in case the dict is empty.
SoftLayer/managers/dedicated_host.py
Outdated
|
||
if guests: | ||
for vs in guests: | ||
result = self.guest.deleteObject(id=vs['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to wrap this in a try/catch for SoftLayer.Exceptions. I can see a case where one guest will have a running transaction and won't be able to be canceled. So we don't want this command to fail midway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, is in the method called _delete_guest
. I also added a unit-test to verify the exception message is retrieved in case the deleteObject fails
if not (env.skip_confirmations or formatting.no_going_back(host_id)): | ||
raise exceptions.CLIAbort('Aborted') | ||
|
||
result = dh_mgr.cancel_guests(host_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After updated the manager function, just add a way to print out a nice table with the results of each guests' cancelation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. It prints a table like below
$ slcli --really dh cancel-guests 33333
:..........:...........................:..................................................................:
: id : server name : status :
:..........:...........................:..................................................................:
: 1111111 : foobar.softlayer.com : Cancelled :
: 2222222 : wombat.softlayer.com : Exception: A billing item is required to process a cancellation. :
:..........:...........................:..................................................................:
slcli dh cancel
makes a simple call to the deleteObject method of dedicated host.slcli dh cancel-guests
cancels all guests into the dedicated hostsslcli dh list-guests
lists guests in the dedicated host, it should be possible to filter, sortby and display more columns in the tableIt should cover the request #1041