DimensionData - Handle exception when powering off a node that is already powered off#912
Conversation
libcloud/common/dimensiondata.py
Outdated
| cnt += 1 | ||
|
|
||
| msg = 'Status check for object %s timed out' % (result) | ||
| msg = 'Status check for object %s timed out' % result |
There was a problem hiding this comment.
For safety reasons I would leave parenthesis there - if you add another format string and format to add parenthesis there it will break during run-time so it's usually safer to just always include parenthesis (this way it's impossible to forget to add them later if and when you add another format string argument).
| r = self.ex_get_node_by_id(node.id) | ||
| response_code = r.state.upper() | ||
|
|
||
| return response_code in ['IN_PROGRESS', 'OK', 'STOPPED', 'STOPPING'] |
There was a problem hiding this comment.
This looks good to me, but maybe we should consider throwing an exception if node is already in stopping / stopped state.
That's more just me thinking out loud, I'm also fine with current approach.
There was a problem hiding this comment.
Thx @Kami for your comment. My intension is to make it more user friendly; As long as the aim is achieved, doesn't matter if the state a precondition or the result of the operation, as long as it is 'STOPPED', I'm happy, no exception.
Throwing exception will means one will have to check the state every time. More code. Open for discussion.
|
LGTM, thanks. |
|
👍 |
Changes Title (replace this with a logical title for your changes)
Description
-Handle exception when powering off a node that is already stopped
Status
Checklist (tick everything that applies)