use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class BackendAttachedStorageDomainsResourceTest method setUpStorageServerConnection.
static StorageServerConnections setUpStorageServerConnection() {
StorageServerConnections cnx = new StorageServerConnections();
cnx.setId(GUIDS[0].toString());
cnx.setConnection("10.11.12.13" + ":" + "/1");
return cnx;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class StorageDomainMapper method map.
@Mapping(from = StorageConnection.class, to = StorageServerConnections.class)
public static StorageServerConnections map(StorageConnection model, StorageServerConnections template) {
StorageServerConnections entity = template != null ? template : new StorageServerConnections();
if (model.isSetId()) {
entity.setId(model.getId());
}
org.ovirt.engine.core.common.businessentities.storage.StorageType storageType = null;
if (model.getType() != null) {
storageType = map(model.getType(), null);
} else if (template != null) {
storageType = template.getStorageType();
}
if (storageType != null) {
entity.setStorageType(storageType);
switch(storageType) {
case ISCSI:
if (model.isSetAddress()) {
entity.setConnection(model.getAddress());
}
if (model.isSetPort()) {
entity.setPort(model.getPort().toString());
}
if (model.isSetUsername()) {
entity.setUserName(model.getUsername());
}
if (model.isSetTarget()) {
entity.setIqn(model.getTarget());
}
if (model.isSetPassword()) {
entity.setPassword(model.getPassword());
}
break;
case FCP:
break;
case NFS:
// in case of update, one or both of the address/path fields might be updated.
// thus, need to take care of their assignment separately since they are merged
// in the backend into a single field.
String[] parts = null;
if (!StringUtils.isEmpty(entity.getConnection())) {
parts = entity.getConnection().split(":");
}
String address = null;
String path = null;
if (model.isSetAddress()) {
address = model.getAddress();
} else {
address = parts != null ? parts[0] : "";
}
if (model.isSetPath()) {
path = model.getPath();
} else {
path = parts != null ? parts[1] : "";
}
entity.setConnection(address + ":" + path);
if (model.getNfsRetrans() != null) {
entity.setNfsRetrans(model.getNfsRetrans().shortValue());
}
if (model.getNfsTimeo() != null) {
entity.setNfsTimeo(model.getNfsTimeo().shortValue());
}
if (model.getNfsVersion() != null) {
entity.setNfsVersion(map(model.getNfsVersion(), null));
}
if (model.isSetMountOptions()) {
entity.setMountOptions(model.getMountOptions());
}
break;
case LOCALFS:
if (model.isSetPath()) {
entity.setConnection(model.getPath());
}
break;
case POSIXFS:
case GLUSTERFS:
if (model.isSetAddress() && model.isSetPath()) {
entity.setConnection(model.getAddress() + ":" + model.getPath());
} else if (model.isSetPath()) {
entity.setConnection(model.getPath());
}
if (model.isSetMountOptions()) {
entity.setMountOptions(model.getMountOptions());
}
if (model.isSetVfsType()) {
entity.setVfsType(model.getVfsType());
}
break;
default:
break;
}
}
return entity;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class AddStorageServerConnectionCommand method validate.
@Override
protected boolean validate() {
StorageServerConnections paramConnection = getConnection();
// if an id was sent - it's not ok since only the backend should allocate ids
if (StringUtils.isNotEmpty(paramConnection.getId())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY);
}
if (!isValidConnection(paramConnection)) {
return false;
}
Guid storagePoolId = Guid.isNullOrEmpty(getParameters().getVdsId()) ? null : getVds().getStoragePoolId();
if (isConnWithSameDetailsExists(paramConnection, storagePoolId)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS);
}
// validate that it's a valid VDS ID and that the VDS is up.
if (!Guid.isNullOrEmpty(getParameters().getVdsId())) {
if (getVds() == null) {
return failValidation(EngineMessage.VDS_INVALID_SERVER_ID);
}
if (getVds().getStatus() != VDSStatus.Up) {
return failValidation(EngineMessage.VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP);
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class AddStorageServerConnectionCommand method executeCommand.
@Override
protected void executeCommand() {
// If not, just save the connection to the database
if (!Guid.isNullOrEmpty(getParameters().getVdsId())) {
Pair<Boolean, Integer> result = connectHostToStorage();
boolean isValidConnection = result.getFirst();
// Process failure
if (!isValidConnection) {
throw new EngineException(EngineError.forValue(result.getSecond()));
}
}
StorageServerConnections connection = getConnection();
connection.setId(Guid.newGuid().toString());
saveConnection(connection);
getReturnValue().setActionReturnValue(connection.getId());
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class BaseIscsiBondCommand method connectAllHostsToStorage.
protected void connectAllHostsToStorage(List<String> connectionIds) {
List<Callable<Void>> tasks = new ArrayList<>();
final List<StorageServerConnections> connections = storageServerConnectionDao.getByIds(connectionIds);
List<VDS> hosts = vdsDao.getAllForStoragePoolAndStatus(getIscsiBond().getStoragePoolId(), VDSStatus.Up);
for (final VDS host : hosts) {
tasks.add(() -> {
try {
final List<StorageServerConnections> conns = iscsiStorageHelper.updateIfaces(connections, host.getId());
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(host.getId(), Guid.Empty, StorageType.ISCSI, conns));
final Map<String, String> iscsiMap = (Map<String, String>) returnValue.getReturnValue();
List<String> failedConnectionsList = iscsiMap.entrySet().stream().filter(e -> !"0".equals(e.getValue())).map(Map.Entry::getKey).collect(Collectors.toList());
if (!failedConnectionsList.isEmpty()) {
log.error("Host '{}' - '{}' encounter problems to connect to the iSCSI Storage" + " Server. The following connections were problematic" + "" + " (connectionid=vdsm result): {}", host.getName(), host.getId(), iscsiMap.toString());
encounterConnectionProblems = true;
}
} catch (EngineException e) {
log.error("Could not connect Host '{}' - '{}' to Iscsi Storage Server: {}", host.getName(), host.getId(), e.getMessage());
log.debug("Exception", e);
encounterConnectionProblems = true;
}
return null;
});
}
ThreadPoolUtil.invokeAll(tasks);
}
Aggregations