use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class ImportVmCommand method validateLunExistsAndInitDeviceData.
private boolean validateLunExistsAndInitDeviceData(LUNs lun, StorageType storageType, Guid vdsId) {
List<LUNs> lunFromStorage = null;
try {
StorageServerConnectionManagementVDSParameters connectParams = new StorageServerConnectionManagementVDSParameters(vdsId, Guid.Empty, storageType, lun.getLunConnections());
runVdsCommand(VDSCommandType.ConnectStorageServer, connectParams);
GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vdsId, storageType, false, Collections.singleton(lun.getLUNId()));
lunFromStorage = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
} catch (Exception e) {
log.debug("Exception while validating LUN disk: '{}'", e);
return false;
}
if (lunFromStorage == null || lunFromStorage.isEmpty()) {
return false;
} else {
LUNs luns = lunFromStorage.get(0);
lun.setSerial(luns.getSerial());
lun.setLunMapping(luns.getLunMapping());
lun.setVendorId(luns.getVendorId());
lun.setProductId(luns.getProductId());
lun.setProductId(luns.getProductId());
lun.setDiscardMaxSize(luns.getDiscardMaxSize());
lun.setPvSize(luns.getPvSize());
}
return true;
}
use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class DisconnectHostFromStoragePoolServersCommand method disconnectStorageByType.
private void disconnectStorageByType(StorageType storageType, List<StorageServerConnections> connections) {
/*
* HE SD should only be connected/disconnected by the HE tools, not
* by the engine.
*/
Set<String> heIds = storageDomainDao.getHostedEngineStorageDomainIds().stream().map(storageDomainDao::get).map(StorageDomain::getStorageStaticData).map(StorageDomainStatic::getStorage).collect(Collectors.toSet());
connections = connections.stream().filter(c -> !heIds.contains(c.getId())).collect(Collectors.toList());
storageHelperDirector.getItem(storageType).prepareDisconnectHostFromStoragePoolServers(getParameters(), connections);
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.DisconnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), getStoragePool().getId(), storageType, connections));
setSucceeded(vdsReturnValue.getSucceeded());
if (!vdsReturnValue.getSucceeded()) {
storageHelperDirector.getItem(storageType).isConnectSucceeded((HashMap<String, String>) vdsReturnValue.getReturnValue(), connections);
}
}
use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class RunVmCommandTest method dontConnectFCLuns.
@Test
public void dontConnectFCLuns() {
// FC luns are connected physically, they don't have StorageServerConnection set.
// Make sure if we have an FC lun connection we don't try to connect
// otherwise NPE will be thrown.
command.setVm(new VM());
// create 2 FC lun disks
LunDisk fcLunDisk = new LunDisk();
LUNs lun1 = new LUNs();
lun1.setLUNId("id1");
fcLunDisk.setLun(lun1);
LunDisk isciDisk = new LunDisk();
LUNs lun2 = new LUNs();
lun2.setLUNId("id2");
isciDisk.setLun(lun2);
// add luns to the vm
command.getVm().getDiskMap().put(Guid.newGuid(), fcLunDisk);
command.getVm().getDiskMap().put(Guid.newGuid(), isciDisk);
List<StorageServerConnections> iscsiLunConnections = new ArrayList<>();
iscsiLunConnections.add(new StorageServerConnections("path/to/iscsi/connection", "id1", null, null, StorageType.ISCSI, null, null, null));
when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(Collections.emptyList());
when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(iscsiLunConnections);
ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
// for different targets, make sure we connect all but not FC.
verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
assertThat(captor.getValue().getConnectionList().size(), is(1));
assertEquals(captor.getValue().getStorageType(), StorageType.ISCSI);
assertTrue(connectSucceeded);
}
use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters 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.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class RunVmCommandBase method connectLunDisks.
protected boolean connectLunDisks(Guid hostId) {
if (getVm().getDiskMap().isEmpty()) {
vmHandler.updateDisksFromDb(getVm());
}
List<LunDisk> lunDisks = DisksFilter.filterLunDisks(getVm().getDiskMap().values());
Map<StorageType, List<StorageServerConnections>> connectionsByType = lunDisks.stream().flatMap(d -> storageServerConnectionDao.getAllForLun(d.getLun().getLUNId()).stream()).distinct().collect(groupingBy(StorageServerConnections::getStorageType, toList()));
return connectionsByType.entrySet().stream().map(entry -> runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(hostId, getStoragePoolId(), entry.getKey(), entry.getValue()))).noneMatch(vdsReturnValue -> !vdsReturnValue.getSucceeded());
}
Aggregations