def main()

in src/ansible_collections/alibaba/apsarastack/plugins/modules/ali_route_entry_info.py [0:0]


def main():
    argument_spec = common_argument_spec()
    argument_spec.update(dict(
        vrouter_id=dict(type='str'),
        route_table_id=dict(type='str', required=True, aliases=['id']))
    )
    module = AnsibleModule(argument_spec=argument_spec)

    if HAS_FOOTMARK is False:
        module.fail_json(msg="Package 'footmark' required for this module.")

    result = []
    vrouter_id = module.params['vrouter_id']
    route_table_id = module.params['route_table_id']


    try:
        vpc_conn = vpc_connect(module)

        # list all route entries in vrouter
        if route_table_id:
            route_tables = get_all_route_tables(module, route_table_id, vrouter_id)
            page = 1
            page_size = 50
            route_tables = []
            route_table = None
            while not route_table and len(route_tables) < page_size:
                route_tables = get_all_route_tables(module, route_table_id=route_table_id, page=page, page_size=page_size)
                for rt in route_tables:
                    if rt.get("RouteTableId") == route_table_id:
                        route_table = rt
                page + 1
            vrouter_entries = route_table["RouteEntrys"]["RouteEntry"]
            for vrouter_entry in vrouter_entries:
                result.append(get_info(vrouter_entry))
    except Exception as e:
        module.fail_json(msg="Unable to describe vrouter entries, and got an error: {0}.".format(e))

    module.exit_json(changed=False, vrouter_id=vrouter_id, route_entrys=result, total=len(result))