use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class AbstractDiskVmCommand method performPlugCommand.
protected void performPlugCommand(VDSCommandType commandType, Disk disk, VmDevice vmDevice) {
if (disk.getDiskStorageType() == DiskStorageType.LUN) {
LunDisk lunDisk = (LunDisk) disk;
if (commandType == VDSCommandType.HotPlugDisk) {
LUNs lun = lunDisk.getLun();
updateLUNConnectionsInfo(lun);
lun.getLunConnections().stream().map(StorageServerConnections::getStorageType).distinct().forEach(t -> {
if (!getStorageHelper(t).connectStorageToLunByVdsId(null, getVm().getRunOnVds(), lun, getVm().getStoragePoolId())) {
throw new EngineException(EngineError.StorageServerConnectionError);
}
});
}
} else if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
CinderDisk cinderDisk = (CinderDisk) disk;
setStorageDomainId(cinderDisk.getStorageIds().get(0));
getCinderBroker().updateConnectionInfoForDisk(cinderDisk);
}
Map<String, String> diskAddressMap = getDiskAddressMap(vmDevice, getDiskVmElement().getDiskInterface());
runVdsCommand(commandType, new HotPlugDiskVDSParameters(getVm().getRunOnVds(), getVm(), disk, vmDevice, diskAddressMap, getDiskVmElement().getDiskInterface(), getDiskVmElement().isPassDiscard()));
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method filterConnectionsUsedByOthers.
@SuppressWarnings("unchecked")
@Override
protected List<StorageServerConnections> filterConnectionsUsedByOthers(List<StorageServerConnections> connections, String vgId, final String lunId) {
// if we have lun id then filter by this lun
// else get vg's luns from db
List<String> lunsByVgWithNoDisks = new ArrayList<>();
if (lunId.isEmpty()) {
List<String> lunsByVg = lunDao.getAllForVolumeGroup(vgId).stream().map(LUNs::getLUNId).collect(Collectors.toList());
// at that case they should left at db
for (String lunIdByVg : lunsByVg) {
if (diskLunMapDao.getDiskIdByLunId(lunIdByVg) == null) {
lunsByVgWithNoDisks.add(lunIdByVg);
}
}
} else {
lunsByVgWithNoDisks.add(lunId);
}
List<StorageServerConnections> toRemove = new ArrayList<>();
for (StorageServerConnections connection : connections) {
fillConnectionDetailsIfNeeded(connection);
if (connection.getId() != null) {
List<String> list = lunDao.getAllForStorageServerConnection(connection.getId()).stream().map(LUNs::getLUNId).collect(Collectors.toList());
if (0 < CollectionUtils.subtract(list, lunsByVgWithNoDisks).size()) {
toRemove.add(connection);
}
}
}
return (List<StorageServerConnections>) CollectionUtils.subtract(connections, toRemove);
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method updateIfaces.
public List<StorageServerConnections> updateIfaces(List<StorageServerConnections> conns, Guid vdsId) {
List<StorageServerConnections> res = new ArrayList<>(conns);
for (StorageServerConnections conn : conns) {
// Get list of endpoints (nics or vlans) that will initiate iscsi sessions.
// Targets are represented by StorageServerConnections object (connection, iqn, port, portal).
List<VdsNetworkInterface> ifaces = interfaceDao.getIscsiIfacesByHostIdAndStorageTargetId(vdsId, conn.getId());
if (!ifaces.isEmpty()) {
VdsNetworkInterface removedInterface = ifaces.remove(0);
setInterfaceProperties(conn, removedInterface);
// from more than one endpoint(initiator) we have to clone this connection per endpoint.
for (VdsNetworkInterface iface : ifaces) {
StorageServerConnections newConn = StorageServerConnections.copyOf(conn);
newConn.setId(Guid.newGuid().toString());
setInterfaceProperties(newConn, iface);
res.add(newConn);
}
}
}
return res;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method isConnectSucceeded.
@Override
public boolean isConnectSucceeded(final Map<String, String> returnValue, List<StorageServerConnections> connections) {
boolean result = true;
List<String> failedConnectionsList = returnValue.keySet().stream().filter(a -> !"0".equals(returnValue.get(a))).collect(Collectors.toList());
for (String failedConnection : failedConnectionsList) {
List<LUNs> failedLuns = lunDao.getAllForStorageServerConnection(failedConnection);
if (!failedLuns.isEmpty()) {
for (LUNs lun : failedLuns) {
// TODO: check if LUNs in the same pool.
List<String> strings = storageServerConnectionLunMapDao.getAll(lun.getLUNId()).stream().map(LUNStorageServerConnectionMap::getStorageServerConnection).collect(Collectors.toList());
if (CollectionUtils.subtract(strings, failedConnectionsList).size() == 0) {
// At case of failure the appropriate log message will be
// added
log.info("The lun with id '{}' was reported as problematic", lun.getPhysicalVolumeId());
for (String connectionFailed : failedConnectionsList) {
String connectionField = addToAuditLogErrorMessage(connectionFailed, returnValue.get(connectionFailed), connections, lun);
printLog(log, connectionField, returnValue.get(connectionFailed));
}
return false;
}
}
} else {
result = false;
printLog(log, failedConnection, returnValue.get(failedConnection));
}
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method runConnectionStorageToDomain.
@SuppressWarnings("unchecked")
@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) {
boolean isSuccess = true;
VDSReturnValue returnValue = null;
List<StorageServerConnections> list = (lun == null) ? storageServerConnectionDao.getAllForVolumeGroup(storageDomain.getStorage()) : lun.getLunConnections();
if (list.size() != 0) {
if (VDSCommandType.forValue(type) == VDSCommandType.DisconnectStorageServer) {
list = filterConnectionsUsedByOthers(list, storageDomain.getStorage(), lun != null ? lun.getLUNId() : "");
} else if (VDSCommandType.forValue(type) == VDSCommandType.ConnectStorageServer) {
list = updateIfaces(list, vdsId);
}
Guid poolId = storagePoolId;
if (storageDomain != null && storageDomain.getStoragePoolId() != null) {
poolId = storageDomain.getStoragePoolId();
}
returnValue = backend.getResourceManager().runVdsCommand(VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, poolId, StorageType.ISCSI, list));
isSuccess = returnValue.getSucceeded();
if (isSuccess && VDSCommandType.forValue(type) == VDSCommandType.ConnectStorageServer) {
isSuccess = isConnectSucceeded((Map<String, String>) returnValue.getReturnValue(), list);
}
}
EngineFault engineFault = null;
if (!isSuccess && returnValue.getVdsError() != null) {
engineFault = new EngineFault();
engineFault.setError(returnValue.getVdsError().getCode());
}
return new Pair<>(isSuccess, engineFault);
}
Aggregations