in src/ansible_collections/alibaba/apsarastack/plugins/modules/ali_route_entry.py [0:0]
def create_route_entry(module):
"""
Create VSwitch
:param module: Ansible module object
:param vpc: Authenticated vpc connection object
:return: Return details of created VSwitch
"""
destination_cidrblock = module.params['destination_cidrblock']
nexthop_type = module.params['nexthop_type']
nexthop_id = module.params['nexthop_id']
route_table_id = module.params['route_table_id']
route_entry_name = module.params['name']
if not nexthop_id:
module.fail_json(msg='nexthop_id is required for creating a route entry.')
if not destination_cidrblock:
module.fail_json(msg='destination_cidrblock is required for creating a route entry.')
try:
route_entry_params = {
'RouteTableId': route_table_id,
'NextHopType': nexthop_type,
'NextHopId': nexthop_id,
"DestinationCidrBlock": destination_cidrblock,
"RouteEntryName": route_entry_name
}
if do_create_route_entry(module, route_entry_params):
route_entry = do_get_route_entry(module, route_table_id, destination_cidrblock)
if route_entry:
return route_entry
except VPCResponseError as e:
module.fail_json(msg='Unable to create route entry, error: {0}'.format(e))