Shahar Havivi has uploaded a new change for review. Change subject: RFE: Report downtime for each live migration ......................................................................
RFE: Report downtime for each live migration Adding actual downtime is the time that the VM was offline (not available) for the user. Change-Id: Ic18c6db9a85167b1c4b85bdad22cf63f0204f378 Bug-Url: https://bugzilla.redhat.com/970711 Signed-off-by: Shahar Havivi <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusReturnForXmlRpc.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusVDSCommand.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java 7 files changed, 82 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/40100/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java index 8ca127b..4a40792 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MigrateVmCommand.java @@ -39,6 +39,7 @@ import org.ovirt.engine.core.common.vdscommands.MigrateStatusVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.MigrateVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.utils.NetworkUtils; @@ -50,6 +51,8 @@ /** Used to log the migration error. */ private VdcBllErrors migrationErrorCode; + + private Integer actualDowntime; public MigrateVmCommand(T parameters) { this(parameters, null); @@ -181,11 +184,26 @@ @Override public void runningSucceded() { try { + getDowntime(); getVmDynamicDao().clearMigratingToVds(getVmId()); updateVmAfterMigrationToDifferentCluster(); } finally { super.runningSucceded(); + } + } + + protected void getDowntime() { + if (getVm() != null && getVm().getStatus() == VMStatus.Up) { + try { + VDSReturnValue retVal = runVdsCommand(VDSCommandType.MigrateStatus, + new MigrateStatusVDSCommandParameters(getDestinationVdsId(), getVmId())); + if (retVal != null) { + actualDowntime = (Integer) retVal.getReturnValue(); + } + } catch (VdcBLLException e) { + migrationErrorCode = e.getErrorCode(); + } } } @@ -483,6 +501,11 @@ return DurationFormatUtils.formatDurationWords(new Date().getTime() - getParameters().getTotalMigrationTime().getTime(), true, true); } + // ActualDowntime: returns the actual time that the vm was offline (not available for access) + public String getActualDowntime() { + return (actualDowntime == null) ? "(N/A)" : actualDowntime + "ms"; + } + @Override protected String getLockMessage() { StringBuilder builder = new StringBuilder(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_BEING_MIGRATED.name()); diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties index f10ae81..f996088 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -256,7 +256,7 @@ USER_SUSPEND_VM_OK=VM ${VmName} on Host ${VdsName} is suspended. VM_FAILURE=VM ${VmName} cannot be found on Host ${VdsName}. VM_MIGRATION_ABORT=Migration failed: ${MigrationError} (VM: ${VmName}, Source: ${VdsName}, Destination: ${DestinationVdsName}). -VM_MIGRATION_DONE=Migration completed (VM: ${VmName}, Source: ${VdsName}, Destination: ${DestinationVdsName}, Duration: ${Duration}, Total: ${TotalDuration}). +VM_MIGRATION_DONE=Migration completed (VM: ${VmName}, Source: ${VdsName}, Destination: ${DestinationVdsName}, Duration: ${Duration}, Total: ${TotalDuration}, Actual downtime: ${ActualDowntime}) VM_MIGRATION_FAILED=Migration failed${DueToMigrationError} (VM: ${VmName}, Source: ${VdsName}, Destination: ${DestinationVdsName}). VM_MIGRATION_FAILED_NO_VDS_TO_RUN_ON=Migration failed, No available host found (VM: ${VmName}, Source: ${VdsName}). VM_MIGRATION_FAILED_DURING_MOVE_TO_MAINTENANCE=Migration failed${DueToMigrationError} while Host is in 'preparing for maintenance' state.\n Consider manual intervention\: stopping/migrating Vms as Host's state will not\n turn to maintenance while VMs are still running on it.(VM: ${VmName}, Source: ${VdsName}, Destination: ${DestinationVdsName}). diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java index ba8c8db..2fec483 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java @@ -44,6 +44,7 @@ import org.ovirt.engine.core.vdsbroker.vdsbroker.IVdsServer; import org.ovirt.engine.core.vdsbroker.vdsbroker.ImageSizeReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.vdsbroker.LUNListReturnForXmlRpc; +import org.ovirt.engine.core.vdsbroker.vdsbroker.MigrateStatusReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.vdsbroker.OneStorageDomainInfoReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.vdsbroker.OneStorageDomainStatsReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.vdsbroker.OneVGReturnForXmlRpc; @@ -281,10 +282,11 @@ } @Override - public StatusOnlyReturnForXmlRpc migrateStatus(String vmId) { + public MigrateStatusReturnForXmlRpc migrateStatus(String vmId) { JsonRpcRequest request = new RequestBuilder("VM.getMigrationStatus").withParameter("vmID", vmId).build(); - Map<String, Object> response = new FutureMap(this.client, request); - return new StatusOnlyReturnForXmlRpc(response); + Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("response") + .withResponseType(Long.class); + return new MigrateStatusReturnForXmlRpc(response); } @Override diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java index 50686cc..aa7d3e6 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java @@ -78,7 +78,7 @@ StatusOnlyReturnForXmlRpc migrate(Map<String, String> migrationInfo); - StatusOnlyReturnForXmlRpc migrateStatus(String vmId); + MigrateStatusReturnForXmlRpc migrateStatus(String vmId); StatusOnlyReturnForXmlRpc migrateCancel(String vmId); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusReturnForXmlRpc.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusReturnForXmlRpc.java new file mode 100644 index 0000000..4abd050 --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusReturnForXmlRpc.java @@ -0,0 +1,32 @@ +package org.ovirt.engine.core.vdsbroker.vdsbroker; + +import java.util.Map; + +public class MigrateStatusReturnForXmlRpc { + + private static final String STATUS = "status"; + private static final String RESPONSE = "response"; + private static final String DOWNTIME = "downtime"; + + private StatusForXmlRpc status; + public Integer downtime; + + @SuppressWarnings("unchecked") + public MigrateStatusReturnForXmlRpc(Map<String, Object> innerMap) { + status = new StatusForXmlRpc((Map<String, Object>) innerMap.get(STATUS)); + if (innerMap.containsKey(RESPONSE)) { + Map<String, Object> response = (Map<String, Object>)innerMap.get(RESPONSE); + if (response.containsKey(DOWNTIME)) { + downtime = (Integer)response.get(DOWNTIME); + } + } + } + + public StatusForXmlRpc getStatus() { + return status; + } + + public Integer getDowntime() { + return downtime; + } +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusVDSCommand.java index 8bf52c1..e59747e 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusVDSCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/MigrateStatusVDSCommand.java @@ -3,13 +3,30 @@ import org.ovirt.engine.core.common.vdscommands.MigrateStatusVDSCommandParameters; public class MigrateStatusVDSCommand<P extends MigrateStatusVDSCommandParameters> extends VdsBrokerCommand<P> { + private Long downtime = null; + private StatusForXmlRpc status; public MigrateStatusVDSCommand(P parameters) { super(parameters); } @Override protected void executeVdsBrokerCommand() { - status = getBroker().migrateStatus(getParameters().getVmId().toString()); + MigrateStatusReturnForXmlRpc retVal = getBroker().migrateStatus(getParameters().getVmId().toString()); + status = retVal.getStatus(); + setReturnValue(retVal.getDowntime()); proceedProxyReturnValue(); } + + @Override + protected StatusForXmlRpc getReturnStatus() { + return status; + } + + public Long getDowntime() { + return downtime; + } + + public void setDowntime(Long downtime) { + this.downtime = downtime; + } } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java index c85c5da..d7a3d54 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java @@ -263,11 +263,10 @@ } @Override - public StatusOnlyReturnForXmlRpc migrateStatus(String vmId) { + public MigrateStatusReturnForXmlRpc migrateStatus(String vmId) { try { Map<String, Object> xmlRpcReturnValue = vdsServer.migrateStatus(vmId); - StatusOnlyReturnForXmlRpc wrapper = new StatusOnlyReturnForXmlRpc(xmlRpcReturnValue); - return wrapper; + return new MigrateStatusReturnForXmlRpc(xmlRpcReturnValue); } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } -- To view, visit https://gerrit.ovirt.org/40100 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic18c6db9a85167b1c4b85bdad22cf63f0204f378 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shahar Havivi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
