'Validates whether an image_id (AMI) is compatible with a given
instance_type. image_id_setting and instance_type_setting are the
setting labels in the config file.'

def __check_platform(self, image_id, instance_type):

    image = self.cluster.ec2.get_image_or_none(image_id)
    if (not image):
        raise exception.ClusterValidationError(('Image    %s    does    not    exist' % image_id))
    image_platform = image.architecture
    image_is_hvm = (image.virtualization_type == 'hvm')
    if (image_is_hvm and (instance_type not in static.HVM_TYPES)):
        cctypes_list = ',    '.join(static.HVM_TYPES)
        raise exception.ClusterValidationError(("Image    '%s'    is    a    hardware    virtual    machine    (HVM)    image    and    cannot    be    used    with    instance    type    '%s'.\n\nHVM    images    require    one    of    the    following    HVM    instance    types:\n%s" % (image_id, instance_type, cctypes_list)))
    if ((instance_type in static.HVM_ONLY_TYPES) and (not image_is_hvm)):
        raise exception.ClusterValidationError(("The    '%s'    instance    type    can    only    be    used    with    hardware    virtual    machine    (HVM)    images.    Image    '%s'    is    not    an    HVM    image." % (instance_type, image_id)))
    instance_platforms = static.INSTANCE_TYPES[instance_type]
    if (image_platform not in instance_platforms):
        error_msg = 'Instance    type    %(instance_type)s    is    for    an    %(instance_platform)s    platform    while    %(image_id)s    is    an    %(image_platform)s    platform'
        error_dict = {'instance_type': instance_type, 'instance_platform': ',    '.join(instance_platforms), 'image_id': image_id, 'image_platform': image_platform}
        raise exception.ClusterValidationError((error_msg % error_dict))
    image_is_ebs = (image.root_device_type == 'ebs')
    if ((instance_type in static.EBS_ONLY_TYPES) and (not image_is_ebs)):
        error_msg = ("Instance    type    %s    can    only    be    used    with    an    EBS-backed    AMI    and    '%s'    is    not    EBS-backed    " % (instance_type, image.id))
        raise exception.ClusterValidationError(error_msg)
    return True
