catch exposed cs.exceptions instead of novaclient
This commit is contained in:
parent
c2d34efd21
commit
ff1570ea31
1 changed files with 4 additions and 8 deletions
12
cloud/rax
12
cloud/rax
|
@ -162,8 +162,6 @@ except ImportError:
|
|||
print("failed=True msg='pyrax is required for this module'")
|
||||
sys.exit(1)
|
||||
|
||||
import novaclient.exceptions
|
||||
|
||||
ACTIVE_STATUSES = ('ACTIVE', 'BUILD', 'HARD_REBOOT', 'MIGRATING', 'PASSWORD',
|
||||
'REBOOT', 'REBUILD', 'RESCUE', 'RESIZE', 'REVERT_RESIZE')
|
||||
FINAL_STATUSES = ('ACTIVE', 'ERROR')
|
||||
|
@ -368,14 +366,12 @@ def cloudservers(module, state, name, flavor, image, meta, key_name, files,
|
|||
except ValueError:
|
||||
try:
|
||||
image = cs.images.find(human_id=image)
|
||||
except (novaclient.exceptions.NotFound,
|
||||
pyrax.exceptions.NotFound,
|
||||
pyrax.exceptions.NoUniqueMatch):
|
||||
except(cs.exceptions.NotFound,
|
||||
cs.exceptions.NoUniqueMatch):
|
||||
try:
|
||||
image = cs.images.find(name=image)
|
||||
except (novaclient.exceptions.NotFound,
|
||||
pyrax.exceptions.NotFound,
|
||||
pyrax.exceptions.NoUniqueMatch):
|
||||
except (cs.exceptions.NotFound,
|
||||
cs.exceptions.NoUniqueMatch):
|
||||
module.fail_json(msg='No matching image found (%s)' %
|
||||
image)
|
||||
|
||||
|
|
Loading…
Reference in a new issue