Fix instance evacuate with shared storage
Fixes instance evacuation problem when --on-shared-storage flag specified. The problem occurs as the password variable ends up being accessed before it is assigned. Also adds missing test case. Fixes bug 1152492 Change-Id: I461c0f7fcf8835028f7529a7860fb330d1759d68
This commit is contained in:
parent
b099879222
commit
21b7149c5a
|
@ -53,6 +53,7 @@ class Controller(wsgi.Controller):
|
|||
on_shared_storage = utils.bool_from_str(
|
||||
evacuate_body["onSharedStorage"])
|
||||
|
||||
password = None
|
||||
if 'adminPass' in evacuate_body:
|
||||
# check that if requested to evacuate server on shared storage
|
||||
# password not specified
|
||||
|
|
|
@ -154,3 +154,29 @@ class EvacuateTest(test.TestCase):
|
|||
self.assertEqual(resp.status_int, 200)
|
||||
resp_json = jsonutils.loads(resp.body)
|
||||
self.assertEqual(CONF.password_length, len(resp_json['adminPass']))
|
||||
|
||||
def test_evacuate_shared(self):
|
||||
ctxt = context.get_admin_context()
|
||||
ctxt.user_id = 'fake'
|
||||
ctxt.project_id = 'fake'
|
||||
ctxt.is_admin = True
|
||||
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'
|
||||
|
||||
def fake_update(inst, context, instance,
|
||||
task_state, expected_task_state):
|
||||
return None
|
||||
|
||||
self.stubs.Set(compute_api.API, 'update', fake_update)
|
||||
|
||||
res = req.get_response(app)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
|
|
Loading…
Reference in New Issue