From 49a1cadd61b4badff0578ecd26adb57fb284ad9a Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Thu, 9 Dec 2010 16:42:52 +0000 Subject: raw instances can now be launched in xenapi (only as hvm at the moment) --- nova/compute/api.py | 25 +++++++++++++---- nova/compute/instance_types.py | 2 +- nova/db/sqlalchemy/api.py | 2 +- nova/flags.py | 7 +++++ nova/virt/libvirt.qemu.xml.template | 18 ++++++++++-- nova/virt/libvirt_conn.py | 56 +++++++++++++++++++++++++++---------- nova/virt/xenapi/vm_utils.py | 41 ++++++++++++++++++++------- nova/virt/xenapi/vmops.py | 19 +++++++++---- 8 files changed, 130 insertions(+), 40 deletions(-) (limited to 'nova') diff --git a/nova/compute/api.py b/nova/compute/api.py index 929342a1e..829dfdaa5 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -74,10 +74,22 @@ class ComputeAPI(base.Base): kernel_id = image.get('kernelId', FLAGS.default_kernel) if ramdisk_id is None: ramdisk_id = image.get('ramdiskId', FLAGS.default_ramdisk) - - # Make sure we have access to kernel and ramdisk - image_service.show(context, kernel_id) - image_service.show(context, ramdisk_id) + #Salvatore - No kernel and ramdisk for raw images + pv_kernel=None + if (kernel_id == str(FLAGS.null_kernel) or kernel_id == str(FLAGS.null_kernel_pv)): + if kernel_id == str(FLAGS.null_kernel): + pv_kernel=False + else: + pv_kernel=True + kernel_id = None + ramdisk_id = None + logging.debug("Creating a raw instance (no kernel and ramdisk) - Paravirtualization:%s" %str(pv_kernel)) + + # Make sure we have access to kernel and ramdisk (as long as we want them) + if (kernel_id!=None): + image_service.show(context, kernel_id) + if (ramdisk_id!=None): + image_service.show(context, ramdisk_id) if security_group is None: security_group = ['default'] @@ -97,11 +109,12 @@ class ComputeAPI(base.Base): key_data = key_pair['public_key'] type_data = instance_types.INSTANCE_TYPES[instance_type] + #Salvatore TODO: PV or HVM base_options = { 'reservation_id': utils.generate_uid('r'), 'image_id': image_id, - 'kernel_id': kernel_id, - 'ramdisk_id': ramdisk_id, + 'kernel_id': kernel_id or '', + 'ramdisk_id': ramdisk_id or '', 'state_description': 'scheduling', 'user_id': context.user_id, 'project_id': context.project_id, diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py index a2679e0fc..06b4bf825 100644 --- a/nova/compute/instance_types.py +++ b/nova/compute/instance_types.py @@ -26,7 +26,7 @@ from nova import flags FLAGS = flags.FLAGS INSTANCE_TYPES = { 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1), - 'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2), + 'm1.small': dict(memory_mb=1024, vcpus=1, local_gb=20, flavorid=2), 'm1.medium': dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3), 'm1.large': dict(memory_mb=8192, vcpus=4, local_gb=80, flavorid=4), 'm1.xlarge': dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)} diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index dd9649054..5ab982860 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -43,7 +43,7 @@ def is_admin_context(context): if not context: warnings.warn('Use of empty request context is deprecated', DeprecationWarning) - raise Exception('die') + #raise Exception('die') return context.is_admin diff --git a/nova/flags.py b/nova/flags.py index 1f94feb08..1cb846c15 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -234,6 +234,13 @@ DEFINE_string('default_ramdisk', 'ari-11111', 'default ramdisk to use, testing only') DEFINE_string('default_instance_type', 'm1.small', 'default instance type to use, testing only') +DEFINE_string('null_kernel', 'aki-00000000', + 'kernel image that indicates not to use a kernel, ' + ' but to use a raw disk image instead') +DEFINE_string('null_kernel_pv', 'aki-00000001', + 'kernel image that indicates not to use a kernel, ' + ' but to use a raw disk image for a paravirtualized guest') + DEFINE_string('vpn_image_id', 'ami-CLOUDPIPE', 'AMI for cloudpipe vpn server') DEFINE_string('vpn_key_suffix', diff --git a/nova/virt/libvirt.qemu.xml.template b/nova/virt/libvirt.qemu.xml.template index 2538b1ade..b2281297e 100644 --- a/nova/virt/libvirt.qemu.xml.template +++ b/nova/virt/libvirt.qemu.xml.template @@ -1,9 +1,9 @@ %(name)s - hvm - %(basepath)s/kernel - %(basepath)s/ramdisk + hvm + %(kernel)s + %(ramdisk)s root=/dev/vda1 console=ttyS0 @@ -29,5 +29,17 @@ + + + + + + + + +