Source:
protected void executeCommand() { VDSGroup sourceCluster = getVdsGroup(); final Guid targetClusterId = getParameters().getClusterId(); if (sourceCluster.getId().equals(targetClusterId)) { setSucceeded(true); return; } TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { VdsStatic staticData = getVds().getStaticData(); getCompensationContext().snapshotEntity(staticData); staticData.setvds_group_id(targetClusterId); DbFacade.getInstance().getVdsStaticDAO().update(staticData); getCompensationContext().stateChanged(); return null; } }); if (sourceCluster.supportsGlusterService()) { glusterHostRemove(sourceCluster.getId()); if (!getSucceeded()) { return; } } if (getVdsGroup(getParameters().getClusterId()).supportsGlusterService()) { glusterHostAdd(getParameters().getClusterId()); if (!getSucceeded()) { return; } } getParameters().setCompensationEnabled(true); getParameters().setTransactionScopeOption(TransactionScopeOption.RequiresNew); if (sourceCluster.getstorage_pool_id() != null) { VdcReturnValueBase removeVdsSpmIdReturn = Backend.getInstance().runInternalAction(VdcActionType.RemoveVdsSpmId, getParameters(), new CommandContext(getCompensationContext())); if (!removeVdsSpmIdReturn.getSucceeded()) { setSucceeded(false); getReturnValue().setFault(removeVdsSpmIdReturn.getFault()); return; } } if (targetStoragePool != null) { VdcReturnValueBase addVdsSpmIdReturn = Backend.getInstance().runInternalAction(VdcActionType.AddVdsSpmId, getParameters(), new CommandContext(getCompensationContext())); if (!addVdsSpmIdReturn.getSucceeded()) { setSucceeded(false); getReturnValue().setFault(addVdsSpmIdReturn.getFault()); return; } } setSucceeded(true); }

Target:
protected void executeCommand() { VDSGroup sourceCluster = getVdsGroup(); final Guid targetClusterId = getParameters().getClusterId(); if (sourceCluster.getId().equals(targetClusterId)) { setSucceeded(true); return; } TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { VdsStatic staticData = getVds().getStaticData(); getCompensationContext().snapshotEntity(staticData); staticData.setvds_group_id(targetClusterId); DbFacade.getInstance().getVdsStaticDAO().update(staticData); getCompensationContext().stateChanged(); return null; } }); if (sourceCluster.supportsGlusterService() && getClusterUtils().hasServers(getSourceClusterId())) { glusterHostRemove(getSourceClusterId()); if (!getSucceeded()) { return; } } if (getVdsGroup(getTargetClusterId()).supportsGlusterService() && getClusterUtils().hasMultipleServers(getTargetClusterId())) { glusterHostAdd(getTargetClusterId()); if (!getSucceeded()) { return; } } getParameters().setCompensationEnabled(true); getParameters().setTransactionScopeOption(TransactionScopeOption.RequiresNew); if (sourceCluster.getstorage_pool_id() != null) { VdcReturnValueBase removeVdsSpmIdReturn = Backend.getInstance().runInternalAction(VdcActionType.RemoveVdsSpmId, getParameters(), new CommandContext(getCompensationContext())); if (!removeVdsSpmIdReturn.getSucceeded()) { setSucceeded(false); getReturnValue().setFault(removeVdsSpmIdReturn.getFault()); return; } } if (targetStoragePool != null) { VdcReturnValueBase addVdsSpmIdReturn = Backend.getInstance().runInternalAction(VdcActionType.AddVdsSpmId, getParameters(), new CommandContext(getCompensationContext())); if (!addVdsSpmIdReturn.getSucceeded()) { setSucceeded(false); getReturnValue().setFault(addVdsSpmIdReturn.getFault()); return; } } setSucceeded(true); }