summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorBrian Lamar <brian.lamar@rackspace.com>2011-04-12 09:23:52 -0400
committerBrian Lamar <brian.lamar@rackspace.com>2011-04-12 09:23:52 -0400
commitb2f693f63d73e3e51cb3be40b5deae720c773340 (patch)
tree9131112680aef286516025ee17782051334ce0a6 /nova/compute
parent0a1a845de526631ce939f51e0c1585c694e773f6 (diff)
Reverted some superfluous changes to make MP more concise.
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py52
-rw-r--r--nova/compute/manager.py11
2 files changed, 32 insertions, 31 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 020d3b06d..5ec88adbd 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -105,32 +105,6 @@ class API(base.Base):
if len(content) > content_limit:
raise quota.QuotaError(code="OnsetFileContentLimitExceeded")
- def _check_metadata_quota(self, context, metadata):
- num_metadata = len(metadata)
- quota_metadata = quota.allowed_metadata_items(context, num_metadata)
- if quota_metadata < num_metadata:
- pid = context.project_id
- msg = (_("Quota exceeeded for %(pid)s,"
- " tried to set %(num_metadata)s metadata properties")
- % locals())
- LOG.warn(msg)
- raise quota.QuotaError(msg, "MetadataLimitExceeded")
-
- def _check_metadata_item_length(self, context, metadata):
- # Because metadata is stored in the DB, we hard-code the size limits
- # In future, we may support more variable length strings, so we act
- # as if this is quota-controlled for forwards compatibility
- for metadata_item in metadata:
- k = metadata_item['key']
- v = metadata_item['value']
- if len(k) > 255 or len(v) > 255:
- pid = context.project_id
- msg = (_("Quota exceeeded for %(pid)s,"
- " metadata property key or value too long")
- % locals())
- LOG.warn(msg)
- raise quota.QuotaError(msg, "MetadataLimitExceeded")
-
def create(self, context, instance_type,
image_id, kernel_id=None, ramdisk_id=None,
min_count=1, max_count=1,
@@ -267,6 +241,32 @@ class API(base.Base):
return [dict(x.iteritems()) for x in instances]
+ def _check_metadata_quota(self, context, metadata):
+ num_metadata = len(metadata)
+ quota_metadata = quota.allowed_metadata_items(context, num_metadata)
+ if quota_metadata < num_metadata:
+ pid = context.project_id
+ msg = (_("Quota exceeeded for %(pid)s,"
+ " tried to set %(num_metadata)s metadata properties")
+ % locals())
+ LOG.warn(msg)
+ raise quota.QuotaError(msg, "MetadataLimitExceeded")
+
+ def _check_metadata_item_length(self, context, metadata):
+ # Because metadata is stored in the DB, we hard-code the size limits
+ # In future, we may support more variable length strings, so we act
+ # as if this is quota-controlled for forwards compatibility
+ for metadata_item in metadata:
+ k = metadata_item['key']
+ v = metadata_item['value']
+ if len(k) > 255 or len(v) > 255:
+ pid = context.project_id
+ msg = (_("Quota exceeeded for %(pid)s,"
+ " metadata property key or value too long")
+ % locals())
+ LOG.warn(msg)
+ raise quota.QuotaError(msg, "MetadataLimitExceeded")
+
def has_finished_migration(self, context, instance_id):
"""Retrieves whether or not a finished migration exists for
an instance"""
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 51f5322cd..04f2abc49 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -150,10 +150,11 @@ class ComputeManager(manager.SchedulerDependentManager):
info = self.driver.get_info(instance_ref['name'])
except exception.NotFound:
info = None
- state = power_state.FAILED
if info is not None:
state = info['state']
+ else:
+ state = power_state.FAILED
self.db.instance_set_state(context, instance_id, state)
@@ -246,10 +247,10 @@ class ComputeManager(manager.SchedulerDependentManager):
self.driver.spawn(instance_ref)
self._update_launched_at(context, instance_id)
except Exception as ex: # pylint: disable=W0702
- LOG.debug(ex)
- LOG.exception(_("Instance '%s' failed to spawn. Is virtualization"
- " enabled in the BIOS?"), instance_id,
- context=context)
+ msg = _("Instance '%(instance_id)s' failed to spawn. Is "
+ "virtualization enabled in the BIOS? Details: "
+ "%(ex)s") % locals()
+ LOG.exception(msg)
self._update_state(context, instance_id)