summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/007_add_os_type_to_instances.py4
-rw-r--r--nova/virt/xenapi/vm_utils.py9
-rw-r--r--nova/virt/xenapi/vmops.py4
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/glance11
4 files changed, 18 insertions, 10 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/007_add_os_type_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/007_add_os_type_to_instances.py
index d6d964b95..21f21b040 100644
--- a/nova/db/sqlalchemy/migrate_repo/versions/007_add_os_type_to_instances.py
+++ b/nova/db/sqlalchemy/migrate_repo/versions/007_add_os_type_to_instances.py
@@ -34,7 +34,7 @@ instances_os_type = Column('os_type',
String(length=255, convert_unicode=False,
assert_unicode=None, unicode_error=None,
_warn_on_bytestring=False),
- nullable=True)
+ nullable=False)
def upgrade(migrate_engine):
@@ -43,3 +43,5 @@ def upgrade(migrate_engine):
meta.bind = migrate_engine
instances.create_column(instances_os_type)
+
+
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 11f1fabe9..9c0bb5579 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -303,7 +303,7 @@ class VMHelper(HelperBase):
return template_vm_ref, template_vdi_uuids
@classmethod
- def upload_image(cls, session, instance_id, vdi_uuids, image_id):
+ def upload_image(cls, session, instance, vdi_uuids, image_id):
""" Requests that the Glance plugin bundle the specified VDIs and
push them into Glance using the specified human-friendly name.
"""
@@ -312,15 +312,18 @@ class VMHelper(HelperBase):
logging.debug(_("Asking xapi to upload %(vdi_uuids)s as"
" ID %(image_id)s") % locals())
+ # TODO(dubs): os_type is currently defaulting to linux, we actually
+ # want to make this a NOT NULL column and require it to be specified.
params = {'vdi_uuids': vdi_uuids,
'image_id': image_id,
'glance_host': FLAGS.glance_host,
'glance_port': FLAGS.glance_port,
- 'sr_path': get_sr_path(session)}
+ 'sr_path': get_sr_path(session),
+ 'os_type': instance.get('os_type', 'linux')}
kwargs = {'params': pickle.dumps(params)}
task = session.async_call_plugin('glance', 'upload_vhd', kwargs)
- session.wait_for_task(instance_id, task)
+ session.wait_for_task(instance.id, task)
@classmethod
def fetch_image(cls, session, instance_id, image, user, project,
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index abc1fb699..1edf39c5b 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -238,11 +238,11 @@ class VMOps(object):
try:
# call plugin to ship snapshot off to glance
VMHelper.upload_image(
- self._session, instance.id, template_vdi_uuids, image_id)
+ self._session, instance, template_vdi_uuids, image_id)
finally:
self._destroy(instance, template_vm_ref, shutdown=False,
destroy_kernel_ramdisk=False)
-
+
logging.debug(_("Finished snapshot and upload for VM %s"), instance)
def reboot(self, instance):
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index 7531af4ec..160bf482f 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -191,7 +191,7 @@ def _prepare_staging_area_for_upload(sr_path, staging_path, vdi_uuids):
os.link(source, link_name)
-def _upload_tarball(staging_path, image_id, glance_host, glance_port):
+def _upload_tarball(staging_path, image_id, glance_host, glance_port, os_type):
"""
Create a tarball of the image and then stream that into Glance
using chunked-transfer-encoded HTTP.
@@ -205,9 +205,10 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port):
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-type': 'vhd',
+ 'x-image-meta-property-os-type': os_type
}
for header, value in headers.iteritems():
conn.putheader(header, value)
@@ -330,11 +331,13 @@ def upload_vhd(session, args):
glance_host = params["glance_host"]
glance_port = params["glance_port"]
sr_path = params["sr_path"]
+ os_type = params["os_type"]
staging_path = _make_staging_area(sr_path)
try:
_prepare_staging_area_for_upload(sr_path, staging_path, vdi_uuids)
- _upload_tarball(staging_path, image_id, glance_host, glance_port)
+ _upload_tarball(staging_path, image_id, glance_host, glance_port,
+ os_type)
finally:
_cleanup_staging_area(staging_path)