Merge "Removes unnecessary check for admin context in evacuate."
This commit is contained in:
commit
33b966771b
@ -39,9 +39,6 @@ class Controller(wsgi.Controller):
|
|||||||
to a new one.
|
to a new one.
|
||||||
"""
|
"""
|
||||||
context = req.environ["nova.context"]
|
context = req.environ["nova.context"]
|
||||||
if not context.is_admin:
|
|
||||||
msg = _("Instance evacuate is admin only functionality")
|
|
||||||
raise exc.HTTPForbidden(explanation=msg)
|
|
||||||
authorize(context)
|
authorize(context)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -180,3 +180,19 @@ class EvacuateTest(test.TestCase):
|
|||||||
|
|
||||||
res = req.get_response(app)
|
res = req.get_response(app)
|
||||||
self.assertEqual(res.status_int, 200)
|
self.assertEqual(res.status_int, 200)
|
||||||
|
|
||||||
|
def test_not_admin(self):
|
||||||
|
ctxt = context.RequestContext('fake', 'fake', is_admin=False)
|
||||||
|
app = fakes.wsgi_app(fake_auth_context=ctxt)
|
||||||
|
uuid = self.UUID
|
||||||
|
req = webob.Request.blank('/v2/fake/servers/%s/action' % uuid)
|
||||||
|
req.method = 'POST'
|
||||||
|
req.body = jsonutils.dumps({
|
||||||
|
'evacuate': {
|
||||||
|
'host': 'my_host',
|
||||||
|
'onSharedStorage': 'True',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
req.content_type = 'application/json'
|
||||||
|
res = req.get_response(app)
|
||||||
|
self.assertEqual(res.status_int, 403)
|
||||||
|
@ -119,7 +119,7 @@ policy_data = """
|
|||||||
"compute_extension:createserverext": "",
|
"compute_extension:createserverext": "",
|
||||||
"compute_extension:deferred_delete": "",
|
"compute_extension:deferred_delete": "",
|
||||||
"compute_extension:disk_config": "",
|
"compute_extension:disk_config": "",
|
||||||
"compute_extension:evacuate": "",
|
"compute_extension:evacuate": "is_admin:True",
|
||||||
"compute_extension:extended_server_attributes": "",
|
"compute_extension:extended_server_attributes": "",
|
||||||
"compute_extension:extended_status": "",
|
"compute_extension:extended_status": "",
|
||||||
"compute_extension:extended_availability_zone": "",
|
"compute_extension:extended_availability_zone": "",
|
||||||
|
Loading…
Reference in New Issue
Block a user