use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class StorageDomainMapperTest method checkISCSIStorageConnectionsMappings.
@Test
public void checkISCSIStorageConnectionsMappings() {
StorageServerConnections connection = new StorageServerConnections();
Guid connId = Guid.newGuid();
connection.setId(connId.toString());
connection.setIqn("iqn.my.target1");
connection.setPort("3260");
connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI);
connection.setConnection("1.2.135.255");
connection.setUserName("myuser1");
connection.setPassword("123");
HostStorage RESTConnection = new HostStorage();
RESTConnection.setId(connId.toString());
RESTConnection.setType(StorageType.ISCSI);
RESTConnection.setPort(3260);
RESTConnection.setTarget("iqn.my.target1");
RESTConnection.setAddress("1.2.135.255");
RESTConnection.setUsername("myuser1");
StorageConnection mappedResult = StorageDomainMapper.map(connection, null);
assertEquals(RESTConnection.getId(), mappedResult.getId());
// Although password was set on StorageServerConnections object, it should not be returned via REST
// thus testing here that it remains empty.
assertEquals(RESTConnection.getPassword(), mappedResult.getPassword());
assertEquals(RESTConnection.getType(), mappedResult.getType());
assertEquals(RESTConnection.getAddress(), mappedResult.getAddress());
assertEquals(RESTConnection.getUsername(), mappedResult.getUsername());
assertEquals(RESTConnection.getTarget(), mappedResult.getTarget());
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommand method validate.
@Override
protected boolean validate() {
StorageServerConnections newConnectionDetails = getConnection();
StorageType storageType = newConnectionDetails.getStorageType();
if (!storageType.isFileDomain() && !storageType.equals(StorageType.ISCSI)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE);
}
if (!isValidConnection(newConnectionDetails)) {
return false;
}
// Check if connection exists by id, otherwise there's nothing to update
String connectionId = newConnectionDetails.getId();
StorageServerConnections oldConnection = storageServerConnectionDao.get(connectionId);
if (oldConnection == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST);
}
if (!newConnectionDetails.getStorageType().equals(oldConnection.getStorageType())) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE);
}
Guid storagePoolId = getStoragePoolIdByFileConnectionId(oldConnection.getId());
if (isConnWithSameDetailsExists(newConnectionDetails, storagePoolId)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS);
}
if (doDomainsUseConnection(newConnectionDetails) || doLunsUseConnection()) {
if (storageType.isFileDomain() && domains.size() > 1) {
String domainNames = createDomainNamesList(domains);
addValidationMessageVariable("domainNames", domainNames);
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS);
}
// Check that the storage domain is in proper state to be edited
if (!isConnectionEditable(newConnectionDetails)) {
return false;
}
}
return super.validate();
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class ConnectStorageToVdsCommand method connectHostToStorage.
protected Pair<Boolean, Integer> connectHostToStorage() {
List<StorageServerConnections> connections = Arrays.asList(getConnection());
if (getConnection().getStorageType() == StorageType.ISCSI) {
connections = iscsiStorageHelper.updateIfaces(connections, getVds().getId());
}
Map<String, String> result = (HashMap<String, String>) runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), Guid.Empty, getConnection().getStorageType(), connections)).getReturnValue();
return new Pair<>(storageHelperDirector.getItem(getConnection().getStorageType()).isConnectSucceeded(result, connections), Integer.parseInt(result.values().iterator().next()));
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class FileStorageHelper method runConnectionStorageToDomain.
@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type) {
Pair<Boolean, EngineFault> result;
StorageServerConnections connection = storageServerConnectionDao.get(storageDomain.getStorage());
if (connection != null) {
ActionReturnValue returnValue = backend.runInternalAction(ActionType.forValue(type), new StorageServerConnectionParametersBase(connection, vdsId, false));
result = new Pair<>(returnValue.getSucceeded(), returnValue.getFault());
} else {
result = new Pair<>(false, null);
log.warn("Did not connect host '{}' to storage domain '{}' because connection for connectionId '{}' is null.", vdsId, storageDomain.getStorageName(), storageDomain.getStorage());
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method storageDomainRemoved.
@Override
public boolean storageDomainRemoved(StorageDomainStatic storageDomain) {
List<StorageServerConnections> list = storageServerConnectionDao.getAllForVolumeGroup(storageDomain.getStorage());
for (StorageServerConnections connection : filterConnectionsUsedByOthers(list, storageDomain.getStorage(), "")) {
storageServerConnectionDao.remove(connection.getId());
}
// There is no need to remove entries from lun_storage_server_connection_map,
// as the foreign key from the luns table is defined as ON DELETE CASCADE.
removeStorageDomainLuns(storageDomain);
return true;
}
Aggregations