Use rax_find_loadbalancer utility method.
This commit is contained in:
parent
1a8ed52819
commit
e1cdda56ff
1 changed files with 1 additions and 20 deletions
|
@ -120,26 +120,7 @@ def cloud_load_balancer_ssl(module, loadbalancer, state, enabled, private_key,
|
||||||
|
|
||||||
# Locate the load balancer.
|
# Locate the load balancer.
|
||||||
|
|
||||||
clb = pyrax.cloud_loadbalancers
|
balancer = rax_find_loadbalancer(module, pyrax, loadbalancer)
|
||||||
if not clb:
|
|
||||||
module.fail_json(msg='Failed to instantiate client. This '
|
|
||||||
'typically indicates an invalid region or an '
|
|
||||||
'incorrectly capitalized region name.')
|
|
||||||
|
|
||||||
balancers = []
|
|
||||||
for balancer in clb.list():
|
|
||||||
if loadbalancer == balancer.name or loadbalancer == str(balancer.id):
|
|
||||||
balancers.append(balancer)
|
|
||||||
|
|
||||||
if not balancers:
|
|
||||||
module.fail_json(msg='No load balancers matched your criteria. '
|
|
||||||
'Use rax_clb to create the balancer first.')
|
|
||||||
|
|
||||||
if len(balancers) > 1:
|
|
||||||
module.fail_json(msg="%d load balancers were matched your criteria. Try"
|
|
||||||
"using the balancer's id instead." % len(balancers))
|
|
||||||
|
|
||||||
balancer = balancers[0]
|
|
||||||
existing_ssl = balancer.get_ssl_termination()
|
existing_ssl = balancer.get_ssl_termination()
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
Loading…
Reference in a new issue