def get_region(apiclient, services=None): "Returns a default region" cmd = listRegions.listRegionsCmd() if services: if "regionid" in services: cmd.id = services["regionid"] regions = apiclient.listRegions(cmd) if isinstance(regions, list): assert len(regions) > 0 return regions[0] else: raise Exception("Failed to find specified region.")
def get_region(apiclient, region_id=None, region_name=None): """ @name : get_region @Desc : Returns the Region Information for a given region id or region name @Input : region_name: Name of the Region region_id : Id of the region @Output : 1. Region Information for the passed inputs else first Region 2. FAILED In case the cmd failed """ cmd = listRegions.listRegionsCmd() if region_name is not None: cmd.name = region_name if region_id is not None: cmd.id = region_id cmd_out = apiclient.listRegions(cmd) return FAILED if validateList(cmd_out)[0] != PASS else cmd_out[0]
def get_region(apiclient, region_id=None, region_name=None): ''' @name : get_region @Desc : Returns the Region Information for a given region id or region name @Input : region_name: Name of the Region region_id : Id of the region @Output : 1. Region Information for the passed inputs else first Region 2. FAILED In case the cmd failed ''' cmd = listRegions.listRegionsCmd() if region_name is not None: cmd.name = region_name if region_id is not None: cmd.id = region_id cmd_out = apiclient.listRegions(cmd) return FAILED if validateList(cmd_out)[0] != PASS else cmd_out[0]