Bug fixed in migration code

This commit is contained in:
ahmadbilalkhalid 2019-12-30 21:14:08 +05:00
parent d13a4bcc37
commit 4b7d6d5099
1 changed files with 11 additions and 14 deletions

View File

@ -57,6 +57,7 @@ class TransferVM(Process):
os.remove(self.src_sock_path)
command = [
"sudo"
"ssh",
"-nNT",
"-L",
@ -73,9 +74,7 @@ class TransferVM(Process):
else:
time.sleep(2)
vmm = VMM()
logger.debug(
"Executing: ssh forwarding command: %s", command
)
logger.debug("Executing: ssh forwarding command: %s", command)
vmm.execute_command(
self.src_uuid,
command="migrate",
@ -83,22 +82,20 @@ class TransferVM(Process):
)
while p.poll() is None:
success, output = vmm.execute_command(
self.src_uuid, command="query-migrate"
)
success, output = vmm.execute_command(self.src_uuid, command="query-migrate")
if success:
status = output["return"]["status"]
if status != "active":
print("Migration Status: ", status)
if status == "completed":
vmm.stop(self.src_uuid)
logger.info('Migration Status: {}'.format(status))
if status == "completed":
vmm.stop(self.src_uuid)
return
elif status in ['failed', 'cancelled']:
return
else:
print("Migration Status: ", status)
else:
logger.error("Couldn't be able to query VM {} that was in migration".format(self.src_uuid))
return
time.sleep(0.2)
time.sleep(2)
class VMM: