in src/ansible_collections/alibaba/apsarastack/plugins/modules/ali_slb_lb_info.py [0:0]
def main():
argument_spec = common_argument_spec()
argument_spec.update(dict(
load_balancer_name=dict(type='list', aliases=['name']),
load_balancer_ids=dict(type='list', aliases=['ids']),
name_prefix=dict(type='str'),
filters=dict(type='dict'),
tags=dict(type='dict')
))
module = AnsibleModule(argument_spec=argument_spec)
if HAS_FOOTMARK is False:
module.fail_json(msg="Package 'footmark' required for this module.")
lb_ids = module.params['load_balancer_ids']
if not lb_ids:
lb_ids = []
name_prefix = module.params['name_prefix']
filters = module.params['filters']
if not filters:
filters = {}
res = []
tags = module.params['tags']
if tags:
for key, value in tags.items():
tmp = {}
tmp['tagKey'] = key
tmp['tagValue'] = value
res.append(tmp)
filters['tags'] = res
for key, value in list(filters.items()):
if key in ["LoadBalancerId", "load-balancer-id", "load_balancer_id"] and value not in lb_ids:
lb_ids.append(value)
lbs = []
ids = []
names = []
try:
slb = slb_connect(module)
if len(lb_ids) > 0:
for index in range(0, len(lb_ids), 10):
ids_tmp = lb_ids[index:index + 10]
if not ids_tmp:
break
filters['load_balancer_id'] = ",".join(ids_tmp)