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 +- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'nova/compute') 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)} -- cgit From eaf463e4cc15820a5a8b91a31266fee02438c2c9 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 15 Dec 2010 14:27:07 +0000 Subject: removed temporary comment lines --- nova/compute/api.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 829dfdaa5..1f54a4f96 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -75,12 +75,7 @@ class ComputeAPI(base.Base): if ramdisk_id is None: ramdisk_id = image.get('ramdiskId', FLAGS.default_ramdisk) #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 + if (kernel_id == str(FLAGS.null_kernel)): kernel_id = None ramdisk_id = None logging.debug("Creating a raw instance (no kernel and ramdisk) - Paravirtualization:%s" %str(pv_kernel)) -- cgit From 9308d57ee06baab7eda304d0456544d1f9e587f0 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 15 Dec 2010 17:35:56 +0000 Subject: final cleanup --- nova/compute/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 1f54a4f96..a9f301d4d 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -78,7 +78,7 @@ class ComputeAPI(base.Base): if (kernel_id == str(FLAGS.null_kernel)): kernel_id = None ramdisk_id = None - logging.debug("Creating a raw instance (no kernel and ramdisk) - Paravirtualization:%s" %str(pv_kernel)) + logging.debug("Creating a raw instance") # Make sure we have access to kernel and ramdisk (as long as we want them) if (kernel_id!=None): -- cgit From 57e839b1333e29a44a33dc2571dfb8a0a0c956e3 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 15 Dec 2010 17:58:55 +0000 Subject: I made pep8 happy --- nova/compute/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index a9f301d4d..556aef7f9 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -80,10 +80,10 @@ class ComputeAPI(base.Base): ramdisk_id = None logging.debug("Creating a raw instance") - # Make sure we have access to kernel and ramdisk (as long as we want them) - if (kernel_id!=None): + # Make sure we have access to kernel and ramdisk (if not raw) + if (kernel_id != None): image_service.show(context, kernel_id) - if (ramdisk_id!=None): + if (ramdisk_id != None): image_service.show(context, ramdisk_id) if security_group is None: -- cgit From 4a451f96ba4a2ef9d061a491b97b61780c28a252 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Thu, 16 Dec 2010 12:09:51 +0000 Subject: Restore code which was changed for testing reasons to the original state. Kudos to Armando for spotting this. --- nova/compute/instance_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py index ed292ff8d..6e47170bd 100644 --- a/nova/compute/instance_types.py +++ b/nova/compute/instance_types.py @@ -27,7 +27,7 @@ from nova import exception FLAGS = flags.FLAGS INSTANCE_TYPES = { 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1), - 'm1.small': dict(memory_mb=1024, vcpus=1, local_gb=20, flavorid=2), + 'm1.small': dict(memory_mb=2048, 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)} -- cgit From 6c9ec94d0c9303316ad8f3347532eabf31ca8316 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Fri, 17 Dec 2010 11:49:00 +0000 Subject: Code reviewed --- nova/compute/api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index a84056dee..262a8819d 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -78,14 +78,14 @@ class ComputeAPI(base.Base): if ramdisk_id is None: ramdisk_id = image.get('ramdiskId', FLAGS.default_ramdisk) #Salvatore - No kernel and ramdisk for raw images - if (kernel_id == str(FLAGS.null_kernel)): + if kernel_id == str(FLAGS.null_kernel): kernel_id = None ramdisk_id = None logging.debug("Creating a raw instance") # Make sure we have access to kernel and ramdisk (if not raw) - if (kernel_id != None): + if kernel_id: image_service.show(context, kernel_id) - if (ramdisk_id != None): + if ramdisk_id: image_service.show(context, ramdisk_id) # Make sure we have access to kernel and ramdisk self.image_service.show(context, kernel_id) @@ -109,7 +109,6 @@ 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, -- cgit From 3356aebe4d830e8d488a8eba2847a58e621045f6 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Fri, 17 Dec 2010 16:41:35 +0000 Subject: bug fixes --- nova/compute/api.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 262a8819d..4c4b82272 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -84,12 +84,9 @@ class ComputeAPI(base.Base): logging.debug("Creating a raw instance") # Make sure we have access to kernel and ramdisk (if not raw) if kernel_id: - image_service.show(context, kernel_id) + self.image_service.show(context, kernel_id) if ramdisk_id: - image_service.show(context, ramdisk_id) - # Make sure we have access to kernel and ramdisk - self.image_service.show(context, kernel_id) - self.image_service.show(context, ramdisk_id) + self.image_service.show(context, ramdisk_id) if security_group is None: security_group = ['default'] -- cgit From c7dada9b2f5811afbc7a181636d6be3ab8ab98cc Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 20 Dec 2010 15:41:43 +0000 Subject: Fixed pep8 errors --- nova/compute/disk.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nova/compute') diff --git a/nova/compute/disk.py b/nova/compute/disk.py index 3d5e07724..0169a9831 100644 --- a/nova/compute/disk.py +++ b/nova/compute/disk.py @@ -105,12 +105,14 @@ def partition(infile, outfile, local_bytes=0, resize=True, execute('parted --script %s mkpartfs primary %s %ds %ds' % (outfile, local_type, local_first, local_last)) + def extend(image, size, execute): file_size = os.path.getsize(image) if file_size >= size: return return execute('truncate -s size %s' % (image,)) + def inject_data(image, key=None, net=None, partition=None, execute=None): """Injects a ssh key and optionally net data into a disk image. -- cgit From aded4faba96e4de88f0294604927ef824cb249be Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Mon, 20 Dec 2010 22:55:11 +0000 Subject: added suspend and resume --- nova/compute/api.py | 18 ++++++++++++++++++ nova/compute/manager.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index c740814da..bb144d12f 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -298,6 +298,24 @@ class ComputeAPI(base.Base): {"method": "unpause_instance", "args": {"instance_id": instance['id']}}) + def suspend(self, context, instance_id): + """suspend the instance with instance_id""" + instance = self.db.instance_get_by_internal_id(context, instance_id) + host = instance['host'] + rpc.cast(context, + self.db.queue_get_for(context, FLAGS.compute_topic, host), + {"method": "suspend_instance", + "args": {"instance_id": instance['id']}}) + + def resume(self, context, instance_id): + """resume the instance with instance_id""" + instance = self.db.instance_get_by_internal_id(context, instance_id) + host = instance['host'] + rpc.cast(context, + self.db.queue_get_for(context, FLAGS.compute_topic, host), + {"method": "resume_instance", + "args": {"instance_id": instance['id']}}) + def rescue(self, context, instance_id): """Rescue the given instance.""" instance = self.db.instance_get_by_internal_id(context, instance_id) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index a84af6bb9..b1ac2db88 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -227,6 +227,38 @@ class ComputeManager(manager.Manager): instance_id, result)) + @exception.wrap_exception + def suspend_instance(self, context, instance_id): + """suspend the instance with instance_id""" + context = context.elevated() + instance_ref = self.db.instance_get(context, instance_id) + + logging.debug('instance %s: suspending', instance_ref['internal_id']) + self.db.instance_set_state(context, instance_id, + power_state.NOSTATE, + 'suspending') + self.driver.suspend(instance_ref, + lambda result: self._update_state_callback(self, + context, + instance_id, + result)) + + @exception.wrap_exception + def resume_instance(self, context, instance_id): + """resume the suspended instance with instance_id""" + context = context.elevated() + instance_ref = self.db.instance_get(context, instance_id) + + logging.debug('instance %s: resuming', instance_ref['internal_id']) + self.db.instance_set_state(context, instance_id, + power_state.NOSTATE, + 'resuming') + self.driver.resume(instance_ref, + lambda result: self._update_state_callback(self, + context, + instance_id, + result)) + @exception.wrap_exception def get_console_output(self, context, instance_id): """Send the console output for an instance.""" -- cgit From 62286399b69218418020baaf524292c1677d27d3 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 23 Dec 2010 06:48:15 +0000 Subject: added suspend as a power state --- nova/compute/power_state.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/power_state.py b/nova/compute/power_state.py index cefdf2d9e..37039d2ec 100644 --- a/nova/compute/power_state.py +++ b/nova/compute/power_state.py @@ -26,6 +26,7 @@ PAUSED = 0x03 SHUTDOWN = 0x04 SHUTOFF = 0x05 CRASHED = 0x06 +SUSPENDED = 0x07 def name(code): @@ -36,5 +37,6 @@ def name(code): PAUSED: 'paused', SHUTDOWN: 'shutdown', SHUTOFF: 'shutdown', - CRASHED: 'crashed'} + CRASHED: 'crashed', + SUSPENDED: 'suspended'} return d[code] -- cgit From a0ca9d4a9550370cc262574fbee097e5b70e408d Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 23 Dec 2010 20:35:16 +0000 Subject: added _() for gettext and a couple of pep8s --- nova/compute/manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index b1ac2db88..f96f0ca9c 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -233,7 +233,7 @@ class ComputeManager(manager.Manager): context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) - logging.debug('instance %s: suspending', instance_ref['internal_id']) + logging.debug(_('instance %s: suspending'), instance_ref['internal_id']) self.db.instance_set_state(context, instance_id, power_state.NOSTATE, 'suspending') @@ -249,7 +249,7 @@ class ComputeManager(manager.Manager): context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) - logging.debug('instance %s: resuming', instance_ref['internal_id']) + logging.debug(_('instance %s: resuming'), instance_ref['internal_id']) self.db.instance_set_state(context, instance_id, power_state.NOSTATE, 'resuming') -- cgit From 32bfe6acdf8e462f90c72c9230b77c8c6fdca93b Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Tue, 28 Dec 2010 05:14:21 +0000 Subject: fixed a line length --- nova/compute/manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index d5e0c38b0..70b175e7c 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -302,7 +302,8 @@ class ComputeManager(manager.Manager): context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) - logging.debug(_('instance %s: suspending'), instance_ref['internal_id']) + logging.debug(_('instance %s: suspending'), + instance_ref['internal_id']) self.db.instance_set_state(context, instance_id, power_state.NOSTATE, 'suspending') -- cgit