lib/ansible/modules/cloud/alicloud/ali_slb_lb_info.py [84:317]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''

RETURN = '''
ids:
    description: List ids of being fetched slb.
    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.
    returned: on present
    type: complex
    contains:
        address:
            description: The IP address of the loal balancer
            returned: always
            type: str
            sample: "47.94.26.126"
        address_ipversion:
            description: The IP address version. IPV4 or IPV6.
            returned: always
            type: str
            sample: "ipv4"
        address_type:
            description: The load balancer internet type
            returned: always
            type: str
            sample: "internet"
        backend_servers:
            description: The load balancer's backend servers
            returned: always
            type: complex
            contains:
                server_id:
                    description: The backend server id
                    returned: always
                    type: str
                    sample: "i-vqunci342"
                weight:
                    description: The backend server weight
                    returned: always
                    type: int
                    sample: 100
                description:
                    description: The backend server description
                    returned: always
                    type: str
                    sample: ""
                type:
                    description: The backend server type, ecs or eni
                    returned: always
                    type: string
                    sample: "ecs"
        bandwidth:
            description: The load balancer internet bandwidth
            returned: always
            type: int
            sample: 5
        create_time:
            description: The time of the load balancer was created
            returned: always
            type: str
            sample: "2019-01-02T02:37:41Z"
        end_time:
            description: The time of the load balancer will be released
            returned: always
            type: str
            sample: "2999-09-08T16:00:00Z"
        id:
            description: The ID of the load balancer was created. Same as load_balancer_id.
            returned: always
            type: str
            sample: "lb-2zea9ohgtf"
        internet_charge_type:
            description: The load balancer internet charge type
            returned: always
            type: str
            sample: "PayByTraffic"
        listeners:
            description: The listeners of the load balancer.
            returned: always
            type: complex
            contains:
                listener_port:
                    description: The front-end port of the listener that is used to receive incoming traffic and
                     distribute the traffic to the backend servers.
                    returned: always
                    type: int
                    sample: 22
                listener_protocol:
                    description: The frontend protocol used by the SLB instance.
                    returned: always
                    type: str
                    sample: tcp
                listener_forward:
                    description: Whether to enable listener forwarding.
                    returned: always
                    type: str
                    sample: ""
                forward_port:
                    description: The destination listening port. It must be an existing HTTPS listening port.
                    returned: always
                    type: int
                    sample: 20
        load_balancer_id:
            description: The ID of the load balancer was created.
            returned: always
            type: str
            sample: "lb-2zea9ohgtf"
        load_balancer_name:
            description: The name of the load balancer was created.
            returned: always
            type: str
            sample: "ansible-ali_slb_lb"
        load_balancer_status:
            description: The load balancer current status.
            returned: always
            type: str
            sample: "active"
        master_zone_id:
            description: The ID of the primary zone.
            returned: always
            type: str
            sample: "cn-beijing-a"
        name:
            description: The name of the load balancer was created.
            returned: always
            type: str
            sample: "ansible-ali_slb_lb"
        network_type:
            description: The network type of the load balancer was created.
            returned: always
            type: str
            sample: "classic"
        pay_type:
            description: The load balancer instance charge type.
            returned: always
            type: str
            sample: "PostPaid"
        resource_group_id:
            description: The resource group of the load balancer belongs.
            returned: always
            type: str
            sample: "rg-acfmwvvtg5owavy"
        slave_zone_id:
            description: The ID of the backup zone
            returned: always
            type: str
            sample: "cn-beijing-d"
        tags:
            description: The load balancer tags
            returned: always
            type: dict
            sample: {}
        vpc_id:
            description: The vpc of the load balancer belongs.
            returned: always
            type: str
            sample: "vpc-fn3nc3"
        vswitch_id:
            description: The vswitch of the load balancer belongs.
            returned: always
            type: str
            sample: "vsw-c3nc3r"
'''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect

HAS_FOOTMARK = False

try:
    from footmark.exception import SLBResponseError

    HAS_FOOTMARK = True
except ImportError:
    HAS_FOOTMARK = False


def main():
    argument_spec = ecs_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)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugins/modules/ali_slb_lb_info.py [66:299]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''

