DimensionData - Handle exception when powering off a node that is already powered off #912

Merged
merged 6 commits into from Oct 24, 2016

Conversation

Projects
None yet
4 participants
@samuelchong
Contributor

samuelchong commented Oct 17, 2016

Changes Title (replace this with a logical title for your changes)

Description

-Handle exception when powering off a node that is already stopped

  • This will be no longer throw exception if it already powered off

Status

  • done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)
libcloud/common/dimensiondata.py
@@ -561,7 +563,7 @@ def wait_for_state(self, state, func, poll_interval=2, timeout=60, *args,
sleep(poll_interval)
cnt += 1
- msg = 'Status check for object %s timed out' % (result)
+ msg = 'Status check for object %s timed out' % result

This comment has been minimized.

@Kami

Kami Oct 18, 2016

Member

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).

@Kami

Kami Oct 18, 2016

Member

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']

This comment has been minimized.

@Kami

Kami Oct 18, 2016

Member

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.

@Kami

Kami Oct 18, 2016

Member

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.

This comment has been minimized.

@samuelchong

samuelchong Oct 20, 2016

Contributor

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.

@samuelchong

samuelchong Oct 20, 2016

Contributor

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.

@Kami

This comment has been minimized.

Show comment
Hide comment
@Kami

Kami Oct 18, 2016

Member

LGTM, thanks.

Member

Kami commented Oct 18, 2016

LGTM, thanks.

@tonybaloney

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney Oct 24, 2016

Contributor

👍

Contributor

tonybaloney commented Oct 24, 2016

👍

@asfgit asfgit merged commit 64793fd into apache:trunk Oct 24, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

asfgit pushed a commit that referenced this pull request Oct 24, 2016

asfgit pushed a commit that referenced this pull request Oct 24, 2016

@samuelchong samuelchong deleted the samuelchong:enhance_get_resource_state branch Oct 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment