From 8f21f19444300f62649d98447f5038dbbe5c0b7e Mon Sep 17 00:00:00 2001 From: Lizzie Salmon Date: Wed, 18 Dec 2024 15:25:10 +0000 Subject: [PATCH] Starting to add in checks for status --- lib/workflows/migrate_server.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/workflows/migrate_server.py b/lib/workflows/migrate_server.py index c3e355fd..f5ee7a26 100644 --- a/lib/workflows/migrate_server.py +++ b/lib/workflows/migrate_server.py @@ -1,5 +1,6 @@ from typing import Optional +import openstackquery from openstack.connection import Connection from openstack_api.openstack_server import migrate_server, snapshot_server @@ -21,6 +22,18 @@ def server_migration( :param live: True to use live migration :type live: bool """ - snapshot_server(conn, server_id) - migrate_server(conn, server_id=server_id, dest_host=destination_host, live=live) + # Determine the status of the server + query = getattr(openstackquery, "ServerQuery")() + query.select("server_status") + query.where( + preset="any_in", + prop="server_id", + values=[server_id], + ) + query.run( + "dev", all_projects=True, as_admin=True + ) # Do I need to add cloud account so that this will work on dev + print(query.to_props()) + # snapshot_server(conn, server_id) + # migrate_server(conn, server_id=server_id, dest_host=destination_host, live=live)