diff --git a/nova/exception.py b/nova/exception.py index 6a50faa4ace0..f587173e1185 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -818,3 +818,7 @@ class InstanceTypeMemoryTooSmall(NovaException): class InstanceTypeDiskTooSmall(NovaException): message = _("Instance type's disk is too small for requested image.") + + +class InsufficientFreeMemory(NovaException): + message = _("Insufficient free memory on compute node to start %(uuid)s.") diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 2cacd2364eaf..ec0104783b69 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -413,7 +413,7 @@ class XenAPIVMTestCase(test.TestCase): self.check_vm_params_for_linux() def test_spawn_not_enough_memory(self): - self.assertRaises(Exception, + self.assertRaises(exception.InsufficientFreeMemory, self._test_spawn, 1, 2, 3, "4") # m1.xlarge diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index bf4481d694ec..4b1d22baceec 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -220,12 +220,7 @@ class VMOps(object): # Ensure enough free memory is available if not VMHelper.ensure_free_mem(self._session, instance): - LOG.exception(_('instance %(instance_name)s: not enough free ' - 'memory') % locals()) - db.instance_set_state(nova_context.get_admin_context(), - instance['id'], - power_state.SHUTDOWN) - return + raise exception.InsufficientFreeMemory(uuid=instance.uuid) disk_image_type = VMHelper.determine_disk_image_type(instance, context) kernel = None