def generate_snapshot_metadata(context, image_api, image_id, instance):
    """Generate a metadata dictionary for an instance snapshot.

    :param context: Nova security context
    :param image_api: Handle to the glance image API.
    :param image_id: UUID of the prepared glance image.
    :param instance: The Nova instance whose disk is to be snapshotted.
    :return: A dict of metadata suitable for image_api.update.
    """
    image = image_api.get(context, image_id)
    metadata = {'name': image['name'], 'status': 'active', 'disk_format':
        'raw', 'container_format': 'bare', 'properties': {'image_location':
        'snapshot', 'image_state': 'available', 'owner_id': instance.
        project_id}}
    return metadata
