catch exposed cs.exceptions instead of novaclient

This commit is contained in:
Troy C 2013-12-16 09:33:29 -06:00
parent 3007a8af7e
commit 038d030404

View file

@ -162,8 +162,6 @@ except ImportError:
print("failed=True msg='pyrax is required for this module'") print("failed=True msg='pyrax is required for this module'")
sys.exit(1) sys.exit(1)
import novaclient.exceptions
ACTIVE_STATUSES = ('ACTIVE', 'BUILD', 'HARD_REBOOT', 'MIGRATING', 'PASSWORD', ACTIVE_STATUSES = ('ACTIVE', 'BUILD', 'HARD_REBOOT', 'MIGRATING', 'PASSWORD',
'REBOOT', 'REBUILD', 'RESCUE', 'RESIZE', 'REVERT_RESIZE') 'REBOOT', 'REBUILD', 'RESCUE', 'RESIZE', 'REVERT_RESIZE')
FINAL_STATUSES = ('ACTIVE', 'ERROR') FINAL_STATUSES = ('ACTIVE', 'ERROR')
@ -368,14 +366,12 @@ def cloudservers(module, state, name, flavor, image, meta, key_name, files,
except ValueError: except ValueError:
try: try:
image = cs.images.find(human_id=image) image = cs.images.find(human_id=image)
except (novaclient.exceptions.NotFound, except(cs.exceptions.NotFound,
pyrax.exceptions.NotFound, cs.exceptions.NoUniqueMatch):
pyrax.exceptions.NoUniqueMatch):
try: try:
image = cs.images.find(name=image) image = cs.images.find(name=image)
except (novaclient.exceptions.NotFound, except (cs.exceptions.NotFound,
pyrax.exceptions.NotFound, cs.exceptions.NoUniqueMatch):
pyrax.exceptions.NoUniqueMatch):
module.fail_json(msg='No matching image found (%s)' % module.fail_json(msg='No matching image found (%s)' %
image) image)