Search in sources :

Example 96 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class GlusterStorageSyncCommand method removeDRSnapshots.

private void removeDRSnapshots() {
    for (Map.Entry<Guid, Guid> entry : getParameters().getVmIdSnapshotIds().entrySet()) {
        RemoveSnapshotParameters removeSnapshotParameters = new RemoveSnapshotParameters(entry.getValue(), entry.getKey());
        removeSnapshotParameters.setParentCommand(getActionType());
        removeSnapshotParameters.setEndProcedure(EndProcedure.COMMAND_MANAGED);
        removeSnapshotParameters.setParentParameters(getParameters());
        removeSnapshotParameters.setNeedsLocking(false);
        commandCoordinatorUtil.executeAsyncCommand(ActionType.RemoveSnapshot, removeSnapshotParameters, cloneContextAndDetachFromParent());
    }
}
Also used : RemoveSnapshotParameters(org.ovirt.engine.core.common.action.RemoveSnapshotParameters) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) Map(java.util.Map)

Example 97 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class GlusterStorageSyncCommand method executeCommand.

@Override
protected void executeCommand() {
    // Get list of running VMs that have disks on storage domain
    List<VM> vms = runInternalQuery(QueryType.GetVmsByStorageDomain, new IdQueryParameters(getStorageDomain().getId())).getReturnValue();
    // Snapshot the VMs
    Map<Guid, Guid> vmIdSnapshotIdMap = new HashMap<>();
    for (VM vm : vms) {
        try {
            Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateSnapshotForVm, getCreateSnapshotParameters(vm), cloneContextAndDetachFromParent());
            vmIdSnapshotIdMap.put(vm.getId(), future.get().getActionReturnValue());
        } catch (InterruptedException | ExecutionException e) {
            log.error("Error creating VM snapshot for VM with id '{}', name '{}' for DR sync", vm.getId(), vm.getName(), e.getMessage());
            log.debug("Exception", e);
            endWithFailure();
            getParameters().setTaskGroupSuccess(false);
        }
    }
    getParameters().setVmIdSnapshotIds(vmIdSnapshotIdMap);
    getParameters().setNextStep(DRStep.GEO_REP);
    persistCommandIfNeeded();
    setSucceeded(true);
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) ExecutionException(java.util.concurrent.ExecutionException)

Example 98 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class GetEntitiesWithLeaseByStorageIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    Guid domainId = getParameters().getId();
    List<VmBase> entities = new ArrayList<>();
    entities.addAll(vmStaticDao.getAllWithLeaseOnStorageDomain(domainId));
    entities.addAll(vmTemplateDao.getAllWithLeaseOnStorageDomain(domainId));
    getQueryReturnValue().setReturnValue(entities);
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 99 with Guid

use of org.ovirt.engine.core.compat.Guid 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 100 with Guid

use of org.ovirt.engine.core.compat.Guid in project ovirt-engine by oVirt.

the class UpdateOvfStoreForStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid storageDomainId = getStorageDomainId();
    ProcessOvfUpdateParameters parameters = new ProcessOvfUpdateParameters(getStoragePoolId(), getStorageDomainId());
    ActionReturnValue actionReturnValue = runInternalAction(ActionType.ProcessOvfUpdateForStoragePool, parameters, getContext());
    Set<Guid> proccessedDomains = actionReturnValue.getActionReturnValue();
    if (!actionReturnValue.getSucceeded()) {
        propagateFailure(actionReturnValue);
        return;
    }
    if (proccessedDomains != null && proccessedDomains.contains(storageDomainId)) {
        actionReturnValue = runInternalActionWithTasksContext(ActionType.ProcessOvfUpdateForStorageDomain, createProcessOvfUpdateForDomainParams());
        if (!actionReturnValue.getSucceeded()) {
            propagateFailure(actionReturnValue);
            return;
        }
    } else {
        addCustomValue("StorageDomainName", getStorageDomain().getName());
        auditLogDirector.log(this, AuditLogType.OVF_STORES_UPDATE_IGNORED);
    }
    setSucceeded(true);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Guid(org.ovirt.engine.core.compat.Guid) ProcessOvfUpdateParameters(org.ovirt.engine.core.common.action.ProcessOvfUpdateParameters)

Aggregations

Guid (org.ovirt.engine.core.compat.Guid)1431 ArrayList (java.util.ArrayList)330 Test (org.junit.Test)322 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)219 HashMap (java.util.HashMap)211 List (java.util.List)167 VM (org.ovirt.engine.core.common.businessentities.VM)144 Map (java.util.Map)118 VDS (org.ovirt.engine.core.common.businessentities.VDS)117 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)106 HashSet (java.util.HashSet)102 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)89 Pair (org.ovirt.engine.core.common.utils.Pair)79 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)77 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)72 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)70 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)69 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)57 ActionType (org.ovirt.engine.core.common.action.ActionType)56 Set (java.util.Set)52