Use disk_format and container_format instead of image type
This commit is contained in:
parent
b238805d2e
commit
dd2f001929
@ -450,7 +450,7 @@ class Controller(wsgi.Controller):
|
||||
_("Cannot build from image %(image_id)s, status not active") %
|
||||
locals())
|
||||
|
||||
if image['type'] != 'machine':
|
||||
if image['disk_format'] != 'ami':
|
||||
return None, None
|
||||
|
||||
try:
|
||||
|
@ -467,19 +467,21 @@ class VMHelper(HelperBase):
|
||||
"%(image_id)s, instance %(instance_id)s") % locals())
|
||||
|
||||
def determine_from_glance():
|
||||
glance_type2nova_type = {'machine': ImageType.DISK,
|
||||
'raw': ImageType.DISK_RAW,
|
||||
'vhd': ImageType.DISK_VHD,
|
||||
'kernel': ImageType.KERNEL_RAMDISK,
|
||||
'ramdisk': ImageType.KERNEL_RAMDISK}
|
||||
glance_disk_format2nova_type = {
|
||||
'ami': ImageType.DISK,
|
||||
'aki': ImageType.KERNEL_RAMDISK,
|
||||
'ari': ImageType.KERNEL_RAMDISK,
|
||||
'raw': ImageType.DISK_RAW,
|
||||
'vhd': ImageType.DISK_VHD}
|
||||
client = glance.client.Client(FLAGS.glance_host, FLAGS.glance_port)
|
||||
meta = client.get_image_meta(instance.image_id)
|
||||
type_ = meta['type']
|
||||
disk_format = meta['disk_format']
|
||||
try:
|
||||
return glance_type2nova_type[type_]
|
||||
return glance_disk_format2nova_type[disk_format]
|
||||
except KeyError:
|
||||
raise exception.NotFound(
|
||||
_("Unrecognized image type '%(type_)s'") % locals())
|
||||
_("Unrecognized disk_format '%(disk_format)s'")
|
||||
% locals())
|
||||
|
||||
def determine_from_instance():
|
||||
if instance.kernel_id:
|
||||
|
@ -201,13 +201,21 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port):
|
||||
# to request
|
||||
conn.putrequest('PUT', '/images/%s' % image_id)
|
||||
|
||||
# TODO(sirp): make `store` configurable
|
||||
# NOTE(sirp): There is some confusion around OVF. Here's a summary of
|
||||
# where we currently stand:
|
||||
# 1. OVF as a container format is misnamed. We really should be using
|
||||
# OVA since that is the name for the container format; OVF is the
|
||||
# standard applied to the manifest file contained within.
|
||||
# 2. We're currently uploading a vanilla tarball. In order to be OVF/OVA
|
||||
# compliant, we'll need to embed a minimal OVF manifest as the first
|
||||
# file.
|
||||
headers = {
|
||||
'content-type': 'application/octet-stream',
|
||||
'transfer-encoding': 'chunked',
|
||||
'x-image-meta-is_public': 'True',
|
||||
'x-image-meta-is-public': 'True',
|
||||
'x-image-meta-status': 'queued',
|
||||
'x-image-meta-type': 'vhd'}
|
||||
'x-image-meta-disk-format': 'vhd',
|
||||
'x-image-meta-container-format': 'ovf'}
|
||||
for header, value in headers.iteritems():
|
||||
conn.putheader(header, value)
|
||||
conn.endheaders()
|
||||
|
Loading…
x
Reference in New Issue
Block a user