Merge lp:~ed-leafe/nova/lp703041 into lp:~hudson-openstack/nova/trunk
- lp703041
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Soren Hansen |
Approved revision: | 581 |
Merged at revision: | 607 |
Proposed branch: | lp:~ed-leafe/nova/lp703041 |
Merge into: | lp:~hudson-openstack/nova/trunk |
Diff against target: |
1614 lines (+340/-281) 35 files modified
bin/nova-api (+1/-1) bin/nova-dhcpbridge (+3/-3) doc/ext/nova_todo.py (+3/-2) nova/api/ec2/__init__.py (+12/-8) nova/api/ec2/admin.py (+23/-16) nova/api/ec2/apirequest.py (+4/-2) nova/api/ec2/cloud.py (+8/-6) nova/api/openstack/servers.py (+3/-3) nova/auth/ldapdriver.py (+2/-2) nova/auth/manager.py (+42/-27) nova/compute/api.py (+7/-4) nova/compute/manager.py (+17/-15) nova/compute/monitor.py (+6/-4) nova/db/sqlalchemy/api.py (+13/-19) nova/exception.py (+3/-2) nova/fakerabbit.py (+6/-5) nova/network/manager.py (+6/-4) nova/objectstore/handler.py (+22/-21) nova/rpc.py (+10/-9) nova/scheduler/manager.py (+1/-1) nova/service.py (+2/-2) nova/tests/test_rpc.py (+2/-1) nova/utils.py (+5/-3) nova/virt/hyperv.py (+46/-39) nova/virt/images.py (+1/-1) nova/virt/libvirt_conn.py (+14/-12) nova/virt/xenapi/fake.py (+5/-2) nova/virt/xenapi/vm_utils.py (+33/-27) nova/virt/xenapi/vmops.py (+5/-2) nova/virt/xenapi/volume_utils.py (+9/-9) nova/virt/xenapi/volumeops.py (+12/-13) nova/virt/xenapi_conn.py (+4/-9) nova/volume/api.py (+4/-3) nova/volume/manager.py (+4/-3) nova/wsgi.py (+2/-1) |
To merge this branch: | bzr merge lp:~ed-leafe/nova/lp703041 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thierry Carrez (community) | Approve | ||
Jay Pipes (community) | Approve | ||
Review via email: mp+46823@code.launchpad.net |
Commit message
Description of the change
Localized strings that employ formatting should not use positional arguments, as they prevent the translator from re-ordering the translated text; instead, they should use mappings (i.e., dicts). This change replaces all localized formatted strings that use more than one formatting placeholder with a mapping version.
Thierry Carrez (ttx) wrote : | # |
L195: you want %(controller)s, not %(contorller)s
Ed Leafe (ed-leafe) wrote : | # |
Thierry: good catch. Fixed and pushed.
OpenStack Infra (hudson-openstack) wrote : | # |
The attempt to merge lp:~ed-leafe/nova/lp703041 into lp:nova failed. Below is the output from the failed tests.
AdminAPITest
test_
test_
APITest
test_
Test
test_
test_
test_bad_token ok
test_bad_user ok
test_no_user ok
test_
TestLimiter
test_
TestFaults
test_
test_raise ok
test_
FlavorsTest
test_
test_
GlanceImageServ
test_create ok
test_
test_delete ok
test_update ok
ImageController
test_
test_
LocalImageServi
test_create ok
test_
test_delete ok
test_update ok
LimiterTest
test_minute ok
test_
test_second ok
test_
test_
WSGIAppProxyTest
test_200 ok
test_403 ok
test_failure ok
WSGIAppTest
test_escaping ok
test_good_urls ok
test_
test_
test_
ServersTest
test_
test_
test_
test_
test_
test_g...
Preview Diff
1 | === modified file 'bin/nova-api' |
2 | --- bin/nova-api 2011-01-20 11:26:19 +0000 |
3 | +++ bin/nova-api 2011-01-24 15:23:08 +0000 |
4 | @@ -56,7 +56,7 @@ |
5 | if config is None: |
6 | LOG.debug(_("No paste configuration for app: %s"), api) |
7 | continue |
8 | - LOG.debug(_("App Config: %s\n%r"), api, config) |
9 | + LOG.debug(_("App Config: %(api)s\n%(config)r") % locals()) |
10 | wsgi.paste_config_to_flags(config, { |
11 | "verbose": FLAGS.verbose, |
12 | "%s_host" % api: config.get('host', '0.0.0.0'), |
13 | |
14 | === modified file 'bin/nova-dhcpbridge' |
15 | --- bin/nova-dhcpbridge 2011-01-04 05:26:41 +0000 |
16 | +++ bin/nova-dhcpbridge 2011-01-24 15:23:08 +0000 |
17 | @@ -120,9 +120,9 @@ |
18 | mac = argv[2] |
19 | ip = argv[3] |
20 | hostname = argv[4] |
21 | - LOG.debug(_("Called %s for mac %s with ip %s and " |
22 | - "hostname %s on interface %s"), |
23 | - action, mac, ip, hostname, interface) |
24 | + msg = _("Called %(action)s for mac %(mac)s with ip %(ip)s and" |
25 | + " hostname %(hostname)s on interface %(interface)s") % locals() |
26 | + LOG.debug(msg) |
27 | globals()[action + '_lease'](mac, ip, hostname, interface) |
28 | else: |
29 | print init_leases(interface) |
30 | |
31 | === modified file 'doc/ext/nova_todo.py' |
32 | --- doc/ext/nova_todo.py 2010-11-12 17:25:01 +0000 |
33 | +++ doc/ext/nova_todo.py 2011-01-24 15:23:08 +0000 |
34 | @@ -26,7 +26,7 @@ |
35 | # reading through docutils for the proper way to construct an empty list |
36 | lists = [] |
37 | for i in xrange(5): |
38 | - lists.append(nodes.bullet_list("", nodes.Text('',''))); |
39 | + lists.append(nodes.bullet_list("", nodes.Text('',''))) |
40 | lists[i].remove(lists[i][0]) |
41 | lists[i].set_class('todo_list') |
42 | |
43 | @@ -42,7 +42,8 @@ |
44 | # Create a reference |
45 | newnode = nodes.reference('', '') |
46 | |
47 | - link = _('%s, line %d') % (filename, todo_info['lineno']); |
48 | + line_info = todo_info['lineno'] |
49 | + link = _('%(filename)s, line %(line_info)d') % locals() |
50 | innernode = nodes.emphasis(link, link) |
51 | newnode['refdocname'] = todo_info['docname'] |
52 | |
53 | |
54 | === modified file 'nova/api/ec2/__init__.py' |
55 | --- nova/api/ec2/__init__.py 2011-01-12 22:47:43 +0000 |
56 | +++ nova/api/ec2/__init__.py 2011-01-24 15:23:08 +0000 |
57 | @@ -131,9 +131,11 @@ |
58 | # NOTE(vish): To use incr, failures has to be a string. |
59 | self.mc.set(failures_key, '1', time=FLAGS.lockout_window * 60) |
60 | elif failures >= FLAGS.lockout_attempts: |
61 | - LOG.warn(_('Access key %s has had %d failed authentications' |
62 | - ' and will be locked out for %d minutes.'), |
63 | - access_key, failures, FLAGS.lockout_minutes) |
64 | + lock_mins = FLAGS.lockout_minutes |
65 | + msg = _('Access key %(access_key)s has had %(failures)d' |
66 | + ' failed authentications and will be locked out' |
67 | + ' for %(lock_mins)d minutes.') % locals() |
68 | + LOG.warn(msg) |
69 | self.mc.set(failures_key, str(failures), |
70 | time=FLAGS.lockout_minutes * 60) |
71 | return res |
72 | @@ -179,8 +181,10 @@ |
73 | project=project, |
74 | remote_address=remote_address) |
75 | req.environ['ec2.context'] = ctxt |
76 | - LOG.audit(_('Authenticated Request For %s:%s)'), user.name, |
77 | - project.name, context=req.environ['ec2.context']) |
78 | + uname = user.name |
79 | + pname = project.name |
80 | + msg = _('Authenticated Request For %(uname)s:%(pname)s)') % locals() |
81 | + LOG.audit(msg, context=req.environ['ec2.context']) |
82 | return self.application |
83 | |
84 | |
85 | @@ -206,7 +210,7 @@ |
86 | |
87 | LOG.debug(_('action: %s'), action) |
88 | for key, value in args.items(): |
89 | - LOG.debug(_('arg: %s\t\tval: %s'), key, value) |
90 | + LOG.debug(_('arg: %(key)s\t\tval: %(value)s') % locals()) |
91 | |
92 | # Success! |
93 | api_request = apirequest.APIRequest(self.controller, action, args) |
94 | @@ -277,8 +281,8 @@ |
95 | if self._matches_any_role(context, allowed_roles): |
96 | return self.application |
97 | else: |
98 | - LOG.audit(_("Unauthorized request for controller=%s " |
99 | - "and action=%s"), controller, action, context=context) |
100 | + LOG.audit(_('Unauthorized request for controller=%(controller)s ' |
101 | + 'and action=%(action)s') % locals(), context=context) |
102 | raise webob.exc.HTTPUnauthorized() |
103 | |
104 | def _matches_any_role(self, context, roles): |
105 | |
106 | === modified file 'nova/api/ec2/admin.py' |
107 | --- nova/api/ec2/admin.py 2011-01-10 21:06:36 +0000 |
108 | +++ nova/api/ec2/admin.py 2011-01-24 15:23:08 +0000 |
109 | @@ -111,19 +111,23 @@ |
110 | """Add or remove a role for a user and project.""" |
111 | if operation == 'add': |
112 | if project: |
113 | - LOG.audit(_("Adding role %s to user %s for project %s"), role, |
114 | - user, project, context=context) |
115 | + msg = _("Adding role %(role)s to user %(user)s" |
116 | + " for project %(project)s") % locals() |
117 | + LOG.audit(msg, context=context) |
118 | else: |
119 | - LOG.audit(_("Adding sitewide role %s to user %s"), role, user, |
120 | - context=context) |
121 | + msg = _("Adding sitewide role %(role)s to" |
122 | + " user %(user)s") % locals() |
123 | + LOG.audit(msg, context=context) |
124 | manager.AuthManager().add_role(user, role, project) |
125 | elif operation == 'remove': |
126 | if project: |
127 | - LOG.audit(_("Removing role %s from user %s for project %s"), |
128 | - role, user, project, context=context) |
129 | + msg = _("Removing role %(role)s from user %(user)s" |
130 | + " for project %(project)s") % locals() |
131 | + LOG.audit(msg, context=context) |
132 | else: |
133 | - LOG.audit(_("Removing sitewide role %s from user %s"), role, |
134 | - user, context=context) |
135 | + msg = _("Removing sitewide role %(role)s" |
136 | + " from user %(user)s") % locals() |
137 | + LOG.audit(msg, context=context) |
138 | manager.AuthManager().remove_role(user, role, project) |
139 | else: |
140 | raise exception.ApiError(_('operation must be add or remove')) |
141 | @@ -139,8 +143,9 @@ |
142 | project = name |
143 | project = manager.AuthManager().get_project(project) |
144 | user = manager.AuthManager().get_user(name) |
145 | - LOG.audit(_("Getting x509 for user: %s on project: %s"), name, |
146 | - project, context=context) |
147 | + msg = _("Getting x509 for user: %(name)s" |
148 | + " on project: %(project)s") % locals() |
149 | + LOG.audit(msg, context=context) |
150 | return user_dict(user, base64.b64encode(project.get_credentials(user))) |
151 | |
152 | def describe_project(self, context, name, **kwargs): |
153 | @@ -156,8 +161,9 @@ |
154 | def register_project(self, context, name, manager_user, description=None, |
155 | member_users=None, **kwargs): |
156 | """Creates a new project""" |
157 | - LOG.audit(_("Create project %s managed by %s"), name, manager_user, |
158 | - context=context) |
159 | + msg = _("Create project %(name)s managed by" |
160 | + " %(manager_user)s") % locals() |
161 | + LOG.audit(msg, context=context) |
162 | return project_dict( |
163 | manager.AuthManager().create_project( |
164 | name, |
165 | @@ -181,12 +187,13 @@ |
166 | **kwargs): |
167 | """Add or remove a user from a project.""" |
168 | if operation == 'add': |
169 | - LOG.audit(_("Adding user %s to project %s"), user, project, |
170 | - context=context) |
171 | + msg = _("Adding user %(user)s to project %(project)s") % locals() |
172 | + LOG.audit(msg, context=context) |
173 | manager.AuthManager().add_to_project(user, project) |
174 | elif operation == 'remove': |
175 | - LOG.audit(_("Removing user %s from project %s"), user, project, |
176 | - context=context) |
177 | + msg = _("Removing user %(user)s from" |
178 | + " project %(project)s") % locals() |
179 | + LOG.audit(msg, context=context) |
180 | manager.AuthManager().remove_from_project(user, project) |
181 | else: |
182 | raise exception.ApiError(_('operation must be add or remove')) |
183 | |
184 | === modified file 'nova/api/ec2/apirequest.py' |
185 | --- nova/api/ec2/apirequest.py 2011-01-12 19:20:05 +0000 |
186 | +++ nova/api/ec2/apirequest.py 2011-01-24 15:23:08 +0000 |
187 | @@ -93,8 +93,10 @@ |
188 | method = getattr(self.controller, |
189 | _camelcase_to_underscore(self.action)) |
190 | except AttributeError: |
191 | - _error = _('Unsupported API request: controller = %s,' |
192 | - 'action = %s') % (self.controller, self.action) |
193 | + controller = self.controller |
194 | + action = self.action |
195 | + _error = _('Unsupported API request: controller = %(controller)s,' |
196 | + ' action = %(action)s') % locals() |
197 | LOG.exception(_error) |
198 | # TODO: Raise custom exception, trap in apiserver, |
199 | # and reraise as 400 error. |
200 | |
201 | === modified file 'nova/api/ec2/cloud.py' |
202 | --- nova/api/ec2/cloud.py 2011-01-20 20:04:57 +0000 |
203 | +++ nova/api/ec2/cloud.py 2011-01-24 15:23:08 +0000 |
204 | @@ -601,8 +601,9 @@ |
205 | def attach_volume(self, context, volume_id, instance_id, device, **kwargs): |
206 | volume_id = ec2_id_to_id(volume_id) |
207 | instance_id = ec2_id_to_id(instance_id) |
208 | - LOG.audit(_("Attach volume %s to instance %s at %s"), volume_id, |
209 | - instance_id, device, context=context) |
210 | + msg = _("Attach volume %(volume_id)s to instance %(instance_id)s" |
211 | + " at %(device)s") % locals() |
212 | + LOG.audit(msg, context=context) |
213 | self.compute_api.attach_volume(context, |
214 | instance_id=instance_id, |
215 | volume_id=volume_id, |
216 | @@ -751,8 +752,8 @@ |
217 | return {'releaseResponse': ["Address released."]} |
218 | |
219 | def associate_address(self, context, instance_id, public_ip, **kwargs): |
220 | - LOG.audit(_("Associate address %s to instance %s"), public_ip, |
221 | - instance_id, context=context) |
222 | + LOG.audit(_("Associate address %(public_ip)s to" |
223 | + " instance %(instance_id)s") % locals(), context=context) |
224 | instance_id = ec2_id_to_id(instance_id) |
225 | self.compute_api.associate_floating_ip(context, |
226 | instance_id=instance_id, |
227 | @@ -840,8 +841,9 @@ |
228 | if image_location is None and 'name' in kwargs: |
229 | image_location = kwargs['name'] |
230 | image_id = self.image_service.register(context, image_location) |
231 | - LOG.audit(_("Registered image %s with id %s"), image_location, |
232 | - image_id, context=context) |
233 | + msg = _("Registered image %(image_location)s with" |
234 | + " id %(image_id)s") % locals() |
235 | + LOG.audit(msg, context=context) |
236 | return {'imageId': image_id} |
237 | |
238 | def describe_image_attribute(self, context, image_id, attribute, **kwargs): |
239 | |
240 | === modified file 'nova/api/openstack/servers.py' |
241 | --- nova/api/openstack/servers.py 2011-01-15 01:48:48 +0000 |
242 | +++ nova/api/openstack/servers.py 2011-01-24 15:23:08 +0000 |
243 | @@ -132,9 +132,9 @@ |
244 | if image_id in mapping: |
245 | return mapping[image_id] |
246 | |
247 | - raise exception.NotFound( |
248 | - _("No entry for image '%s' in mapping file '%s'") % |
249 | - (image_id, mapping_filename)) |
250 | + msg = _("No entry for image '%(image_id)s'" |
251 | + " in mapping file '%(mapping_filename)s'") % locals() |
252 | + raise exception.NotFound(msg) |
253 | |
254 | def create(self, req): |
255 | """ Creates a new server for a given user """ |
256 | |
257 | === modified file 'nova/auth/ldapdriver.py' |
258 | --- nova/auth/ldapdriver.py 2011-01-20 17:52:02 +0000 |
259 | +++ nova/auth/ldapdriver.py 2011-01-24 15:23:08 +0000 |
260 | @@ -473,8 +473,8 @@ |
261 | raise exception.NotFound(_("The group at dn %s doesn't exist") % |
262 | group_dn) |
263 | if self.__is_in_group(uid, group_dn): |
264 | - raise exception.Duplicate(_("User %s is already a member of " |
265 | - "the group %s") % (uid, group_dn)) |
266 | + raise exception.Duplicate(_("User %(uid)s is already a member of " |
267 | + "the group %(group_dn)s") % locals()) |
268 | attr = [(self.ldap.MOD_ADD, 'member', self.__uid_to_dn(uid))] |
269 | self.conn.modify_s(group_dn, attr) |
270 | |
271 | |
272 | === modified file 'nova/auth/manager.py' |
273 | --- nova/auth/manager.py 2011-01-13 23:23:18 +0000 |
274 | +++ nova/auth/manager.py 2011-01-24 15:23:08 +0000 |
275 | @@ -272,16 +272,22 @@ |
276 | |
277 | project = self.get_project(project_id) |
278 | if project == None: |
279 | - LOG.audit(_("failed authorization: no project named %s (user=%s)"), |
280 | - project_id, user.name) |
281 | + pjid = project_id |
282 | + uname = user.name |
283 | + LOG.audit(_("failed authorization: no project named %(pjid)s" |
284 | + " (user=%(uname)s)") % locals()) |
285 | raise exception.NotFound(_('No project called %s could be found') |
286 | % project_id) |
287 | if not self.is_admin(user) and not self.is_project_member(user, |
288 | project): |
289 | - LOG.audit(_("Failed authorization: user %s not admin and not " |
290 | - "member of project %s"), user.name, project.name) |
291 | - raise exception.NotFound(_('User %s is not a member of project %s') |
292 | - % (user.id, project.id)) |
293 | + uname = user.name |
294 | + uid = user.id |
295 | + pjname = project.name |
296 | + pjid = project.id |
297 | + LOG.audit(_("Failed authorization: user %(uname)s not admin" |
298 | + " and not member of project %(pjname)s") % locals()) |
299 | + raise exception.NotFound(_('User %(uid)s is not a member of' |
300 | + ' project %(pjid)s') % locals()) |
301 | if check_type == 's3': |
302 | sign = signer.Signer(user.secret.encode()) |
303 | expected_signature = sign.s3_authorization(headers, verb, path) |
304 | @@ -408,14 +414,16 @@ |
305 | raise exception.NotFound(_("The %s role can not be found") % role) |
306 | if project is not None and role in FLAGS.global_roles: |
307 | raise exception.NotFound(_("The %s role is global only") % role) |
308 | + uid = User.safe_id(user) |
309 | + pid = Project.safe_id(project) |
310 | if project: |
311 | - LOG.audit(_("Adding role %s to user %s in project %s"), role, |
312 | - User.safe_id(user), Project.safe_id(project)) |
313 | + LOG.audit(_("Adding role %(role)s to user %(uid)s" |
314 | + " in project %(pid)s") % locals()) |
315 | else: |
316 | - LOG.audit(_("Adding sitewide role %s to user %s"), role, |
317 | - User.safe_id(user)) |
318 | + LOG.audit(_("Adding sitewide role %(role)s to user %(uid)s") |
319 | + % locals()) |
320 | with self.driver() as drv: |
321 | - drv.add_role(User.safe_id(user), role, Project.safe_id(project)) |
322 | + drv.add_role(uid, role, pid) |
323 | |
324 | def remove_role(self, user, role, project=None): |
325 | """Removes role for user |
326 | @@ -434,14 +442,16 @@ |
327 | @type project: Project or project_id |
328 | @param project: Project in which to remove local role. |
329 | """ |
330 | + uid = User.safe_id(user) |
331 | + pid = Project.safe_id(project) |
332 | if project: |
333 | - LOG.audit(_("Removing role %s from user %s on project %s"), |
334 | - role, User.safe_id(user), Project.safe_id(project)) |
335 | + LOG.audit(_("Removing role %(role)s from user %(uid)s" |
336 | + " on project %(pid)s") % locals()) |
337 | else: |
338 | - LOG.audit(_("Removing sitewide role %s from user %s"), role, |
339 | - User.safe_id(user)) |
340 | + LOG.audit(_("Removing sitewide role %(role)s" |
341 | + " from user %(uid)s") % locals()) |
342 | with self.driver() as drv: |
343 | - drv.remove_role(User.safe_id(user), role, Project.safe_id(project)) |
344 | + drv.remove_role(uid, role, pid) |
345 | |
346 | @staticmethod |
347 | def get_roles(project_roles=True): |
348 | @@ -502,8 +512,8 @@ |
349 | description, |
350 | member_users) |
351 | if project_dict: |
352 | - LOG.audit(_("Created project %s with manager %s"), name, |
353 | - manager_user) |
354 | + LOG.audit(_("Created project %(name)s with" |
355 | + " manager %(manager_user)s") % locals()) |
356 | project = Project(**project_dict) |
357 | return project |
358 | |
359 | @@ -530,11 +540,12 @@ |
360 | |
361 | def add_to_project(self, user, project): |
362 | """Add user to project""" |
363 | - LOG.audit(_("Adding user %s to project %s"), User.safe_id(user), |
364 | - Project.safe_id(project)) |
365 | + uid = User.safe_id(user) |
366 | + pid = Project.safe_id(project) |
367 | + LOG.audit(_("Adding user %(uid)s to project %(pid)s") % locals()) |
368 | with self.driver() as drv: |
369 | return drv.add_to_project(User.safe_id(user), |
370 | - Project.safe_id(project)) |
371 | + Project.safe_id(project)) |
372 | |
373 | def is_project_manager(self, user, project): |
374 | """Checks if user is project manager""" |
375 | @@ -550,11 +561,11 @@ |
376 | |
377 | def remove_from_project(self, user, project): |
378 | """Removes a user from a project""" |
379 | - LOG.audit(_("Remove user %s from project %s"), User.safe_id(user), |
380 | - Project.safe_id(project)) |
381 | + uid = User.safe_id(user) |
382 | + pid = Project.safe_id(project) |
383 | + LOG.audit(_("Remove user %(uid)s from project %(pid)s") % locals()) |
384 | with self.driver() as drv: |
385 | - return drv.remove_from_project(User.safe_id(user), |
386 | - Project.safe_id(project)) |
387 | + return drv.remove_from_project(uid, pid) |
388 | |
389 | @staticmethod |
390 | def get_project_vpn_data(project): |
391 | @@ -634,7 +645,10 @@ |
392 | user_dict = drv.create_user(name, access, secret, admin) |
393 | if user_dict: |
394 | rv = User(**user_dict) |
395 | - LOG.audit(_("Created user %s (admin: %r)"), rv.name, rv.admin) |
396 | + rvname = rv.name |
397 | + rvadmin = rv.admin |
398 | + LOG.audit(_("Created user %(rvname)s" |
399 | + " (admin: %(rvadmin)r)") % locals()) |
400 | return rv |
401 | |
402 | def delete_user(self, user): |
403 | @@ -656,7 +670,8 @@ |
404 | if secret_key: |
405 | LOG.audit(_("Secret Key change for user %s"), uid) |
406 | if admin is not None: |
407 | - LOG.audit(_("Admin status set to %r for user %s"), admin, uid) |
408 | + LOG.audit(_("Admin status set to %(admin)r" |
409 | + " for user %(uid)s") % locals()) |
410 | with self.driver() as drv: |
411 | drv.modify_user(uid, access_key, secret_key, admin) |
412 | |
413 | |
414 | === modified file 'nova/compute/api.py' |
415 | --- nova/compute/api.py 2011-01-20 19:33:37 +0000 |
416 | +++ nova/compute/api.py 2011-01-24 15:23:08 +0000 |
417 | @@ -92,8 +92,9 @@ |
418 | type_data = instance_types.INSTANCE_TYPES[instance_type] |
419 | num_instances = quota.allowed_instances(context, max_count, type_data) |
420 | if num_instances < min_count: |
421 | - LOG.warn(_("Quota exceeeded for %s, tried to run %s instances"), |
422 | - context.project_id, min_count) |
423 | + pid = context.project_id |
424 | + LOG.warn(_("Quota exceeeded for %(pid)s," |
425 | + " tried to run %(min_count)s instances") % locals()) |
426 | raise quota.QuotaError(_("Instance quota exceeded. You can only " |
427 | "run %s more instances of this type.") % |
428 | num_instances, "InstanceLimitExceeded") |
429 | @@ -183,8 +184,10 @@ |
430 | instance = self.update(context, instance_id, **updates) |
431 | instances.append(instance) |
432 | |
433 | - LOG.debug(_("Casting to scheduler for %s/%s's instance %s"), |
434 | - context.project_id, context.user_id, instance_id) |
435 | + pid = context.project_id |
436 | + uid = context.user_id |
437 | + LOG.debug(_("Casting to scheduler for %(pid)s/%(uid)s's" |
438 | + " instance %(instance_id)s") % locals()) |
439 | rpc.cast(context, |
440 | FLAGS.scheduler_topic, |
441 | {"method": "run_instance", |
442 | |
443 | === modified file 'nova/compute/manager.py' |
444 | --- nova/compute/manager.py 2011-01-18 19:01:16 +0000 |
445 | +++ nova/compute/manager.py 2011-01-24 15:23:08 +0000 |
446 | @@ -77,8 +77,8 @@ |
447 | |
448 | LOG.info(_("check_instance_lock: decorating: |%s|"), function, |
449 | context=context) |
450 | - LOG.info(_("check_instance_lock: arguments: |%s| |%s| |%s|"), |
451 | - self, context, instance_id, context=context) |
452 | + LOG.info(_("check_instance_lock: arguments: |%(self)s| |%(context)s|" |
453 | + " |%(instance_id)s|") % locals(), context=context) |
454 | locked = self.get_lock(context, instance_id) |
455 | admin = context.is_admin |
456 | LOG.info(_("check_instance_lock: locked: |%s|"), locked, |
457 | @@ -278,11 +278,11 @@ |
458 | LOG.audit(_("Rebooting instance %s"), instance_id, context=context) |
459 | |
460 | if instance_ref['state'] != power_state.RUNNING: |
461 | + state = instance_ref['state'] |
462 | + running = power_state.RUNNING |
463 | LOG.warn(_('trying to reboot a non-running ' |
464 | - 'instance: %s (state: %s excepted: %s)'), |
465 | - instance_id, |
466 | - instance_ref['state'], |
467 | - power_state.RUNNING, |
468 | + 'instance: %(instance_id)s (state: %(state)s ' |
469 | + 'expected: %(running)s)') % locals(), |
470 | context=context) |
471 | |
472 | self.db.instance_set_state(context, |
473 | @@ -307,9 +307,11 @@ |
474 | LOG.audit(_('instance %s: snapshotting'), instance_id, |
475 | context=context) |
476 | if instance_ref['state'] != power_state.RUNNING: |
477 | + state = instance_ref['state'] |
478 | + running = power_state.RUNNING |
479 | LOG.warn(_('trying to snapshot a non-running ' |
480 | - 'instance: %s (state: %s excepted: %s)'), |
481 | - instance_id, instance_ref['state'], power_state.RUNNING) |
482 | + 'instance: %(instance_id)s (state: %(state)s ' |
483 | + 'expected: %(running)s)') % locals()) |
484 | |
485 | self.driver.snapshot(instance_ref, image_id) |
486 | |
487 | @@ -517,8 +519,8 @@ |
488 | """Attach a volume to an instance.""" |
489 | context = context.elevated() |
490 | instance_ref = self.db.instance_get(context, instance_id) |
491 | - LOG.audit(_("instance %s: attaching volume %s to %s"), instance_id, |
492 | - volume_id, mountpoint, context=context) |
493 | + LOG.audit(_("instance %(instance_id)s: attaching volume %(volume_id)s" |
494 | + " to %(mountpoint)s") % locals(), context=context) |
495 | dev_path = self.volume_manager.setup_compute_volume(context, |
496 | volume_id) |
497 | try: |
498 | @@ -533,8 +535,8 @@ |
499 | # NOTE(vish): The inline callback eats the exception info so we |
500 | # log the traceback here and reraise the same |
501 | # ecxception below. |
502 | - LOG.exception(_("instance %s: attach failed %s, removing"), |
503 | - instance_id, mountpoint, context=context) |
504 | + LOG.exception(_("instance %(instance_id)s: attach failed" |
505 | + " %(mountpoint)s, removing") % locals(), context=context) |
506 | self.volume_manager.remove_compute_volume(context, |
507 | volume_id) |
508 | raise exc |
509 | @@ -548,9 +550,9 @@ |
510 | context = context.elevated() |
511 | instance_ref = self.db.instance_get(context, instance_id) |
512 | volume_ref = self.db.volume_get(context, volume_id) |
513 | - LOG.audit(_("Detach volume %s from mountpoint %s on instance %s"), |
514 | - volume_id, volume_ref['mountpoint'], instance_id, |
515 | - context=context) |
516 | + mp = volume_ref['mountpoint'] |
517 | + LOG.audit(_("Detach volume %(volume_id)s from mountpoint %(mp)s" |
518 | + " on instance %(instance_id)s") % locals(), context=context) |
519 | if instance_ref['name'] not in self.driver.list_instances(): |
520 | LOG.warn(_("Detaching volume from unknown instance %s"), |
521 | instance_id, context=context) |
522 | |
523 | === modified file 'nova/compute/monitor.py' |
524 | --- nova/compute/monitor.py 2011-01-04 05:26:41 +0000 |
525 | +++ nova/compute/monitor.py 2011-01-24 15:23:08 +0000 |
526 | @@ -352,8 +352,9 @@ |
527 | rd += rd_bytes |
528 | wr += wr_bytes |
529 | except TypeError: |
530 | - LOG.error(_('Cannot get blockstats for "%s" on "%s"'), |
531 | - disk, self.instance_id) |
532 | + iid = self.instance_id |
533 | + LOG.error(_('Cannot get blockstats for "%(disk)s"' |
534 | + ' on "%(iid)s"') % locals()) |
535 | raise |
536 | |
537 | return '%d:%d' % (rd, wr) |
538 | @@ -374,8 +375,9 @@ |
539 | rx += stats[0] |
540 | tx += stats[4] |
541 | except TypeError: |
542 | - LOG.error(_('Cannot get ifstats for "%s" on "%s"'), |
543 | - interface, self.instance_id) |
544 | + iid = self.instance_id |
545 | + LOG.error(_('Cannot get ifstats for "%(interface)s"' |
546 | + ' on "%(iid)s"') % locals()) |
547 | raise |
548 | |
549 | return '%d:%d' % (rx, tx) |
550 | |
551 | === modified file 'nova/db/sqlalchemy/api.py' |
552 | --- nova/db/sqlalchemy/api.py 2011-01-20 01:34:54 +0000 |
553 | +++ nova/db/sqlalchemy/api.py 2011-01-24 15:23:08 +0000 |
554 | @@ -247,7 +247,8 @@ |
555 | filter_by(deleted=can_read_deleted(context)).\ |
556 | first() |
557 | if not result: |
558 | - raise exception.NotFound(_('No service for %s, %s') % (host, binary)) |
559 | + raise exception.NotFound(_('No service for %(host)s, %(binary)s') |
560 | + % locals()) |
561 | |
562 | return result |
563 | |
564 | @@ -935,8 +936,8 @@ |
565 | filter_by(deleted=can_read_deleted(context)).\ |
566 | first() |
567 | if not result: |
568 | - raise exception.NotFound(_('no keypair for user %s, name %s') % |
569 | - (user_id, name)) |
570 | + raise exception.NotFound(_('no keypair for user %(user_id)s,' |
571 | + ' name %(name)s') % locals()) |
572 | return result |
573 | |
574 | |
575 | @@ -1537,8 +1538,8 @@ |
576 | first() |
577 | if not result: |
578 | raise exception.NotFound( |
579 | - _('No security group named %s for project: %s') |
580 | - % (group_name, project_id)) |
581 | + _('No security group named %(group_name)s' |
582 | + ' for project: %(project_id)s') % locals()) |
583 | return result |
584 | |
585 | |
586 | @@ -1922,8 +1923,8 @@ |
587 | filter_by(id=pool_id).\ |
588 | first() |
589 | if not result: |
590 | - raise exception.NotFound(_("No console pool with id %(pool_id)s") % |
591 | - {'pool_id': pool_id}) |
592 | + raise exception.NotFound(_("No console pool with id %(pool_id)s") |
593 | + % locals()) |
594 | |
595 | return result |
596 | |
597 | @@ -1939,12 +1940,9 @@ |
598 | options(joinedload('consoles')).\ |
599 | first() |
600 | if not result: |
601 | - raise exception.NotFound(_('No console pool of type %(type)s ' |
602 | + raise exception.NotFound(_('No console pool of type %(console_type)s ' |
603 | 'for compute host %(compute_host)s ' |
604 | - 'on proxy host %(host)s') % |
605 | - {'type': console_type, |
606 | - 'compute_host': compute_host, |
607 | - 'host': host}) |
608 | + 'on proxy host %(host)s') % locals()) |
609 | return result |
610 | |
611 | |
612 | @@ -1982,9 +1980,7 @@ |
613 | first() |
614 | if not result: |
615 | raise exception.NotFound(_('No console for instance %(instance_id)s ' |
616 | - 'in pool %(pool_id)s') % |
617 | - {'instance_id': instance_id, |
618 | - 'pool_id': pool_id}) |
619 | + 'in pool %(pool_id)s') % locals()) |
620 | return result |
621 | |
622 | |
623 | @@ -2005,9 +2001,7 @@ |
624 | query = query.filter_by(instance_id=instance_id) |
625 | result = query.options(joinedload('pool')).first() |
626 | if not result: |
627 | - idesc = (_("on instance %s") % instance_id) if instance_id else "" |
628 | + idesc = (_("on instance %s") % instance_id) if instance_id else "" |
629 | raise exception.NotFound(_("No console with id %(console_id)s" |
630 | - " %(instance)s") % |
631 | - {'instance': idesc, |
632 | - 'console_id': console_id}) |
633 | + " %(idesc)s") % locals()) |
634 | return result |
635 | |
636 | === modified file 'nova/exception.py' |
637 | --- nova/exception.py 2011-01-07 21:49:12 +0000 |
638 | +++ nova/exception.py 2011-01-24 15:23:08 +0000 |
639 | @@ -33,8 +33,9 @@ |
640 | description = _("Unexpected error while running command.") |
641 | if exit_code is None: |
642 | exit_code = '-' |
643 | - message = _("%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r")\ |
644 | - % (description, cmd, exit_code, stdout, stderr) |
645 | + message = _("%(description)s\nCommand: %(cmd)s\n" |
646 | + "Exit code: %(exit_code)s\nStdout: %(stdout)r\n" |
647 | + "Stderr: %(stderr)r") % locals() |
648 | IOError.__init__(self, message) |
649 | |
650 | |
651 | |
652 | === modified file 'nova/fakerabbit.py' |
653 | --- nova/fakerabbit.py 2011-01-04 05:23:35 +0000 |
654 | +++ nova/fakerabbit.py 2011-01-24 15:23:08 +0000 |
655 | @@ -45,8 +45,9 @@ |
656 | self._routes = {} |
657 | |
658 | def publish(self, message, routing_key=None): |
659 | - LOG.debug(_('(%s) publish (key: %s) %s'), |
660 | - self.name, routing_key, message) |
661 | + nm = self.name |
662 | + LOG.debug(_('(%(nm)s) publish (key: %(routing_key)s)' |
663 | + ' %(message)s') % locals()) |
664 | routing_key = routing_key.split('.')[0] |
665 | if routing_key in self._routes: |
666 | for f in self._routes[routing_key]: |
667 | @@ -92,8 +93,8 @@ |
668 | def queue_bind(self, queue, exchange, routing_key, **kwargs): |
669 | global EXCHANGES |
670 | global QUEUES |
671 | - LOG.debug(_('Binding %s to %s with key %s'), |
672 | - queue, exchange, routing_key) |
673 | + LOG.debug(_('Binding %(queue)s to %(exchange)s with' |
674 | + ' key %(routing_key)s') % locals()) |
675 | EXCHANGES[exchange].bind(QUEUES[queue].push, routing_key) |
676 | |
677 | def declare_consumer(self, queue, callback, *args, **kwargs): |
678 | @@ -117,7 +118,7 @@ |
679 | content_type=content_type, |
680 | content_encoding=content_encoding) |
681 | message.result = True |
682 | - LOG.debug(_('Getting from %s: %s'), queue, message) |
683 | + LOG.debug(_('Getting from %(queue)s: %(message)s') % locals()) |
684 | return message |
685 | |
686 | def prepare_message(self, message_data, delivery_mode, |
687 | |
688 | === modified file 'nova/network/manager.py' |
689 | --- nova/network/manager.py 2011-01-20 17:52:02 +0000 |
690 | +++ nova/network/manager.py 2011-01-24 15:23:08 +0000 |
691 | @@ -198,8 +198,9 @@ |
692 | raise exception.Error(_("IP %s leased that isn't associated") % |
693 | address) |
694 | if instance_ref['mac_address'] != mac: |
695 | - raise exception.Error(_("IP %s leased to bad mac %s vs %s") % |
696 | - (address, instance_ref['mac_address'], mac)) |
697 | + inst_addr = instance_ref['mac_address'] |
698 | + raise exception.Error(_("IP %(address)s leased to bad" |
699 | + " mac %(inst_addr)s vs %(mac)s") % locals()) |
700 | now = datetime.datetime.utcnow() |
701 | self.db.fixed_ip_update(context, |
702 | fixed_ip_ref['address'], |
703 | @@ -218,8 +219,9 @@ |
704 | raise exception.Error(_("IP %s released that isn't associated") % |
705 | address) |
706 | if instance_ref['mac_address'] != mac: |
707 | - raise exception.Error(_("IP %s released from bad mac %s vs %s") % |
708 | - (address, instance_ref['mac_address'], mac)) |
709 | + inst_addr = instance_ref['mac_address'] |
710 | + raise exception.Error(_("IP %(address)s released from" |
711 | + " bad mac %(inst_addr)s vs %(mac)s") % locals()) |
712 | if not fixed_ip_ref['leased']: |
713 | LOG.warn(_("IP %s released that was not leased"), address, |
714 | context=context) |
715 | |
716 | === modified file 'nova/objectstore/handler.py' |
717 | --- nova/objectstore/handler.py 2011-01-20 17:52:02 +0000 |
718 | +++ nova/objectstore/handler.py 2011-01-24 15:23:08 +0000 |
719 | @@ -180,7 +180,7 @@ |
720 | def render_GET(self, request): # pylint: disable-msg=R0201 |
721 | """Renders the GET request for a list of buckets as XML""" |
722 | LOG.debug(_('List of buckets requested'), context=request.context) |
723 | - buckets = [b for b in bucket.Bucket.all() \ |
724 | + buckets = [b for b in bucket.Bucket.all() |
725 | if b.is_authorized(request.context)] |
726 | |
727 | render_xml(request, {"ListAllMyBucketsResult": { |
728 | @@ -268,12 +268,14 @@ |
729 | Raises NotAuthorized if user in request context is not |
730 | authorized to delete the object. |
731 | """ |
732 | - LOG.debug(_("Getting object: %s / %s"), self.bucket.name, self.name) |
733 | + bname = self.bucket.name |
734 | + nm = self.name |
735 | + LOG.debug(_("Getting object: %(bname)s / %(nm)s") % locals()) |
736 | |
737 | if not self.bucket.is_authorized(request.context): |
738 | - LOG.audit(_("Unauthorized attempt to get object %s from bucket " |
739 | - "%s"), self.name, self.bucket.name, |
740 | - context=request.context) |
741 | + LOG.audit(_("Unauthorized attempt to get object %(nm)s" |
742 | + " from bucket %(bname)s") % locals(), |
743 | + context=request.context) |
744 | raise exception.NotAuthorized() |
745 | |
746 | obj = self.bucket[urllib.unquote(self.name)] |
747 | @@ -289,12 +291,13 @@ |
748 | Raises NotAuthorized if user in request context is not |
749 | authorized to delete the object. |
750 | """ |
751 | - LOG.debug(_("Putting object: %s / %s"), self.bucket.name, self.name) |
752 | + nm = self.name |
753 | + bname = self.bucket.name |
754 | + LOG.debug(_("Putting object: %(bname)s / %(nm)s") % locals()) |
755 | |
756 | if not self.bucket.is_authorized(request.context): |
757 | - LOG.audit(_("Unauthorized attempt to upload object %s to bucket " |
758 | - "%s"), |
759 | - self.name, self.bucket.name, context=request.context) |
760 | + LOG.audit(_("Unauthorized attempt to upload object %(nm)s to" |
761 | + " bucket %(bname)s") % locals(), context=request.context) |
762 | raise exception.NotAuthorized() |
763 | |
764 | key = urllib.unquote(self.name) |
765 | @@ -310,16 +313,14 @@ |
766 | Raises NotAuthorized if user in request context is not |
767 | authorized to delete the object. |
768 | """ |
769 | - |
770 | - LOG.debug(_("Deleting object: %s / %s"), self.bucket.name, self.name, |
771 | + nm = self.name |
772 | + bname = self.bucket.name |
773 | + LOG.debug(_("Deleting object: %(bname)s / %(nm)s") % locals(), |
774 | context=request.context) |
775 | |
776 | if not self.bucket.is_authorized(request.context): |
777 | - LOG.audit(_("Unauthorized attempt to delete object " |
778 | - "%(object)s from bucket %(bucket)s") % |
779 | - {'object': self.name, |
780 | - 'bucket': self.bucket.name}, |
781 | - context=request.context) |
782 | + LOG.audit(_("Unauthorized attempt to delete object %(nm)s from " |
783 | + "bucket %(bname)s") % locals(), context=request.context) |
784 | raise exception.NotAuthorized() |
785 | |
786 | del self.bucket[urllib.unquote(self.name)] |
787 | @@ -390,10 +391,10 @@ |
788 | image_location = get_argument(request, 'image_location', u'') |
789 | |
790 | image_path = os.path.join(FLAGS.images_path, image_id) |
791 | - if not image_path.startswith(FLAGS.images_path) or \ |
792 | - os.path.exists(image_path): |
793 | + if ((not image_path.startswith(FLAGS.images_path)) or |
794 | + os.path.exists(image_path)): |
795 | LOG.audit(_("Not authorized to upload image: invalid directory " |
796 | - "%s"), |
797 | + "%s"), |
798 | image_path, context=request.context) |
799 | raise exception.NotAuthorized() |
800 | |
801 | @@ -427,8 +428,8 @@ |
802 | if operation: |
803 | # operation implies publicity toggle |
804 | newstatus = (operation == 'add') |
805 | - LOG.audit(_("Toggling publicity flag of image %s %r"), image_id, |
806 | - newstatus, context=request.context) |
807 | + LOG.audit(_("Toggling publicity flag of image %(image_id)s" |
808 | + " %(newstatus)r") % locals(), context=request.context) |
809 | image_object.set_public(newstatus) |
810 | else: |
811 | # other attributes imply update |
812 | |
813 | === modified file 'nova/rpc.py' |
814 | --- nova/rpc.py 2011-01-20 17:52:02 +0000 |
815 | +++ nova/rpc.py 2011-01-24 15:23:08 +0000 |
816 | @@ -89,15 +89,16 @@ |
817 | self.failed_connection = False |
818 | break |
819 | except: # Catching all because carrot sucks |
820 | - LOG.exception(_("AMQP server on %s:%d is unreachable." |
821 | - " Trying again in %d seconds.") % ( |
822 | - FLAGS.rabbit_host, |
823 | - FLAGS.rabbit_port, |
824 | - FLAGS.rabbit_retry_interval)) |
825 | + fl_host = FLAGS.rabbit_host |
826 | + fl_port = FLAGS.rabbit_port |
827 | + fl_intv = FLAGS.rabbit_retry_interval |
828 | + LOG.exception(_("AMQP server on %(fl_host)s:%(fl_port)d is" |
829 | + " unreachable. Trying again in %(fl_intv)d seconds.") |
830 | + % locals()) |
831 | self.failed_connection = True |
832 | if self.failed_connection: |
833 | LOG.exception(_("Unable to connect to AMQP server " |
834 | - "after %d tries. Shutting down."), |
835 | + "after %d tries. Shutting down."), |
836 | FLAGS.rabbit_max_retries) |
837 | sys.exit(1) |
838 | |
839 | @@ -152,7 +153,7 @@ |
840 | class AdapterConsumer(TopicConsumer): |
841 | """Calls methods on a proxy object based on method and args""" |
842 | def __init__(self, connection=None, topic="broadcast", proxy=None): |
843 | - LOG.debug(_('Initing the Adapter Consumer for %s') % (topic)) |
844 | + LOG.debug(_('Initing the Adapter Consumer for %s') % topic) |
845 | self.proxy = proxy |
846 | super(AdapterConsumer, self).__init__(connection=connection, |
847 | topic=topic) |
848 | @@ -167,7 +168,7 @@ |
849 | |
850 | Example: {'method': 'echo', 'args': {'value': 42}} |
851 | """ |
852 | - LOG.debug(_('received %s') % (message_data)) |
853 | + LOG.debug(_('received %s') % message_data) |
854 | msg_id = message_data.pop('_msg_id', None) |
855 | |
856 | ctxt = _unpack_context(message_data) |
857 | @@ -180,7 +181,7 @@ |
858 | # messages stay in the queue indefinitely, so for now |
859 | # we just log the message and send an error string |
860 | # back to the caller |
861 | - LOG.warn(_('no method for message: %s') % (message_data)) |
862 | + LOG.warn(_('no method for message: %s') % message_data) |
863 | msg_reply(msg_id, _('No method for message: %s') % message_data) |
864 | return |
865 | |
866 | |
867 | === modified file 'nova/scheduler/manager.py' |
868 | --- nova/scheduler/manager.py 2011-01-18 19:01:16 +0000 |
869 | +++ nova/scheduler/manager.py 2011-01-24 15:23:08 +0000 |
870 | @@ -66,4 +66,4 @@ |
871 | db.queue_get_for(context, topic, host), |
872 | {"method": method, |
873 | "args": kwargs}) |
874 | - LOG.debug(_("Casting to %s %s for %s"), topic, host, method) |
875 | + LOG.debug(_("Casting to %(topic)s %(host)s for %(method)s") % locals()) |
876 | |
877 | === modified file 'nova/service.py' |
878 | --- nova/service.py 2011-01-20 11:20:50 +0000 |
879 | +++ nova/service.py 2011-01-24 15:23:08 +0000 |
880 | @@ -221,10 +221,10 @@ |
881 | |
882 | name = '_'.join(x.binary for x in services) |
883 | logging.debug(_("Serving %s"), name) |
884 | - |
885 | logging.debug(_("Full set of FLAGS:")) |
886 | for flag in FLAGS: |
887 | - logging.debug("%s : %s" % (flag, FLAGS.get(flag, None))) |
888 | + flag_get = FLAGS.get(flag, None) |
889 | + logging.debug("%(flag)s : %(flag_get)s" % locals()) |
890 | |
891 | for x in services: |
892 | x.start() |
893 | |
894 | === modified file 'nova/tests/test_rpc.py' |
895 | --- nova/tests/test_rpc.py 2011-01-07 14:46:17 +0000 |
896 | +++ nova/tests/test_rpc.py 2011-01-24 15:23:08 +0000 |
897 | @@ -86,7 +86,8 @@ |
898 | @staticmethod |
899 | def echo(context, queue, value): |
900 | """Calls echo in the passed queue""" |
901 | - LOG.debug(_("Nested received %s, %s"), queue, value) |
902 | + LOG.debug(_("Nested received %(queue)s, %(value)s") |
903 | + % locals()) |
904 | ret = rpc.call(context, |
905 | queue, |
906 | {"method": "echo", |
907 | |
908 | === modified file 'nova/utils.py' |
909 | --- nova/utils.py 2011-01-18 23:50:47 +0000 |
910 | +++ nova/utils.py 2011-01-24 15:23:08 +0000 |
911 | @@ -138,7 +138,7 @@ |
912 | result = obj.communicate() |
913 | obj.stdin.close() |
914 | if obj.returncode: |
915 | - LOG.debug(_("Result was %s") % (obj.returncode)) |
916 | + LOG.debug(_("Result was %s") % obj.returncode) |
917 | if check_exit_code and obj.returncode != 0: |
918 | (stdout, stderr) = result |
919 | raise ProcessExecutionError(exit_code=obj.returncode, |
920 | @@ -214,9 +214,11 @@ |
921 | else: |
922 | return 'fe00::' |
923 | except IndexError as ex: |
924 | - LOG.warn(_("Couldn't get Link Local IP of %s :%s"), interface, ex) |
925 | + LOG.warn(_("Couldn't get Link Local IP of %(interface)s :%(ex)s") |
926 | + % locals()) |
927 | except ProcessExecutionError as ex: |
928 | - LOG.warn(_("Couldn't get Link Local IP of %s :%s"), interface, ex) |
929 | + LOG.warn(_("Couldn't get Link Local IP of %(interface)s :%(ex)s") |
930 | + % locals()) |
931 | except: |
932 | return 'fe00::' |
933 | |
934 | |
935 | === modified file 'nova/virt/hyperv.py' |
936 | --- nova/virt/hyperv.py 2011-01-12 11:43:29 +0000 |
937 | +++ nova/virt/hyperv.py 2011-01-24 15:23:08 +0000 |
938 | @@ -129,7 +129,7 @@ |
939 | vm = self._lookup(instance.name) |
940 | if vm is not None: |
941 | raise exception.Duplicate(_('Attempt to create duplicate vm %s') % |
942 | - instance.name) |
943 | + instance.name) |
944 | |
945 | user = manager.AuthManager().get_user(instance['user_id']) |
946 | project = manager.AuthManager().get_project(instance['project_id']) |
947 | @@ -159,7 +159,7 @@ |
948 | vs_gs_data = self._conn.Msvm_VirtualSystemGlobalSettingData.new() |
949 | vs_gs_data.ElementName = instance['name'] |
950 | (job, ret_val) = vs_man_svc.DefineVirtualSystem( |
951 | - [], None, vs_gs_data.GetText_(1))[1:] |
952 | + [], None, vs_gs_data.GetText_(1))[1:] |
953 | if ret_val == WMI_JOB_STATUS_STARTED: |
954 | success = self._check_job_status(job) |
955 | else: |
956 | @@ -184,40 +184,40 @@ |
957 | memsetting.Limit = mem |
958 | |
959 | (job, ret_val) = vs_man_svc.ModifyVirtualSystemResources( |
960 | - vm.path_(), [memsetting.GetText_(1)]) |
961 | + vm.path_(), [memsetting.GetText_(1)]) |
962 | LOG.debug(_('Set memory for vm %s...'), instance.name) |
963 | procsetting = vmsetting.associators( |
964 | - wmi_result_class='Msvm_ProcessorSettingData')[0] |
965 | + wmi_result_class='Msvm_ProcessorSettingData')[0] |
966 | vcpus = long(instance['vcpus']) |
967 | procsetting.VirtualQuantity = vcpus |
968 | procsetting.Reservation = vcpus |
969 | procsetting.Limit = vcpus |
970 | |
971 | (job, ret_val) = vs_man_svc.ModifyVirtualSystemResources( |
972 | - vm.path_(), [procsetting.GetText_(1)]) |
973 | + vm.path_(), [procsetting.GetText_(1)]) |
974 | LOG.debug(_('Set vcpus for vm %s...'), instance.name) |
975 | |
976 | def _create_disk(self, vm_name, vhdfile): |
977 | """Create a disk and attach it to the vm""" |
978 | - LOG.debug(_('Creating disk for %s by attaching disk file %s'), |
979 | - vm_name, vhdfile) |
980 | + LOG.debug(_('Creating disk for %(vm_name)s by attaching' |
981 | + ' disk file %(vhdfile)s') % locals()) |
982 | #Find the IDE controller for the vm. |
983 | vms = self._conn.MSVM_ComputerSystem(ElementName=vm_name) |
984 | vm = vms[0] |
985 | vmsettings = vm.associators( |
986 | - wmi_result_class='Msvm_VirtualSystemSettingData') |
987 | + wmi_result_class='Msvm_VirtualSystemSettingData') |
988 | rasds = vmsettings[0].associators( |
989 | - wmi_result_class='MSVM_ResourceAllocationSettingData') |
990 | + wmi_result_class='MSVM_ResourceAllocationSettingData') |
991 | ctrller = [r for r in rasds |
992 | if r.ResourceSubType == 'Microsoft Emulated IDE Controller'\ |
993 | - and r.Address == "0"] |
994 | + and r.Address == "0"] |
995 | #Find the default disk drive object for the vm and clone it. |
996 | diskdflt = self._conn.query( |
997 | - "SELECT * FROM Msvm_ResourceAllocationSettingData \ |
998 | - WHERE ResourceSubType LIKE 'Microsoft Synthetic Disk Drive'\ |
999 | - AND InstanceID LIKE '%Default%'")[0] |
1000 | + "SELECT * FROM Msvm_ResourceAllocationSettingData \ |
1001 | + WHERE ResourceSubType LIKE 'Microsoft Synthetic Disk Drive'\ |
1002 | + AND InstanceID LIKE '%Default%'")[0] |
1003 | diskdrive = self._clone_wmi_obj( |
1004 | - 'Msvm_ResourceAllocationSettingData', diskdflt) |
1005 | + 'Msvm_ResourceAllocationSettingData', diskdflt) |
1006 | #Set the IDE ctrller as parent. |
1007 | diskdrive.Parent = ctrller[0].path_() |
1008 | diskdrive.Address = 0 |
1009 | @@ -263,17 +263,18 @@ |
1010 | default_nic_data = [n for n in emulatednics_data |
1011 | if n.InstanceID.rfind('Default') > 0] |
1012 | new_nic_data = self._clone_wmi_obj( |
1013 | - 'Msvm_EmulatedEthernetPortSettingData', |
1014 | - default_nic_data[0]) |
1015 | + 'Msvm_EmulatedEthernetPortSettingData', |
1016 | + default_nic_data[0]) |
1017 | #Create a port on the vswitch. |
1018 | (new_port, ret_val) = switch_svc.CreateSwitchPort(vm_name, vm_name, |
1019 | "", extswitch.path_()) |
1020 | if ret_val != 0: |
1021 | LOG.error(_('Failed creating a port on the external vswitch')) |
1022 | raise Exception(_('Failed creating port for %s'), |
1023 | - vm_name) |
1024 | - LOG.debug(_("Created switch port %s on switch %s"), |
1025 | - vm_name, extswitch.path_()) |
1026 | + vm_name) |
1027 | + ext_path = extswitch.path_() |
1028 | + LOG.debug(_("Created switch port %(vm_name)s on switch %(ext_path)s") |
1029 | + % locals()) |
1030 | #Connect the new nic to the new port. |
1031 | new_nic_data.Connection = [new_port] |
1032 | new_nic_data.ElementName = vm_name + ' nic' |
1033 | @@ -283,7 +284,7 @@ |
1034 | new_resources = self._add_virt_resource(new_nic_data, vm) |
1035 | if new_resources is None: |
1036 | raise Exception(_('Failed to add nic to VM %s'), |
1037 | - vm_name) |
1038 | + vm_name) |
1039 | LOG.info(_("Created nic for %s "), vm_name) |
1040 | |
1041 | def _add_virt_resource(self, res_setting_data, target_vm): |
1042 | @@ -319,8 +320,10 @@ |
1043 | if job.JobState != WMI_JOB_STATE_COMPLETED: |
1044 | LOG.debug(_("WMI job failed: %s"), job.ErrorSummaryDescription) |
1045 | return False |
1046 | - LOG.debug(_("WMI job succeeded: %s, Elapsed=%s "), job.Description, |
1047 | - job.ElapsedTime) |
1048 | + desc = job.Description |
1049 | + elap = job.ElapsedTime |
1050 | + LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s ") |
1051 | + % locals()) |
1052 | return True |
1053 | |
1054 | def _find_external_network(self): |
1055 | @@ -386,7 +389,9 @@ |
1056 | vhdfile = self._cim_conn.CIM_DataFile(Name=disk) |
1057 | for vf in vhdfile: |
1058 | vf.Delete() |
1059 | - LOG.debug(_("Del: disk %s vm %s"), vhdfile, instance.name) |
1060 | + instance_name = instance.name |
1061 | + LOG.debug(_("Del: disk %(vhdfile)s vm %(instance_name)s") |
1062 | + % locals()) |
1063 | |
1064 | def get_info(self, instance_id): |
1065 | """Get information about the VM""" |
1066 | @@ -402,12 +407,14 @@ |
1067 | summary_info = vs_man_svc.GetSummaryInformation( |
1068 | [4, 100, 103, 105], settings_paths)[1] |
1069 | info = summary_info[0] |
1070 | - LOG.debug(_("Got Info for vm %s: state=%s, mem=%s, num_cpu=%s, \ |
1071 | - cpu_time=%s"), instance_id, |
1072 | - str(HYPERV_POWER_STATE[info.EnabledState]), |
1073 | - str(info.MemoryUsage), |
1074 | - str(info.NumberOfProcessors), |
1075 | - str(info.UpTime)) |
1076 | + state = str(HYPERV_POWER_STATE[info.EnabledState]) |
1077 | + memusage = str(info.MemoryUsage) |
1078 | + numprocs = str(info.NumberOfProcessors) |
1079 | + uptime = str(info.UpTime) |
1080 | + |
1081 | + LOG.debug(_("Got Info for vm %(instance_id)s: state=%(state)s," |
1082 | + " mem=%(memusage)s, num_cpu=%(numprocs)s," |
1083 | + " cpu_time=%(uptime)s") % locals()) |
1084 | |
1085 | return {'state': HYPERV_POWER_STATE[info.EnabledState], |
1086 | 'max_mem': info.MemoryUsage, |
1087 | @@ -441,22 +448,22 @@ |
1088 | #already in the state requested |
1089 | success = True |
1090 | if success: |
1091 | - LOG.info(_("Successfully changed vm state of %s to %s"), vm_name, |
1092 | - req_state) |
1093 | + LOG.info(_("Successfully changed vm state of %(vm_name)s" |
1094 | + " to %(req_state)s") % locals()) |
1095 | else: |
1096 | - LOG.error(_("Failed to change vm state of %s to %s"), vm_name, |
1097 | - req_state) |
1098 | - raise Exception(_("Failed to change vm state of %s to %s"), |
1099 | - vm_name, req_state) |
1100 | + msg = _("Failed to change vm state of %(vm_name)s" |
1101 | + " to %(req_state)s") % locals() |
1102 | + LOG.error(msg) |
1103 | + raise Exception(msg) |
1104 | |
1105 | def attach_volume(self, instance_name, device_path, mountpoint): |
1106 | vm = self._lookup(instance_name) |
1107 | if vm is None: |
1108 | - raise exception.NotFound('Cannot attach volume to missing %s vm' % |
1109 | - instance_name) |
1110 | + raise exception.NotFound('Cannot attach volume to missing %s vm' |
1111 | + % instance_name) |
1112 | |
1113 | def detach_volume(self, instance_name, mountpoint): |
1114 | vm = self._lookup(instance_name) |
1115 | if vm is None: |
1116 | - raise exception.NotFound('Cannot detach volume from missing %s ' % |
1117 | - instance_name) |
1118 | + raise exception.NotFound('Cannot detach volume from missing %s ' |
1119 | + % instance_name) |
1120 | |
1121 | === modified file 'nova/virt/images.py' |
1122 | --- nova/virt/images.py 2011-01-07 20:29:35 +0000 |
1123 | +++ nova/virt/images.py 2011-01-24 15:23:08 +0000 |
1124 | @@ -67,7 +67,7 @@ |
1125 | |
1126 | urlopened = urllib2.urlopen(request) |
1127 | urlretrieve(urlopened, path) |
1128 | - LOG.debug(_("Finished retreving %s -- placed in %s"), url, path) |
1129 | + LOG.debug(_("Finished retreving %(url)s -- placed in %(path)s") % locals()) |
1130 | |
1131 | |
1132 | def _fetch_s3_image(image, path, user, project): |
1133 | |
1134 | === modified file 'nova/virt/libvirt_conn.py' |
1135 | --- nova/virt/libvirt_conn.py 2011-01-21 09:08:21 +0000 |
1136 | +++ nova/virt/libvirt_conn.py 2011-01-24 15:23:08 +0000 |
1137 | @@ -236,8 +236,9 @@ |
1138 | |
1139 | def _cleanup(self, instance): |
1140 | target = os.path.join(FLAGS.instances_path, instance['name']) |
1141 | - LOG.info(_('instance %s: deleting instance files %s'), |
1142 | - instance['name'], target) |
1143 | + instance_name = instance['name'] |
1144 | + LOG.info(_('instance %(instance_name)s: deleting instance files' |
1145 | + ' %(target)s') % locals()) |
1146 | if os.path.exists(target): |
1147 | shutil.rmtree(target) |
1148 | |
1149 | @@ -418,7 +419,7 @@ |
1150 | virsh_output = virsh_output[0].strip() |
1151 | |
1152 | if virsh_output.startswith('/dev/'): |
1153 | - LOG.info(_('cool, it\'s a device')) |
1154 | + LOG.info(_("cool, it's a device")) |
1155 | out, err = utils.execute("sudo dd if=%s iflag=nonblock" % |
1156 | virsh_output, check_exit_code=False) |
1157 | return out |
1158 | @@ -426,7 +427,7 @@ |
1159 | return '' |
1160 | |
1161 | def _append_to_file(self, data, fpath): |
1162 | - LOG.info(_('data: %r, fpath: %r'), data, fpath) |
1163 | + LOG.info(_('data: %(data)r, fpath: %(fpath)r') % locals()) |
1164 | fp = open(fpath, 'a+') |
1165 | fp.write(data) |
1166 | return fpath |
1167 | @@ -434,7 +435,7 @@ |
1168 | def _dump_file(self, fpath): |
1169 | fp = open(fpath, 'r+') |
1170 | contents = fp.read() |
1171 | - LOG.info(_('Contents of file %s: %r'), fpath, contents) |
1172 | + LOG.info(_('Contents of file %(fpath)s: %(contents)r') % locals()) |
1173 | return contents |
1174 | |
1175 | @exception.wrap_exception |
1176 | @@ -621,21 +622,22 @@ |
1177 | 'dns': network_ref['dns'], |
1178 | 'ra_server': ra_server} |
1179 | if key or net: |
1180 | + inst_name = inst['name'] |
1181 | + img_id = inst.image_id |
1182 | if key: |
1183 | - LOG.info(_('instance %s: injecting key into image %s'), |
1184 | - inst['name'], inst.image_id) |
1185 | + LOG.info(_('instance %(inst_name)s: injecting key into' |
1186 | + ' image %(img_id)s') % locals()) |
1187 | if net: |
1188 | - LOG.info(_('instance %s: injecting net into image %s'), |
1189 | - inst['name'], inst.image_id) |
1190 | + LOG.info(_('instance %(inst_name)s: injecting net into' |
1191 | + ' image %(img_id)s') % locals()) |
1192 | try: |
1193 | disk.inject_data(basepath('disk'), key, net, |
1194 | partition=target_partition, |
1195 | nbd=FLAGS.use_cow_images) |
1196 | except Exception as e: |
1197 | # This could be a windows image, or a vmdk format disk |
1198 | - LOG.warn(_('instance %s: ignoring error injecting data' |
1199 | - ' into image %s (%s)'), |
1200 | - inst['name'], inst.image_id, e) |
1201 | + LOG.warn(_('instance %(inst_name)s: ignoring error injecting' |
1202 | + ' data into image %(img_id)s (%(e)s)') % locals()) |
1203 | |
1204 | if FLAGS.libvirt_type == 'uml': |
1205 | utils.execute('sudo chown root %s' % basepath('disk')) |
1206 | |
1207 | === modified file 'nova/virt/xenapi/fake.py' |
1208 | --- nova/virt/xenapi/fake.py 2011-01-12 11:54:58 +0000 |
1209 | +++ nova/virt/xenapi/fake.py 2011-01-24 15:23:08 +0000 |
1210 | @@ -69,7 +69,9 @@ |
1211 | |
1212 | |
1213 | def log_db_contents(msg=None): |
1214 | - LOG.debug(_("%s: _db_content => %s"), msg or "", pformat(_db_content)) |
1215 | + text = msg or "" |
1216 | + content = pformat(_db_content) |
1217 | + LOG.debug(_("%(text)s: _db_content => %(content)s") % locals()) |
1218 | |
1219 | |
1220 | def reset(): |
1221 | @@ -331,7 +333,8 @@ |
1222 | if impl is not None: |
1223 | |
1224 | def callit(*params): |
1225 | - LOG.debug(_('Calling %s %s'), name, impl) |
1226 | + localname = name |
1227 | + LOG.debug(_('Calling %(localname)s %(impl)s') % locals()) |
1228 | self._check_session(params) |
1229 | return impl(*params) |
1230 | return callit |
1231 | |
1232 | === modified file 'nova/virt/xenapi/vm_utils.py' |
1233 | --- nova/virt/xenapi/vm_utils.py 2011-01-21 22:16:52 +0000 |
1234 | +++ nova/virt/xenapi/vm_utils.py 2011-01-24 15:23:08 +0000 |
1235 | @@ -134,7 +134,8 @@ |
1236 | 'pae': 'true', 'viridian': 'true'} |
1237 | LOG.debug(_('Created VM %s...'), instance.name) |
1238 | vm_ref = session.call_xenapi('VM.create', rec) |
1239 | - LOG.debug(_('Created VM %s as %s.'), instance.name, vm_ref) |
1240 | + instance_name = instance.name |
1241 | + LOG.debug(_('Created VM %(instance_name)s as %(vm_ref)s.') % locals()) |
1242 | return vm_ref |
1243 | |
1244 | @classmethod |
1245 | @@ -154,10 +155,11 @@ |
1246 | vbd_rec['qos_algorithm_type'] = '' |
1247 | vbd_rec['qos_algorithm_params'] = {} |
1248 | vbd_rec['qos_supported_algorithms'] = [] |
1249 | - LOG.debug(_('Creating VBD for VM %s, VDI %s ... '), vm_ref, vdi_ref) |
1250 | + LOG.debug(_('Creating VBD for VM %(vm_ref)s,' |
1251 | + ' VDI %(vdi_ref)s ... ') % locals()) |
1252 | vbd_ref = session.call_xenapi('VBD.create', vbd_rec) |
1253 | - LOG.debug(_('Created VBD %s for VM %s, VDI %s.'), vbd_ref, vm_ref, |
1254 | - vdi_ref) |
1255 | + LOG.debug(_('Created VBD %(vbd_ref)s for VM %(vm_ref)s,' |
1256 | + ' VDI %(vdi_ref)s.') % locals()) |
1257 | return vbd_ref |
1258 | |
1259 | @classmethod |
1260 | @@ -209,11 +211,11 @@ |
1261 | vif_rec['other_config'] = {} |
1262 | vif_rec['qos_algorithm_type'] = '' |
1263 | vif_rec['qos_algorithm_params'] = {} |
1264 | - LOG.debug(_('Creating VIF for VM %s, network %s.'), vm_ref, |
1265 | - network_ref) |
1266 | + LOG.debug(_('Creating VIF for VM %(vm_ref)s,' |
1267 | + ' network %(network_ref)s.') % locals()) |
1268 | vif_ref = session.call_xenapi('VIF.create', vif_rec) |
1269 | - LOG.debug(_('Created VIF %s for VM %s, network %s.'), vif_ref, |
1270 | - vm_ref, network_ref) |
1271 | + LOG.debug(_('Created VIF %(vif_ref)s for VM %(vm_ref)s,' |
1272 | + ' network %(network_ref)s.') % locals()) |
1273 | return vif_ref |
1274 | |
1275 | @classmethod |
1276 | @@ -231,8 +233,9 @@ |
1277 | 'other_config': {}, |
1278 | 'sm_config': {}, |
1279 | 'tags': []}) |
1280 | - LOG.debug(_('Created VDI %s (%s, %s, %s) on %s.'), vdi_ref, |
1281 | - name_label, virtual_size, read_only, sr_ref) |
1282 | + LOG.debug(_('Created VDI %(vdi_ref)s (%(name_label)s,' |
1283 | + ' %(virtual_size)s, %(read_only)s) on %(sr_ref)s.') |
1284 | + % locals()) |
1285 | return vdi_ref |
1286 | |
1287 | @classmethod |
1288 | @@ -242,7 +245,8 @@ |
1289 | """ |
1290 | #TODO(sirp): Add quiesce and VSS locking support when Windows support |
1291 | # is added |
1292 | - LOG.debug(_("Snapshotting VM %s with label '%s'..."), vm_ref, label) |
1293 | + LOG.debug(_("Snapshotting VM %(vm_ref)s with label '%(label)s'...") |
1294 | + % locals()) |
1295 | |
1296 | vm_vdi_ref, vm_vdi_rec = get_vdi_for_vm_safely(session, vm_ref) |
1297 | vm_vdi_uuid = vm_vdi_rec["uuid"] |
1298 | @@ -255,8 +259,8 @@ |
1299 | template_vdi_rec = get_vdi_for_vm_safely(session, template_vm_ref)[1] |
1300 | template_vdi_uuid = template_vdi_rec["uuid"] |
1301 | |
1302 | - LOG.debug(_('Created snapshot %s from VM %s.'), template_vm_ref, |
1303 | - vm_ref) |
1304 | + LOG.debug(_('Created snapshot %(template_vm_ref)s from' |
1305 | + ' VM %(vm_ref)s.') % locals()) |
1306 | |
1307 | parent_uuid = wait_for_vhd_coalesce( |
1308 | session, instance_id, sr_ref, vm_vdi_ref, original_parent_uuid) |
1309 | @@ -269,8 +273,8 @@ |
1310 | """ Requests that the Glance plugin bundle the specified VDIs and |
1311 | push them into Glance using the specified human-friendly name. |
1312 | """ |
1313 | - logging.debug(_("Asking xapi to upload %s as ID %s"), |
1314 | - vdi_uuids, image_id) |
1315 | + logging.debug(_("Asking xapi to upload %(vdi_uuids)s as" |
1316 | + " ID %(image_id)s") % locals()) |
1317 | |
1318 | params = {'vdi_uuids': vdi_uuids, |
1319 | 'image_id': image_id, |
1320 | @@ -310,7 +314,7 @@ |
1321 | meta, image_file = c.get_image(image) |
1322 | virtual_size = int(meta['size']) |
1323 | vdi_size = virtual_size |
1324 | - LOG.debug(_("Size for image %s:%d"), image, virtual_size) |
1325 | + LOG.debug(_("Size for image %(image)s:%(virtual_size)d") % locals()) |
1326 | if type == ImageType.DISK: |
1327 | # Make room for MBR. |
1328 | vdi_size += MBR_SIZE_BYTES |
1329 | @@ -344,7 +348,7 @@ |
1330 | def _fetch_image_objectstore(cls, session, instance_id, image, access, |
1331 | secret, type): |
1332 | url = images.image_url(image) |
1333 | - LOG.debug(_("Asking xapi to fetch %s as %s"), url, access) |
1334 | + LOG.debug(_("Asking xapi to fetch %(url)s as %(access)s") % locals()) |
1335 | fn = (type != ImageType.KERNEL_RAMDISK) and 'get_vdi' or 'get_kernel' |
1336 | args = {} |
1337 | args['src_url'] = url |
1338 | @@ -499,7 +503,8 @@ |
1339 | parent_uuid = vdi_rec['sm_config']['vhd-parent'] |
1340 | parent_ref = session.get_xenapi().VDI.get_by_uuid(parent_uuid) |
1341 | parent_rec = session.get_xenapi().VDI.get_record(parent_ref) |
1342 | - LOG.debug(_("VHD %s has parent %s"), vdi_rec['uuid'], parent_ref) |
1343 | + vdi_uuid = vdi_rec['uuid'] |
1344 | + LOG.debug(_("VHD %(vdi_uuid)s has parent %(parent_ref)s") % locals()) |
1345 | return parent_ref, parent_rec |
1346 | else: |
1347 | return None |
1348 | @@ -540,16 +545,17 @@ |
1349 | def _poll_vhds(): |
1350 | attempts['counter'] += 1 |
1351 | if attempts['counter'] > max_attempts: |
1352 | - msg = (_("VHD coalesce attempts exceeded (%d > %d), giving up...") |
1353 | - % (attempts['counter'], max_attempts)) |
1354 | + counter = attempts['counter'] |
1355 | + msg = (_("VHD coalesce attempts exceeded (%(counter)d >" |
1356 | + " %(max_attempts)d), giving up...") % locals()) |
1357 | raise exception.Error(msg) |
1358 | |
1359 | scan_sr(session, instance_id, sr_ref) |
1360 | parent_uuid = get_vhd_parent_uuid(session, vdi_ref) |
1361 | if original_parent_uuid and (parent_uuid != original_parent_uuid): |
1362 | - LOG.debug(_("Parent %s doesn't match original parent %s, " |
1363 | - "waiting for coalesce..."), parent_uuid, |
1364 | - original_parent_uuid) |
1365 | + LOG.debug(_("Parent %(parent_uuid)s doesn't match original parent" |
1366 | + " %(original_parent_uuid)s, waiting for coalesce...") |
1367 | + % locals()) |
1368 | else: |
1369 | # Breakout of the loop (normally) and return the parent_uuid |
1370 | raise utils.LoopingCallDone(parent_uuid) |
1371 | @@ -567,8 +573,8 @@ |
1372 | else: |
1373 | num_vdis = len(vdi_refs) |
1374 | if num_vdis != 1: |
1375 | - raise Exception(_("Unexpected number of VDIs (%s) found for " |
1376 | - "VM %s") % (num_vdis, vm_ref)) |
1377 | + raise Exception(_("Unexpected number of VDIs (%(num_vdis)s) found" |
1378 | + " for VM %(vm_ref)s") % locals()) |
1379 | |
1380 | vdi_ref = vdi_refs[0] |
1381 | vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref) |
1382 | @@ -708,8 +714,8 @@ |
1383 | primary_first = MBR_SIZE_SECTORS |
1384 | primary_last = MBR_SIZE_SECTORS + (virtual_size / SECTOR_SIZE) - 1 |
1385 | |
1386 | - LOG.debug(_('Writing partition table %d %d to %s...'), |
1387 | - primary_first, primary_last, dest) |
1388 | + LOG.debug(_('Writing partition table %(primary_first)d %(primary_last)d' |
1389 | + ' to %(dest)s...') % locals()) |
1390 | |
1391 | def execute(cmd, process_input=None, check_exit_code=True): |
1392 | return utils.execute(cmd=cmd, |
1393 | |
1394 | === modified file 'nova/virt/xenapi/vmops.py' |
1395 | --- nova/virt/xenapi/vmops.py 2011-01-22 04:59:58 +0000 |
1396 | +++ nova/virt/xenapi/vmops.py 2011-01-24 15:23:08 +0000 |
1397 | @@ -104,7 +104,9 @@ |
1398 | network_ref, instance.mac_address) |
1399 | LOG.debug(_('Starting VM %s...'), vm_ref) |
1400 | self._session.call_xenapi('VM.start', vm_ref, False, False) |
1401 | - LOG.info(_('Spawning VM %s created %s.'), instance.name, vm_ref) |
1402 | + instance_name = instance.name |
1403 | + LOG.info(_('Spawning VM %(instance_name)s created %(vm_ref)s.') |
1404 | + % locals()) |
1405 | |
1406 | # NOTE(armando): Do we really need to do this in virt? |
1407 | timer = utils.LoopingCall(f=None) |
1408 | @@ -196,7 +198,8 @@ |
1409 | template_vm_ref, template_vdi_uuids = VMHelper.create_snapshot( |
1410 | self._session, instance.id, vm_ref, label) |
1411 | except self.XenAPI.Failure, exc: |
1412 | - logging.error(_("Unable to Snapshot %s: %s"), vm_ref, exc) |
1413 | + logging.error(_("Unable to Snapshot %(vm_ref)s: %(exc)s") |
1414 | + % locals()) |
1415 | return |
1416 | |
1417 | try: |
1418 | |
1419 | === modified file 'nova/virt/xenapi/volume_utils.py' |
1420 | --- nova/virt/xenapi/volume_utils.py 2011-01-07 14:46:17 +0000 |
1421 | +++ nova/virt/xenapi/volume_utils.py 2011-01-24 15:23:08 +0000 |
1422 | @@ -71,7 +71,7 @@ |
1423 | session.get_xenapi_host(), |
1424 | record, |
1425 | '0', label, description, 'iscsi', '', False, {}) |
1426 | - LOG.debug(_('Introduced %s as %s.'), label, sr_ref) |
1427 | + LOG.debug(_('Introduced %(label)s as %(sr_ref)s.') % locals()) |
1428 | return sr_ref |
1429 | except cls.XenAPI.Failure, exc: |
1430 | LOG.exception(exc) |
1431 | @@ -98,20 +98,20 @@ |
1432 | try: |
1433 | pbds = session.get_xenapi().SR.get_PBDs(sr_ref) |
1434 | except cls.XenAPI.Failure, exc: |
1435 | - LOG.warn(_('Ignoring exception %s when getting PBDs for %s'), |
1436 | - exc, sr_ref) |
1437 | + LOG.warn(_('Ignoring exception %(exc)s when getting PBDs' |
1438 | + ' for %(sr_ref)s') % locals()) |
1439 | for pbd in pbds: |
1440 | try: |
1441 | session.get_xenapi().PBD.unplug(pbd) |
1442 | except cls.XenAPI.Failure, exc: |
1443 | - LOG.warn(_('Ignoring exception %s when unplugging PBD %s'), |
1444 | - exc, pbd) |
1445 | + LOG.warn(_('Ignoring exception %(exc)s when unplugging' |
1446 | + ' PBD %(pbd)s') % locals()) |
1447 | try: |
1448 | session.get_xenapi().SR.forget(sr_ref) |
1449 | LOG.debug(_("Forgetting SR %s done."), sr_ref) |
1450 | except cls.XenAPI.Failure, exc: |
1451 | - LOG.warn(_('Ignoring exception %s when forgetting SR %s'), exc, |
1452 | - sr_ref) |
1453 | + LOG.warn(_('Ignoring exception %(exc)s when forgetting' |
1454 | + ' SR %(sr_ref)s') % locals()) |
1455 | |
1456 | @classmethod |
1457 | def introduce_vdi(cls, session, sr_ref): |
1458 | @@ -172,8 +172,8 @@ |
1459 | (volume_id is None) or \ |
1460 | (target_host is None) or \ |
1461 | (target_iqn is None): |
1462 | - raise StorageError(_('Unable to obtain target information %s, %s') |
1463 | - % (device_path, mountpoint)) |
1464 | + raise StorageError(_('Unable to obtain target information' |
1465 | + ' %(device_path)s, %(mountpoint)s') % locals()) |
1466 | volume_info = {} |
1467 | volume_info['deviceNumber'] = device_number |
1468 | volume_info['volumeId'] = volume_id |
1469 | |
1470 | === modified file 'nova/virt/xenapi/volumeops.py' |
1471 | --- nova/virt/xenapi/volumeops.py 2011-01-04 05:23:35 +0000 |
1472 | +++ nova/virt/xenapi/volumeops.py 2011-01-24 15:23:08 +0000 |
1473 | @@ -48,8 +48,8 @@ |
1474 | raise exception.NotFound(_('Instance %s not found') |
1475 | % instance_name) |
1476 | # NOTE: No Resource Pool concept so far |
1477 | - LOG.debug(_("Attach_volume: %s, %s, %s"), |
1478 | - instance_name, device_path, mountpoint) |
1479 | + LOG.debug(_("Attach_volume: %(instance_name)s, %(device_path)s," |
1480 | + " %(mountpoint)s") % locals()) |
1481 | # Create the iSCSI SR, and the PDB through which hosts access SRs. |
1482 | # But first, retrieve target info, like Host, IQN, LUN and SCSIID |
1483 | vol_rec = VolumeHelper.parse_volume_info(device_path, mountpoint) |
1484 | @@ -66,9 +66,8 @@ |
1485 | except StorageError, exc: |
1486 | LOG.exception(exc) |
1487 | VolumeHelper.destroy_iscsi_storage(self._session, sr_ref) |
1488 | - raise Exception(_('Unable to create VDI on SR %s for instance %s') |
1489 | - % (sr_ref, |
1490 | - instance_name)) |
1491 | + raise Exception(_('Unable to create VDI on SR %(sr_ref)s for' |
1492 | + ' instance %(instance_name)s') % locals()) |
1493 | else: |
1494 | try: |
1495 | vbd_ref = VMHelper.create_vbd(self._session, |
1496 | @@ -78,9 +77,8 @@ |
1497 | except self.XenAPI.Failure, exc: |
1498 | LOG.exception(exc) |
1499 | VolumeHelper.destroy_iscsi_storage(self._session, sr_ref) |
1500 | - raise Exception(_('Unable to use SR %s for instance %s') |
1501 | - % (sr_ref, |
1502 | - instance_name)) |
1503 | + raise Exception(_('Unable to use SR %(sr_ref)s for' |
1504 | + ' instance %(instance_name)s') % locals()) |
1505 | else: |
1506 | try: |
1507 | task = self._session.call_xenapi('Async.VBD.plug', |
1508 | @@ -92,8 +90,8 @@ |
1509 | sr_ref) |
1510 | raise Exception(_('Unable to attach volume to instance %s') |
1511 | % instance_name) |
1512 | - LOG.info(_('Mountpoint %s attached to instance %s'), |
1513 | - mountpoint, instance_name) |
1514 | + LOG.info(_('Mountpoint %(mountpoint)s attached to' |
1515 | + ' instance %(instance_name)s') % locals()) |
1516 | |
1517 | def detach_volume(self, instance_name, mountpoint): |
1518 | """Detach volume storage to VM instance""" |
1519 | @@ -103,7 +101,8 @@ |
1520 | raise exception.NotFound(_('Instance %s not found') |
1521 | % instance_name) |
1522 | # Detach VBD from VM |
1523 | - LOG.debug(_("Detach_volume: %s, %s"), instance_name, mountpoint) |
1524 | + LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s") |
1525 | + % locals()) |
1526 | device_number = VolumeHelper.mountpoint_to_number(mountpoint) |
1527 | try: |
1528 | vbd_ref = VMHelper.find_vbd_by_number(self._session, |
1529 | @@ -125,5 +124,5 @@ |
1530 | LOG.exception(exc) |
1531 | # Forget SR |
1532 | VolumeHelper.destroy_iscsi_storage(self._session, sr_ref) |
1533 | - LOG.info(_('Mountpoint %s detached from instance %s'), |
1534 | - mountpoint, instance_name) |
1535 | + LOG.info(_('Mountpoint %(mountpoint)s detached from' |
1536 | + ' instance %(instance_name)s') % locals()) |
1537 | |
1538 | === modified file 'nova/virt/xenapi_conn.py' |
1539 | --- nova/virt/xenapi_conn.py 2011-01-21 21:31:47 +0000 |
1540 | +++ nova/virt/xenapi_conn.py 2011-01-24 15:23:08 +0000 |
1541 | @@ -298,19 +298,14 @@ |
1542 | return |
1543 | elif status == "success": |
1544 | result = self._session.xenapi.task.get_result(task) |
1545 | - LOG.info(_("Task [%s] %s status: success %s") % ( |
1546 | - name, |
1547 | - task, |
1548 | - result)) |
1549 | + LOG.info(_("Task [%(name)s] %(task)s status:" |
1550 | + " success %(result)s") % locals()) |
1551 | done.send(_parse_xmlrpc_value(result)) |
1552 | else: |
1553 | error_info = self._session.xenapi.task.get_error_info(task) |
1554 | action["error"] = str(error_info) |
1555 | - LOG.warn(_("Task [%s] %s status: %s %s") % ( |
1556 | - name, |
1557 | - task, |
1558 | - status, |
1559 | - error_info)) |
1560 | + LOG.warn(_("Task [%(name)s] %(task)s status:" |
1561 | + " %(status)s %(error_info)s") % locals()) |
1562 | done.send_exception(self.XenAPI.Failure(error_info)) |
1563 | db.instance_action_create(context.get_admin_context(), action) |
1564 | except self.XenAPI.Failure, exc: |
1565 | |
1566 | === modified file 'nova/volume/api.py' |
1567 | --- nova/volume/api.py 2011-01-07 14:46:17 +0000 |
1568 | +++ nova/volume/api.py 2011-01-24 15:23:08 +0000 |
1569 | @@ -41,10 +41,11 @@ |
1570 | |
1571 | def create(self, context, size, name, description): |
1572 | if quota.allowed_volumes(context, 1, size) < 1: |
1573 | - LOG.warn(_("Quota exceeeded for %s, tried to create %sG volume"), |
1574 | - context.project_id, size) |
1575 | + pid = context.project_id |
1576 | + LOG.warn(_("Quota exceeeded for %(pid)s, tried to create" |
1577 | + " %(size)sG volume") % locals()) |
1578 | raise quota.QuotaError(_("Volume quota exceeded. You cannot " |
1579 | - "create a volume of size %s") % size) |
1580 | + "create a volume of size %s") % size) |
1581 | |
1582 | options = { |
1583 | 'size': size, |
1584 | |
1585 | === modified file 'nova/volume/manager.py' |
1586 | --- nova/volume/manager.py 2011-01-19 02:50:21 +0000 |
1587 | +++ nova/volume/manager.py 2011-01-24 15:23:08 +0000 |
1588 | @@ -103,9 +103,10 @@ |
1589 | volume_ref['host'] = self.host |
1590 | |
1591 | try: |
1592 | - LOG.debug(_("volume %s: creating lv of size %sG"), |
1593 | - volume_ref['name'], |
1594 | - volume_ref['size']) |
1595 | + vol_name = volume_ref['name'] |
1596 | + vol_size = volume_ref['size'] |
1597 | + LOG.debug(_("volume %(vol_name)s: creating lv of" |
1598 | + " size %(vol_size)sG") % locals()) |
1599 | self.driver.create_volume(volume_ref) |
1600 | |
1601 | LOG.debug(_("volume %s: creating export"), volume_ref['name']) |
1602 | |
1603 | === modified file 'nova/wsgi.py' |
1604 | --- nova/wsgi.py 2011-01-20 17:52:02 +0000 |
1605 | +++ nova/wsgi.py 2011-01-24 15:23:08 +0000 |
1606 | @@ -64,7 +64,8 @@ |
1607 | |
1608 | def start(self, application, port, host='0.0.0.0', backlog=128): |
1609 | """Run a WSGI server with the given application.""" |
1610 | - logging.audit(_("Starting %s on %s:%s"), sys.argv[0], host, port) |
1611 | + arg0 = sys.argv[0] |
1612 | + logging.audit(_("Starting %(arg0)s on %(host)s:%(port)s") % locals()) |
1613 | socket = eventlet.listen((host, port), backlog=backlog) |
1614 | self.pool.spawn_n(self._run, application, socket) |
1615 |
lgtm