Fix nova handle_rebuild return error
Change-Id: Ib45772dc0ba99a66f9eaf8458a2b8ba5b9d4784c Closes-Bug: 1731120
This commit is contained in:
parent
0fbd7a427d
commit
4a8e090ecc
|
@ -1475,8 +1475,15 @@ class ServerProfile(base.Profile):
|
|||
return True
|
||||
|
||||
def handle_rebuild(self, obj, **options):
|
||||
"""Handler for the rebuild operation.
|
||||
|
||||
:param obj: The node object.
|
||||
:param dict options: A list for operations each of which has a name
|
||||
and optionally a map from parameter to values.
|
||||
:returns: The server ID if successful or None if failed.
|
||||
"""
|
||||
if not obj.physical_id:
|
||||
return False
|
||||
return None
|
||||
|
||||
server_id = obj.physical_id
|
||||
driver = self.compute(obj)
|
||||
|
@ -1488,7 +1495,7 @@ class ServerProfile(base.Profile):
|
|||
message=six.text_type(ex))
|
||||
|
||||
if server is None or server.image is None:
|
||||
return False
|
||||
return None
|
||||
|
||||
image_id = server.image['id']
|
||||
admin_pass = self.properties.get(self.ADMIN_PASS)
|
||||
|
@ -1497,11 +1504,12 @@ class ServerProfile(base.Profile):
|
|||
driver.server_rebuild(server_id, image_id,
|
||||
name, admin_pass)
|
||||
driver.wait_for_server(server_id, 'ACTIVE')
|
||||
return server_id
|
||||
except exc.InternalError as ex:
|
||||
raise exc.EResourceOperation(op='rebuilding', type='server',
|
||||
id=server_id,
|
||||
message=six.text_type(ex))
|
||||
return True
|
||||
return None
|
||||
|
||||
def handle_change_password(self, obj, **options):
|
||||
"""Handler for the change_password operation."""
|
||||
|
|
|
@ -1215,7 +1215,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
|
|||
|
||||
res = profile.handle_rebuild(node_obj)
|
||||
|
||||
self.assertTrue(res)
|
||||
self.assertEqual('FAKE_ID', res)
|
||||
cc.server_get.assert_called_with('FAKE_ID')
|
||||
cc.server_rebuild.assert_called_once_with('FAKE_ID', '123',
|
||||
'FAKE_SERVER_NAME',
|
||||
|
|
Loading…
Reference in New Issue