Skip to content

Commit

Permalink
Perform region validation early to be more explicit about invalid reg…
Browse files Browse the repository at this point in the history
…ion failures
  • Loading branch information
sivel committed Sep 2, 2014
1 parent 69e7999 commit 55ed448
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/ansible/module_utils/rax.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def rax_required_together():
return [['api_key', 'username']]


def setup_rax_module(module, rax_module):
def setup_rax_module(module, rax_module, region_required=True):
rax_module.USER_AGENT = 'ansible/%s %s' % (ANSIBLE_VERSION,
rax_module.USER_AGENT)

Expand Down Expand Up @@ -270,7 +270,8 @@ def setup_rax_module(module, rax_module):
except Exception, e:
module.fail_json(msg='%s' % e.message)

rax_module.USER_AGENT = 'ansible/%s %s' % (ANSIBLE_VERSION,
rax_module.USER_AGENT)
if region_required and region not in rax_module.regions:
module.fail_json(msg='%s is not a valid region, must be one of: %s' %
(region, ','.join(rax_module.regions)))

return rax_module
2 changes: 1 addition & 1 deletion library/cloud/rax_dns
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def main():
state = module.params.get('state')
ttl = module.params.get('ttl')

setup_rax_module(module, pyrax)
setup_rax_module(module, pyrax, False)

rax_dns(module, comment, email, name, state, ttl)

Expand Down
2 changes: 1 addition & 1 deletion library/cloud/rax_dns_record
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def main():
ttl = module.params.get('ttl')
record_type = module.params.get('type')

setup_rax_module(module, pyrax)
setup_rax_module(module, pyrax, False)

if record_type.upper() == 'PTR':
if not server and not loadbalancer:
Expand Down

0 comments on commit 55ed448

Please sign in to comment.