@@ -27,24 +27,27 @@ def verify_project_id(context, project_id):
27
27
"""verify that a project_id exists.
28
28
29
29
This attempts to verify that a project id exists. If it does not,
30
- an HTTPBadRequest is emitted.
30
+ an HTTPBadRequest is emitted. Also HTTPBadRequest is emitted
31
+ if Keystone identity service version 3.0 is not found.
31
32
32
33
"""
33
34
adap = utils .get_ksa_adapter (
34
35
'identity' , ksa_auth = context .get_auth_plugin (),
35
36
min_version = (3 , 0 ), max_version = (3 , 'latest' ))
36
37
37
- failure = webob .exc .HTTPBadRequest (
38
- explanation = _ ("Project ID %s is not a valid project." ) %
39
- project_id )
40
38
try :
41
39
resp = adap .get ('/projects/%s' % project_id )
42
40
except kse .EndpointNotFound :
43
41
LOG .error (
44
- "Keystone identity service version 3.0 was not found. This might "
45
- "be because your endpoint points to the v2.0 versioned endpoint "
46
- "which is not supported. Please fix this." )
47
- raise failure
42
+ "Keystone identity service version 3.0 was not found. This "
43
+ "might be caused by Nova misconfiguration or Keystone "
44
+ "problems." )
45
+ msg = _ ("Nova was unable to find Keystone service endpoint." )
46
+ # TODO(astupnik). It may be reasonable to switch to HTTP 503
47
+ # (HTTP Service Unavailable) instead of HTTP Bad Request here.
48
+ # If proper Keystone servie is inaccessible, then technially
49
+ # this is a server side error and not an error in Nova.
50
+ raise webob .exc .HTTPBadRequest (explanation = msg )
48
51
except kse .ClientException :
49
52
# something is wrong, like there isn't a keystone v3 endpoint,
50
53
# or nova isn't configured for the interface to talk to it;
@@ -57,7 +60,8 @@ def verify_project_id(context, project_id):
57
60
return True
58
61
elif resp .status_code == 404 :
59
62
# we got access, and we know this project is not there
60
- raise failure
63
+ msg = _ ("Project ID %s is not a valid project." ) % project_id
64
+ raise webob .exc .HTTPBadRequest (explanation = msg )
61
65
elif resp .status_code == 403 :
62
66
# we don't have enough permission to verify this, so default
63
67
# to "it's ok".
0 commit comments