问题
- 环境P版在虚拟机创建快照的时候,上传镜像的时候出现如下错误信息:
1
ImageNotAuthorized: Not authorized for image 4fb7c773-0ab3-4123-a6cc-2a9e38373793
解决办法
本人在之前对glance设置了一个配置show_image_direct_url,用来支持虚拟机从镜像秒启动,跟踪了错误日志
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
792018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server Traceback (most recent call last):
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 160, in _process_incoming
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 213, in dispatch
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 183, in _do_dispatch
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server result = func(ctxt, **new_args)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/exception_wrapper.py", line 76, in wrapped
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server function_name, call_dict, binary)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server self.force_reraise()
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/exception_wrapper.py", line 67, in wrapped
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return f(self, context, *args, **kw)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 191, in decorated_function
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server "Error: %s", e, instance=instance)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server self.force_reraise()
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 161, in decorated_function
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return function(self, context, *args, **kwargs)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 219, in decorated_function
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server kwargs['instance'], e, sys.exc_info())
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server self.force_reraise()
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 207, in decorated_function
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return function(self, context, *args, **kwargs)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 248, in decorated_function
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server image_id, instance=instance)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server self.force_reraise()
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 235, in decorated_function
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server *args, **kwargs)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 3221, in snapshot_instance
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server task_states.IMAGE_SNAPSHOT)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 3253, in _snapshot_instance
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server update_task_state)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1827, in snapshot
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server ignore_errors=True)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server self.force_reraise()
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1768, in snapshot
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server purge_props=False)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/api.py", line 132, in update
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server purge_props=purge_props)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 503, in update
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server _reraise_translated_image_exception(image_id)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 820, in _reraise_translated_image_exception
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server six.reraise(type(new_exc), new_exc, exc_trace)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 501, in update
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server image = self._update_v2(context, sent_service_image_meta, data)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 515, in _update_v2
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server image = self._add_location(context, image_id, location)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 400, in _add_location
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server location, {})
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 166, in call
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server result = getattr(controller, method)(*args, **kwargs)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 368, in add_location
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server response = self._send_image_update_request(image_id, add_patch)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 545, in inner
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return RequestIdProxy(wrapped(*args, **kwargs))
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 352, in _send_image_update_request
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server data=json.dumps(patch_body))
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 300, in patch
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return self.request(url, 'PATCH', **kwargs)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 349, in request
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server return self._handle_response(resp)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 98, in _handle_response
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server raise exc.from_response(resp, resp.content)
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server ImageNotAuthorized: Not authorized for image 4fb7c773-0ab3-4123-a6cc-2a9e38373793.
2018-09-28 16:58:31.419 1040857 ERROR oslo_messaging.rpc.server在代码里面看到这段注释
1
2
3
4
5
6
7
8/usr/lib/python2.7/site-packages/nova/image/glance.py
def _add_location(self, context, image_id, location):
# 'show_multiple_locations' must be enabled in glance api conf file.
try:
return self._client.call(context, 2, 'add_location', image_id,
location, {})
except glanceclient.exc.HTTPBadRequest:
_reraise_translated_exception()
需要打开show_multiple_locations配置,打开之后就OK了