Merge pull request #8832 from sivel/rax-validate-regions
rax modules: Perform region validation early
This commit is contained in:
commit
b827f791e1
3 changed files with 6 additions and 5 deletions
|
@ -212,7 +212,7 @@ def rax_required_together():
|
||||||
return [['api_key', 'username']]
|
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 = 'ansible/%s %s' % (ANSIBLE_VERSION,
|
||||||
rax_module.USER_AGENT)
|
rax_module.USER_AGENT)
|
||||||
|
|
||||||
|
@ -270,7 +270,8 @@ def setup_rax_module(module, rax_module):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module.fail_json(msg='%s' % e.message)
|
module.fail_json(msg='%s' % e.message)
|
||||||
|
|
||||||
rax_module.USER_AGENT = 'ansible/%s %s' % (ANSIBLE_VERSION,
|
if region_required and region not in rax_module.regions:
|
||||||
rax_module.USER_AGENT)
|
module.fail_json(msg='%s is not a valid region, must be one of: %s' %
|
||||||
|
(region, ','.join(rax_module.regions)))
|
||||||
|
|
||||||
return rax_module
|
return rax_module
|
||||||
|
|
|
@ -160,7 +160,7 @@ def main():
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
ttl = module.params.get('ttl')
|
ttl = module.params.get('ttl')
|
||||||
|
|
||||||
setup_rax_module(module, pyrax)
|
setup_rax_module(module, pyrax, False)
|
||||||
|
|
||||||
rax_dns(module, comment, email, name, state, ttl)
|
rax_dns(module, comment, email, name, state, ttl)
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ def main():
|
||||||
ttl = module.params.get('ttl')
|
ttl = module.params.get('ttl')
|
||||||
record_type = module.params.get('type')
|
record_type = module.params.get('type')
|
||||||
|
|
||||||
setup_rax_module(module, pyrax)
|
setup_rax_module(module, pyrax, False)
|
||||||
|
|
||||||
if record_type.upper() == 'PTR':
|
if record_type.upper() == 'PTR':
|
||||||
if not server and not loadbalancer:
|
if not server and not loadbalancer:
|
||||||
|
|
Loading…
Reference in a new issue