From ba387b5a5a7acaf8151c21bf82fe673b0f64f543 Mon Sep 17 00:00:00 2001 From: Daniel Vincze Date: Tue, 22 Oct 2024 20:44:08 +0300 Subject: [PATCH] Fix fulfilled migration exception Raises proper exception when user attempts to re-execute or re-deploy an already fulfilled migration action. --- coriolis/conductor/rpc/server.py | 10 +++------- coriolis/exception.py | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/coriolis/conductor/rpc/server.py b/coriolis/conductor/rpc/server.py index 548aee1b..d8decbe7 100644 --- a/coriolis/conductor/rpc/server.py +++ b/coriolis/conductor/rpc/server.py @@ -402,13 +402,9 @@ def _check_reservation_for_replica(self, replica): fulfilled_at = reservation.get("fulfilled_at", None) if scenario == constants.REPLICA_SCENARIO_LIVE_MIGRATION and ( fulfilled_at): - raise exception.LicensingException( - message=f"The Live Migration operation with ID " - f"'{replica.id}' (licensing reservation " - f"'{reservation_id}' has already been " - f"fulfilled on {fulfilled_at}. Please " - f"create a new Live Migration operation " - f"to create a new licensing reservation.") + raise exception.MigrationLicenceFulfilledException( + action_id=replica.id, reservation_id=reservation_id, + fulfilled_at=fulfilled_at) replica.reservation_id = ( self._licensing_client.check_refresh_reservation( diff --git a/coriolis/exception.py b/coriolis/exception.py index db311782..8e0a54d6 100644 --- a/coriolis/exception.py +++ b/coriolis/exception.py @@ -523,3 +523,11 @@ class OSMorphingWinRMOperationTimeout(OSMorphingOperationTimeout): " or the command execution time exceeds the timeout set. Try extending" " the timeout by editing the 'default_osmorphing_operation_timeout' " "in Coriolis' static configuration file.") + + +class MigrationLicenceFulfilledException(Invalid): + message = ( + "The Live Migration operation with ID '%(action_id)s' (licensing " + "reservation '%(reservation_id)s') has already been fulfilled on " + "%(fulfilled_at)s. Please create a new Live Migration operation to " + "create a new licensing reservation.")