summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorTodd Willey <todd@ansolabs.com>2011-01-25 09:00:56 -0800
committerTodd Willey <todd@ansolabs.com>2011-01-25 09:00:56 -0800
commita964fc3a8efad33b0dbb94e8a128c512a248f7f1 (patch)
tree1d40ee63f45cc8fae3f089621e8e64bf95a3d71e /nova/compute
parentf02c9e781bdddd609601da81b97a438b6d5b9781 (diff)
parent07f39806f3b82d5d06371758e3efe597a47434ed (diff)
Merge trunk.
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py18
-rw-r--r--nova/compute/manager.py32
-rw-r--r--nova/compute/monitor.py10
3 files changed, 35 insertions, 25 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 607a9ef25..cb1a57a44 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -92,8 +92,9 @@ class API(base.Base):
type_data = instance_types.INSTANCE_TYPES[instance_type]
num_instances = quota.allowed_instances(context, max_count, type_data)
if num_instances < min_count:
- LOG.warn(_("Quota exceeeded for %s, tried to run %s instances"),
- context.project_id, min_count)
+ pid = context.project_id
+ LOG.warn(_("Quota exceeeded for %(pid)s,"
+ " tried to run %(min_count)s instances") % locals())
raise quota.QuotaError(_("Instance quota exceeded. You can only "
"run %s more instances of this type.") %
num_instances, "InstanceLimitExceeded")
@@ -183,8 +184,10 @@ class API(base.Base):
instance = self.update(context, instance_id, **updates)
instances.append(instance)
- LOG.debug(_("Casting to scheduler for %s/%s's instance %s"),
- context.project_id, context.user_id, instance_id)
+ pid = context.project_id
+ uid = context.user_id
+ LOG.debug(_("Casting to scheduler for %(pid)s/%(uid)s's"
+ " instance %(instance_id)s") % locals())
rpc.cast(context,
FLAGS.scheduler_topic,
{"method": "run_instance",
@@ -246,13 +249,16 @@ class API(base.Base):
# ..then we distill the security groups to which they belong..
security_groups = set()
for rule in security_group_rules:
- security_groups.add(rule['parent_group_id'])
+ security_group = self.db.security_group_get(
+ context,
+ rule['parent_group_id'])
+ security_groups.add(security_group)
# ..then we find the instances that are members of these groups..
instances = set()
for security_group in security_groups:
for instance in security_group['instances']:
- instances.add(instance['id'])
+ instances.add(instance)
# ...then we find the hosts where they live...
hosts = set()
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index a9734f13b..9d99d1de2 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -77,8 +77,8 @@ def checks_instance_lock(function):
LOG.info(_("check_instance_lock: decorating: |%s|"), function,
context=context)
- LOG.info(_("check_instance_lock: arguments: |%s| |%s| |%s|"),
- self, context, instance_id, context=context)
+ LOG.info(_("check_instance_lock: arguments: |%(self)s| |%(context)s|"
+ " |%(instance_id)s|") % locals(), context=context)
locked = self.get_lock(context, instance_id)
admin = context.is_admin
LOG.info(_("check_instance_lock: locked: |%s|"), locked,
@@ -283,11 +283,11 @@ class ComputeManager(manager.Manager):
LOG.audit(_("Rebooting instance %s"), instance_id, context=context)
if instance_ref['state'] != power_state.RUNNING:
+ state = instance_ref['state']
+ running = power_state.RUNNING
LOG.warn(_('trying to reboot a non-running '
- 'instance: %s (state: %s excepted: %s)'),
- instance_id,
- instance_ref['state'],
- power_state.RUNNING,
+ 'instance: %(instance_id)s (state: %(state)s '
+ 'expected: %(running)s)') % locals(),
context=context)
self.db.instance_set_state(context,
@@ -312,9 +312,11 @@ class ComputeManager(manager.Manager):
LOG.audit(_('instance %s: snapshotting'), instance_id,
context=context)
if instance_ref['state'] != power_state.RUNNING:
+ state = instance_ref['state']
+ running = power_state.RUNNING
LOG.warn(_('trying to snapshot a non-running '
- 'instance: %s (state: %s excepted: %s)'),
- instance_id, instance_ref['state'], power_state.RUNNING)
+ 'instance: %(instance_id)s (state: %(state)s '
+ 'expected: %(running)s)') % locals())
self.driver.snapshot(instance_ref, image_id)
@@ -522,8 +524,8 @@ class ComputeManager(manager.Manager):
"""Attach a volume to an instance."""
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
- LOG.audit(_("instance %s: attaching volume %s to %s"), instance_id,
- volume_id, mountpoint, context=context)
+ LOG.audit(_("instance %(instance_id)s: attaching volume %(volume_id)s"
+ " to %(mountpoint)s") % locals(), context=context)
dev_path = self.volume_manager.setup_compute_volume(context,
volume_id)
try:
@@ -538,8 +540,8 @@ class ComputeManager(manager.Manager):
# NOTE(vish): The inline callback eats the exception info so we
# log the traceback here and reraise the same
# ecxception below.
- LOG.exception(_("instance %s: attach failed %s, removing"),
- instance_id, mountpoint, context=context)
+ LOG.exception(_("instance %(instance_id)s: attach failed"
+ " %(mountpoint)s, removing") % locals(), context=context)
self.volume_manager.remove_compute_volume(context,
volume_id)
raise exc
@@ -553,9 +555,9 @@ class ComputeManager(manager.Manager):
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
volume_ref = self.db.volume_get(context, volume_id)
- LOG.audit(_("Detach volume %s from mountpoint %s on instance %s"),
- volume_id, volume_ref['mountpoint'], instance_id,
- context=context)
+ mp = volume_ref['mountpoint']
+ LOG.audit(_("Detach volume %(volume_id)s from mountpoint %(mp)s"
+ " on instance %(instance_id)s") % locals(), context=context)
if instance_ref['name'] not in self.driver.list_instances():
LOG.warn(_("Detaching volume from unknown instance %s"),
instance_id, context=context)
diff --git a/nova/compute/monitor.py b/nova/compute/monitor.py
index 14d0e8ca1..04e08a235 100644
--- a/nova/compute/monitor.py
+++ b/nova/compute/monitor.py
@@ -352,8 +352,9 @@ class Instance(object):
rd += rd_bytes
wr += wr_bytes
except TypeError:
- LOG.error(_('Cannot get blockstats for "%s" on "%s"'),
- disk, self.instance_id)
+ iid = self.instance_id
+ LOG.error(_('Cannot get blockstats for "%(disk)s"'
+ ' on "%(iid)s"') % locals())
raise
return '%d:%d' % (rd, wr)
@@ -374,8 +375,9 @@ class Instance(object):
rx += stats[0]
tx += stats[4]
except TypeError:
- LOG.error(_('Cannot get ifstats for "%s" on "%s"'),
- interface, self.instance_id)
+ iid = self.instance_id
+ LOG.error(_('Cannot get ifstats for "%(interface)s"'
+ ' on "%(iid)s"') % locals())
raise
return '%d:%d' % (rx, tx)