'If we are booting from a volume, we need to get the
volume details from Cinder and make sure we pass the
metadata back accordingly.'

def _get_bdm_image_metadata(self, context, block_device_mapping, legacy_bdm=True):

    if (not block_device_mapping):
        return {}
    for bdm in block_device_mapping:
        if (legacy_bdm and (block_device.get_device_letter(bdm.get('device_name', '')) != 'a')):
            continue
        elif ((not legacy_bdm) and (bdm.get('boot_index') != 0)):
            continue
        volume_id = bdm.get('volume_id')
        snapshot_id = bdm.get('snapshot_id')
        if snapshot_id:
            snapshot = self.volume_api.get_snapshot(context, snapshot_id)
            volume_id = snapshot['volume_id']
        if bdm.get('image_id'):
            try:
                image_id = bdm['image_id']
                image_meta = self.image_api.get(context, image_id)
                return image_meta
            except Exception:
                raise exception.InvalidBDMImage(id=image_id)
        elif volume_id:
            try:
                volume = self.volume_api.get(context, volume_id)
            except exception.CinderConnectionFailed:
                raise
            except Exception:
                raise exception.InvalidBDMVolume(id=volume_id)
            if (not volume.get('bootable', True)):
                raise exception.InvalidBDMVolumeNotBootable(id=volume_id)
            return utils.get_image_metadata_from_volume(volume)
    return {}
