Skip to content

Commit

Permalink
Improve module ali_slb_vsg and ali_slb_vsg_facts
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Jan 3, 2019
1 parent b1276a6 commit 97a022a
Show file tree
Hide file tree
Showing 7 changed files with 699 additions and 426 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FEATURES:

IMPROVEMENTS:

- Improve module ali_slb_vsg and ali_slb_vsg_facts ([#148](https://github.com/alibaba/ansible-provider/pull/148))
- Improve module ali_slb_lb and ali_slb_lb_facts ([#147](https://github.com/alibaba/ansible-provider/pull/147))
- Improve ecs instance and eni docs ([#146](https://github.com/alibaba/ansible-provider/pull/146))
- Improve module ali_eip and add its testcase ([#145](https://github.com/alibaba/ansible-provider/pull/145))
Expand Down
15 changes: 10 additions & 5 deletions lib/ansible/modules/cloud/alicloud/ali_slb_lb_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
returned: when success
type: list
sample: ["lb-dj1oi1h5l74hg22gsnugf", "lb-dj1t1xwn0y9zcr90e52i2"]
names:
description: List names of being fetched slb.
returned: when success
type: list
sample: ["ansible-foo", "ansible-bar"]
load_balancers:
description:
- info about the server load balancer that was created or deleted.
Expand Down Expand Up @@ -278,6 +283,7 @@ def main():
lb_ids.append(value)
lbs = []
ids = []
names = []

try:
slb = slb_connect(module)
Expand All @@ -286,24 +292,23 @@ def main():
ids_tmp = lb_ids[index:index + 10]
if not ids_tmp:
break
id_str = ""
for id in ids_tmp:
id_str += id + ','
filters['load_balancer_id'] = id_str[:-1]
filters['load_balancer_id'] = ",".join(ids_tmp)

for lb in slb.describe_load_balancers(**filters):
if name_prefix and not str(lb.load_balancer_name).startswith(name_prefix):
continue
lbs.append(lb.read())
ids.append(lb.load_balancer_id)
names.append(lb.load_balancer_name)
else:
for lb in slb.describe_load_balancers(**filters):
if name_prefix and not str(lb.load_balancer_name).startswith(name_prefix):
continue
lbs.append(lb.read())
ids.append(lb.load_balancer_id)
names.append(lb.load_balancer_name)

module.exit_json(changed=False, load_balancers=lbs, ids=ids)
module.exit_json(changed=False, load_balancers=lbs, ids=ids, names=names)
except Exception as e:
module.fail_json(msg="Unable to describe server load balancers, and got an error: {0}.".format(e))

Expand Down
Loading

0 comments on commit 97a022a

Please sign in to comment.