Search in sources :

Example 1 with VmLeaseVDSParameters

use of org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters in project ovirt-engine by oVirt.

the class AddVmLeaseCommand method endSuccessfully.

@Override
protected void endSuccessfully() {
    // it would be nicer to get this as part of the tasks rather
    // than initiating another call to the host, this approach is
    // easier and backward compatible though
    VDSReturnValue retVal = null;
    try {
        retVal = runVdsCommand(VDSCommandType.GetVmLeaseInfo, new VmLeaseVDSParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getVmId()));
    } catch (EngineException e) {
        log.error("Failure in getting lease info for VM {}, message: {}", getParameters().getVmId(), e.getMessage());
    }
    if (retVal == null || !retVal.getSucceeded()) {
        log.error("Failed to get info on the lease of VM {}", getParameters().getVmId());
        return;
    }
    vmDynamicDao.updateVmLeaseInfo(getParameters().getVmId(), (Map<String, String>) retVal.getReturnValue());
    if (getParameters().isHotPlugLease()) {
        boolean hotPlugSucceeded = false;
        try {
            hotPlugSucceeded = runVdsCommand(VDSCommandType.HotPlugLease, new LeaseVDSParameters(getParameters().getVdsId(), getParameters().getVmId(), getParameters().getStorageDomainId())).getSucceeded();
        } catch (EngineException e) {
            log.error("Failure in hot plugging a lease to VM {}, message: {}", getParameters().getVmId(), e.getMessage());
        }
        if (!hotPlugSucceeded) {
            setVmId(getParameters().getVmId());
            auditLog(this, AuditLogType.HOT_PLUG_LEASE_FAILED);
            getReturnValue().setEndActionTryAgain(false);
            setSucceeded(false);
            return;
        }
    }
    setSucceeded(true);
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) LeaseVDSParameters(org.ovirt.engine.core.common.vdscommands.LeaseVDSParameters) VmLeaseVDSParameters(org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters) VmLeaseVDSParameters(org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 2 with VmLeaseVDSParameters

use of org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters in project ovirt-engine by oVirt.

the class VmLeaseCommandBase method executeCommand.

@Override
protected void executeCommand() {
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    VmLeaseVDSParameters params = new VmLeaseVDSParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), getParameters().getVmId());
    VDSReturnValue returnValue = runVdsCommand(getLeaseAction(), params);
    if (returnValue.getSucceeded()) {
        getTaskIdList().add(createTask(taskId, returnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
    }
    setSucceeded(returnValue.getSucceeded());
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) VmLeaseVDSParameters(org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with VmLeaseVDSParameters

use of org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters in project ovirt-engine by oVirt.

the class RestoreAllSnapshotsCommand method updateLeaseInfo.

private boolean updateLeaseInfo(Guid snapshotLeaseDomainId) {
    if (snapshotLeaseDomainId == null) {
        // there was no lease for the snapshot
        vmDynamicDao.updateVmLeaseInfo(getParameters().getVmId(), null);
        return true;
    }
    VDSReturnValue retVal = null;
    try {
        retVal = runVdsCommand(VDSCommandType.GetVmLeaseInfo, new VmLeaseVDSParameters(getStoragePoolId(), snapshotLeaseDomainId, getParameters().getVmId()));
    } catch (EngineException e) {
        log.error("Failure in getting lease info for VM {}, message: {}", getParameters().getVmId(), e.getMessage());
    }
    if (retVal == null || !retVal.getSucceeded()) {
        log.error("Failed to get info on the lease of VM {}", getParameters().getVmId());
        return false;
    }
    vmDynamicDao.updateVmLeaseInfo(getParameters().getVmId(), (Map<String, String>) retVal.getReturnValue());
    return true;
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) VmLeaseVDSParameters(org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 VmLeaseVDSParameters (org.ovirt.engine.core.common.vdscommands.VmLeaseVDSParameters)3 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 LeaseVDSParameters (org.ovirt.engine.core.common.vdscommands.LeaseVDSParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1