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