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);
}
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);
}
}
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();
}
}
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());
}
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());
}
}
Aggregations