Search in sources :

Example 26 with VDSReturnValue

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

the class RunVmCommandTest method oneConnectFailed.

@Test
public void oneConnectFailed() {
    command.setVm(new VM());
    // create 2 lun disks
    LunDisk lunDisk1 = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    lunDisk1.setLun(lun1);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
    List<StorageServerConnections> connections = new ArrayList<>();
    // luns have the same backing targets
    connections.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(new VDSReturnValue()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for same targets, connect only once
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertFalse(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Example 27 with VDSReturnValue

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

the class SPMRevertTaskVDSCommand method executeIrsBrokerCommand.

@Override
protected void executeIrsBrokerCommand() {
    VDSReturnValue returnValue = resourceManager.runVdsCommand(VDSCommandType.HSMRevertTask, new HSMTaskGuidBaseVDSCommandParameters(getCurrentIrsProxy().getCurrentVdsId(), getParameters().getTaskId()));
    if (returnValue != null && !returnValue.getSucceeded()) {
        getVDSReturnValue().setVdsError(returnValue.getVdsError());
        getVDSReturnValue().setSucceeded(false);
    }
}
Also used : VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) HSMTaskGuidBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMTaskGuidBaseVDSCommandParameters)

Example 28 with VDSReturnValue

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

the class VmAnalyzerTest method initMocks.

public void initMocks(VmTestPairs vmData, boolean run) {
    stubDaos();
    when(vdsManager.getVdsId()).thenReturn(VmTestPairs.SRC_HOST_ID);
    when(vdsManager.getClusterId()).thenReturn(VmTestPairs.CLUSTER_ID);
    when(vdsManager.getCopyVds()).thenReturn(vdsManagerVds);
    when(vmManager.isColdReboot()).thenReturn(false);
    when(vmManager.isAutoStart()).thenReturn(vmData.dbVm() != null ? vmData.dbVm().isAutoStartup() : false);
    when(vmManager.getStatistics()).thenReturn(new VmStatistics());
    when(resourceManager.getVdsManager(any())).thenReturn(vdsManager);
    // -- default behaviors --
    // dst host is up
    mockDstHostStatus(VDSStatus.Up);
    // -- end of behaviors --
    vmAnalyzer = spy(new VmAnalyzer(vmData.dbVm() != null ? vmData.dbVm().getDynamicData() : null, vmData.vdsmVm(), false, vdsManager, auditLogDirector, resourceManager, vdsDynamicDao, null));
    doNothing().when(vmAnalyzer).resetVmInterfaceStatistics();
    doReturn(vmManager).when(vmAnalyzer).getVmManager();
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setSucceeded(true);
    doReturn(vdsReturnValue).when(vmAnalyzer).runVdsCommand(any(), any());
    if (run) {
        vmAnalyzer.analyze();
    }
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 29 with VDSReturnValue

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

the class CreateVDSCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    VM vm = getParameters().getVm();
    getVDSReturnValue().setReturnValue(vm.getStatus());
    if (!resourceManager.addAsyncRunningVm(vm.getId())) {
        log.info("Vm Running failed - vm '{}'({}) already running", vm.getName(), vm.getId());
        return;
    }
    Date now = new Date();
    VDSReturnValue vdsReturnValue = null;
    try {
        vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.CreateBroker, getParameters());
        if (!vdsReturnValue.getSucceeded()) {
            handleCommandResult(vdsReturnValue);
            resourceManager.removeAsyncRunningVm(getParameters().getVmId());
            return;
        }
        if (!getParameters().isRunInUnknownStatus()) {
            if (!vm.isInitialized()) {
                vmDao.saveIsInitialized(vm.getId(), true);
            }
            boolean vmIsBooting = StringUtils.isEmpty(getParameters().getHibernationVolHandle()) && getParameters().getMemoryConfImage() == null;
            if (vmIsBooting) {
                vm.setBootTime(now);
                vm.setDowntime(0);
            } else {
                vm.setDowntime(vm.getDowntime() + now.getTime() - getParameters().getDownSince().getTime());
            }
            vm.setLastStartTime(now);
            vm.setStopReason(null);
            vm.setInitialized(true);
            vm.setRunOnVds(getParameters().getVdsId());
            vmManager.update(vm.getDynamicData());
        }
    } catch (Exception e) {
        log.error("Failed to create VM", e);
        // log.debug("Exception", e);
        if (vdsReturnValue != null && !vdsReturnValue.getSucceeded()) {
            resourceManager.removeAsyncRunningVm(getParameters().getVmId());
        }
        throw new RuntimeException(e);
    }
    getVDSReturnValue().setReturnValue(vm.getStatus());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Date(java.util.Date) VDSGenericException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSGenericException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 30 with VDSReturnValue

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

the class DestroyVmVDSCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.Destroy, getParameters());
    if (vdsReturnValue.getSucceeded()) {
        VmDynamic vm = vmDynamicDao.get(getParameters().getVmId());
        changeStatus(vm);
        vm.setStopReason(getParameters().getReason());
        vmManager.update(vm);
        getVDSReturnValue().setReturnValue(vm.getStatus());
    } else if (vdsReturnValue.getExceptionObject() != null) {
        logFailureToDestroy(vdsReturnValue);
        getVDSReturnValue().setSucceeded(false);
        getVDSReturnValue().setExceptionString(vdsReturnValue.getExceptionString());
        getVDSReturnValue().setExceptionObject(vdsReturnValue.getExceptionObject());
        getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
    }
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) 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