in src/ansible_collections/alibaba/apsarastack/plugins/modules/ali_vswitch.py [0:0]
def vswitch_exists(conn, module, vswitch_id, vpc_id, cidr):
try:
for vsw in conn.describe_vswitches():
if cidr and vsw.cidr_block != cidr:
continue
if vpc_id and vpc_id != vsw.vpc_id:
continue
if vswitch_id and vswitch_id != vsw.vswitch_id:
continue
return vsw
except Exception as e:
module.fail_json(msg="Couldn't get matching subnet: {0}".format(e))