Search in sources :

Example 86 with VDSReturnValue

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

the class FenceAgentExecutorTest method createVdsReturnValue.

private VDSReturnValue createVdsReturnValue(FenceOperationResult result) {
    VDSReturnValue retVal = new VDSReturnValue();
    retVal.setSucceeded(result.getStatus() != Status.ERROR);
    retVal.setReturnValue(result);
    return retVal;
}
Also used : VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 87 with VDSReturnValue

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

the class FenceAgentExecutorTest method mockFenceVdsResult.

private void mockFenceVdsResult(FenceOperationResult result1, FenceOperationResult result2) {
    VDSReturnValue retVal1 = createVdsReturnValue(result1);
    VDSReturnValue retVal2 = result2 == null ? null : createVdsReturnValue(result2);
    when(resourceManager.runVdsCommand(eq(VDSCommandType.FenceVds), any())).thenReturn(retVal1).thenReturn(retVal2);
}
Also used : VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 88 with VDSReturnValue

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

the class ExportVmCommand method updateCopyVmInSpm.

private void updateCopyVmInSpm(Guid storagePoolId, VM vm, Guid storageDomainId) {
    HashMap<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndMetaDictionary = new HashMap<>();
    List<DiskImage> vmImages = new ArrayList<>();
    List<LunDisk> lunDisks = new ArrayList<>();
    List<VmNetworkInterface> interfaces = vm.getInterfaces();
    if (interfaces != null) {
        // TODO remove this when the API changes
        interfaces.clear();
        interfaces.addAll(vmNetworkInterfaceDao.getAllForVm(vm.getId()));
    }
    List<Guid> imageGroupIds = new ArrayList<>();
    for (Disk disk : getDisksBasedOnImage()) {
        DiskImage diskImage = (DiskImage) disk;
        diskImage.setParentId(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
        diskImage.setImageTemplateId(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
        diskImage.setStorageIds(new ArrayList<>(Collections.singletonList(storageDomainId)));
        DiskImage diskForVolumeInfo = getDiskForVolumeInfo(diskImage);
        diskImage.setVolumeFormat(diskForVolumeInfo.getVolumeFormat());
        diskImage.setVolumeType(diskForVolumeInfo.getVolumeType());
        VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(storagePoolId, storageDomainId, diskImage.getId(), diskImage.getImageId()));
        if (vdsReturnValue != null && vdsReturnValue.getSucceeded()) {
            DiskImage fromVdsm = (DiskImage) vdsReturnValue.getReturnValue();
            diskImage.setActualSizeInBytes(fromVdsm.getActualSizeInBytes());
        }
        vmImages.add(diskImage);
        imageGroupIds.add(disk.getId());
    }
    if (StringUtils.isEmpty(vm.getVmtName())) {
        VmTemplate t = vmTemplateDao.get(vm.getVmtGuid());
        vm.setVmtName(t.getName());
    }
    lunDisks.addAll(DisksFilter.filterLunDisks(getVm().getDiskMap().values(), ONLY_NOT_SHAREABLE));
    lunDisks.forEach(lun -> lun.getLun().setLunConnections(new ArrayList<>(storageServerConnectionDao.getAllForLun(lun.getLun().getId()))));
    getVm().setVmtGuid(VmTemplateHandler.BLANK_VM_TEMPLATE_ID);
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
    fullEntityOvfData.setClusterName(vm.getClusterName());
    fullEntityOvfData.setDiskImages(vmImages);
    fullEntityOvfData.setLunDisks(lunDisks);
    String vmMeta = ovfManager.exportVm(vm, fullEntityOvfData, clusterUtils.getCompatibilityVersion(vm));
    vmsAndMetaDictionary.put(vm.getId(), new KeyValuePairCompat<>(vmMeta, imageGroupIds));
    UpdateVMVDSCommandParameters tempVar = new UpdateVMVDSCommandParameters(storagePoolId, vmsAndMetaDictionary);
    tempVar.setStorageDomainId(storageDomainId);
    runVdsCommand(VDSCommandType.UpdateVM, tempVar);
}
Also used : GetImageInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters) KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UpdateVMVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UpdateVMVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 89 with VDSReturnValue

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

the class ConvertVmCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    try {
        VDSReturnValue retValue = runVdsCommand();
        if (retValue.getSucceeded()) {
            monitorV2VJob(JobStatus.WAIT_FOR_START);
            setSucceeded(true);
        } else {
            log.error("Failed to convert VM");
            setCommandStatus(CommandStatus.FAILED);
        }
    } catch (EngineException e) {
        log.error("Failed to convert VM", e);
        setCommandStatus(CommandStatus.FAILED);
    }
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 90 with VDSReturnValue

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

the class HostSetupNetworksCommand method invokeSetupNetworksCommand.

private FutureVDSCall<VDSReturnValue> invokeSetupNetworksCommand(int timeout) {
    final HostSetupNetworksVdsCommandParameters parameters = createSetupNetworksParameters(timeout);
    FutureVDSCall<VDSReturnValue> setupNetworksTask = getVdsBroker().runFutureVdsCommand(FutureVDSCommandType.HostSetupNetworks, parameters);
    if (parameters.isRollbackOnFailure()) {
        PollTechnique pollTechnique = FeatureSupported.isConfirmConnectivitySupportedByVdsm(getVds().getClusterCompatibilityVersion()) ? CONFIRM_CONNECTIVITY : POLL;
        HostPoller poller = new HostPoller(new TimeBoundPollVDSCommandParameters(getVdsId(), pollTechnique));
        while (!setupNetworksTask.isDone()) {
            poller.poll();
        }
    }
    return setupNetworksTask;
}
Also used : HostSetupNetworksVdsCommandParameters(org.ovirt.engine.core.common.vdscommands.HostSetupNetworksVdsCommandParameters) PollTechnique(org.ovirt.engine.core.common.vdscommands.TimeBoundPollVDSCommandParameters.PollTechnique) TimeBoundPollVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.TimeBoundPollVDSCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)250 Guid (org.ovirt.engine.core.compat.Guid)65 ArrayList (java.util.ArrayList)43 VDS (org.ovirt.engine.core.common.businessentities.VDS)29 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 Pair (org.ovirt.engine.core.common.utils.Pair)26 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)23 List (java.util.List)16 Test (org.junit.Test)15 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)15 VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)15 HashMap (java.util.HashMap)13 VDSError (org.ovirt.engine.core.common.errors.VDSError)13 Map (java.util.Map)11 Callable (java.util.concurrent.Callable)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)11 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)8