def get_location(conn, vm_):
    '''
    Return the location object to use
    '''
    locations = conn.list_locations()
    vm_location = config.get_cloud_config_value('location', vm_, __opts__)
    if not six.PY3:
        vm_location = vm_location.encode(
            'ascii', 'salt-cloud-force-ascii'
        )

    for img in locations:
        if isinstance(img.id, six.string_types) and not six.PY3:
            img_id = img.id.encode('ascii', 'salt-cloud-force-ascii')
        else:
            img_id = str(img.id)  # future lint: disable=blacklisted-function

        if isinstance(img.name, six.string_types) and not six.PY3:
            img_name = img.name.encode('ascii', 'salt-cloud-force-ascii')
        else:
            img_name = str(img.name)  # future lint: disable=blacklisted-function

        if vm_location and vm_location in (img_id, img_name):
            return img

    raise SaltCloudNotFound(
        'The specified location, \'{0}\', could not be found.'.format(
            vm_location
        )
    )
def get_location ( conn , vm_ ) : locations = conn . list_locations ( ) vm_location = config . get_cloud_config_value ( 'location' , vm_ , __opts__ ) if not six . PY3 : vm_location = vm_location . encode ( 'ascii' , 'salt-cloud-force-ascii' ) for img in locations : if isinstance ( img . id , six . string_types ) and not six . PY3 : img_id = img . id . encode ( 'ascii' , 'salt-cloud-force-ascii' ) else : img_id = str ( img . id ) if isinstance ( img . name , six . string_types ) and not six . PY3 : img_name = img . name . encode ( 'ascii' , 'salt-cloud-force-ascii' ) else : img_name = str ( img . name ) if vm_location and vm_location in ( img_id , img_name ) : return img raise SaltCloudNotFound ( 'The specified location, \'{0}\', could not be found.' . format ( vm_location ) )
Return the location object to use