def get_image(conn, vm_):
    vm_image = config.get_cloud_config_value('image', vm_, __opts__).encode(
        'ascii', 'salt-cloud-force-ascii'
    )

    for item in conn.list_images()['items']:
        img = {'id': item['id'], 'name': item['properties']['name']}

        if isinstance(img['id'], string_types):
            img_id = img['id'].encode('ascii', 'salt-cloud-force-ascii')
        else:
            img_id = str(img['id'])

        if isinstance(img['name'], string_types):
            img_name = img['name'].encode('ascii', 'salt-cloud-force-ascii')
        else:
            img_name = str(img['name'])

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

    raise SaltCloudNotFound(
        'The specified image, \'{0}\', could not be found.'.format(vm_image)
    )
Optionally initialize a new instance.
dataset/ETHPy150Open saltstack/salt/salt/cloud/clouds/profitbricks.py/get_image--crossover with--dataset/ETHPy150Open nicolaiarocci/cerberus/cerberus/errors.py/BaseErrorHandler.__init__