RETURN = '''
ids:
    description: List ids of being fetched slb.
    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.
    returned: on present
    type: complex
    contains:
        address:
            description: The IP address of the loal balancer
            returned: always
            type: str
            sample: "47.94.26.126"
        address_ipversion:
            description: The IP address version. IPV4 or IPV6.
            returned: always
            type: str
            sample: "ipv4"
        address_type:
            description: The load balancer internet type
            returned: always
            type: str
            sample: "internet"
        backend_servers:
            description: The load balancer's backend servers
            returned: always
            type: complex
            contains:
                server_id:
                    description: The backend server id
                    returned: always
                    type: str
                    sample: "i-vqunci342"
                weight:
                    description: The backend server weight
                    returned: always
                    type: int
                    sample: 100
                description:
                    description: The backend server description
                    returned: always
                    type: str
                    sample: ""
                type:
                    description: The backend server type, ecs or eni
                    returned: always
                    type: string
                    sample: "ecs"
        bandwidth:
            description: The load balancer internet bandwidth
            returned: always
            type: int
            sample: 5
        create_time:
            description: The time of the load balancer was created
            returned: always
            type: str
            sample: "2019-01-02T02:37:41Z"
        end_time:
            description: The time of the load balancer will be released
            returned: always
            type: str
            sample: "2999-09-08T16:00:00Z"
        id:
            description: The ID of the load balancer was created. Same as load_balancer_id.
            returned: always
            type: str
            sample: "lb-2zea9ohgtf"
        internet_charge_type:
            description: The load balancer internet charge type
            returned: always
            type: str
            sample: "PayByTraffic"
        listeners:
            description: The listeners of the load balancer.
            returned: always
            type: complex
            contains:
                listener_port:
                    description: The front-end port of the listener that is used to receive incoming traffic and
                     distribute the traffic to the backend servers.
                    returned: always
                    type: int
                    sample: 22
                listener_protocol:
                    description: The frontend protocol used by the SLB instance.
                    returned: always
                    type: str
                    sample: tcp
                listener_forward:
                    description: Whether to enable listener forwarding.
                    returned: always
                    type: str
                    sample: ""
                forward_port:
                    description: The destination listening port. It must be an existing HTTPS listening port.
                    returned: always
                    type: int
                    sample: 20
        load_balancer_id:
            description: The ID of the load balancer was created.
            returned: always
            type: str
            sample: "lb-2zea9ohgtf"
        load_balancer_name:
            description: The name of the load balancer was created.
            returned: always
            type: str
            sample: "ansible-ali_slb_lb"
        load_balancer_status:
            description: The load balancer current status.
            returned: always
            type: str
            sample: "active"
        master_zone_id:
            description: The ID of the primary zone.
            returned: always
            type: str
            sample: "cn-beijing-a"
        name:
            description: The name of the load balancer was created.
            returned: always
            type: str
            sample: "ansible-ali_slb_lb"
        network_type:
            description: The network type of the load balancer was created.
            returned: always
            type: str
            sample: "classic"
        pay_type:
            description: The load balancer instance charge type.
            returned: always
            type: str
            sample: "PostPaid"
        resource_group_id:
            description: The resource group of the load balancer belongs.
            returned: always
            type: str
            sample: "rg-acfmwvvtg5owavy"
        slave_zone_id:
            description: The ID of the backup zone
            returned: always
            type: str
            sample: "cn-beijing-d"
        tags:
            description: The load balancer tags
            returned: always
            type: dict
            sample: {}
        vpc_id:
            description: The vpc of the load balancer belongs.
            returned: always
            type: str
            sample: "vpc-fn3nc3"
        vswitch_id:
            description: The vswitch of the load balancer belongs.
            returned: always
            type: str
            sample: "vsw-c3nc3r"
'''

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.alibaba.alicloud.plugins.module_utils.alicloud_ecs import ecs_argument_spec, slb_connect

HAS_FOOTMARK = False

try:
    from footmark.exception import SLBResponseError

    HAS_FOOTMARK = True
except ImportError:
    HAS_FOOTMARK = False


def main():
    argument_spec = ecs_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)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



