use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class RemoveStorageServerConnectionCommand method validate.
@Override
protected boolean validate() {
String connectionId = getConnection().getId();
List<StorageDomain> domains = null;
if (StringUtils.isEmpty(connectionId)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY);
}
StorageServerConnections connection = storageServerConnectionDao.get(connectionId);
if (connection == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST);
}
// if user passed only the connection id for removal, vdsm still needs few more details in order to disconnect, so
// bringing them from db and repopulating them in the connection object received in input parameters
populateMissingFields(connection);
StorageType storageType = connection.getStorageType();
if (storageType.isFileDomain()) {
// go to storage domain static, get all storage domains where storage field = storage connection id
domains = getStorageDomainsByConnId(connectionId);
if (domains.size() > 0) {
String domainNames = createDomainNamesListFromStorageDomains(domains);
return prepareFailureMessageForDomains(domainNames);
}
} else if (storageType.equals(StorageType.ISCSI)) {
List<String> domainNames = new ArrayList<>();
List<String> diskNames = new ArrayList<>();
// go to luns to storage connections map table, get it from there
List<LUNs> luns = lunDao.getAllForStorageServerConnection(connectionId);
if (!luns.isEmpty()) {
String volumeGroupId = null;
for (LUNs lun : luns) {
volumeGroupId = lun.getVolumeGroupId();
if (StringUtils.isNotEmpty(volumeGroupId)) {
// non empty vg id indicates there's a storage domain using the lun
String domainName = lun.getStorageDomainName();
domainNames.add(domainName);
} else {
// empty vg id indicates there's a lun disk using the lun
String lunDiskName = lun.getDiskAlias();
diskNames.add(lunDiskName);
}
}
String domainNamesForMessage = null;
if (!domainNames.isEmpty()) {
// Build domain names list to display in the error
domainNamesForMessage = prepareEntityNamesForMessage(domainNames);
if (diskNames.isEmpty()) {
return prepareFailureMessageForDomains(domainNamesForMessage);
} else {
String diskNamesForMessage = prepareEntityNamesForMessage(diskNames);
return prepareFailureMessageForDomainsAndDisks(domainNamesForMessage, diskNamesForMessage);
}
} else if (!diskNames.isEmpty()) {
String diskNamesForMessage = prepareEntityNamesForMessage(diskNames);
return prepareFailureMessageForDisks(diskNamesForMessage);
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class DetachStorageConnectionFromStorageDomainCommand method createStorageConnectionValidator.
protected StorageConnectionValidator createStorageConnectionValidator() {
String connectionId = getParameters().getStorageConnectionId();
StorageServerConnections connection = storageServerConnectionDao.get(connectionId);
return new StorageConnectionValidator(connection);
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class StorageServerConnectionDaoTest method testGetForIqnWithInvalidIqn.
@Test
public void testGetForIqnWithInvalidIqn() {
StorageServerConnections result = dao.getForIqn("farkle");
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class StorageServerConnectionDaoTest method generateNewEntity.
@Override
protected StorageServerConnections generateNewEntity() {
StorageServerConnections newServerConnection = new StorageServerConnections();
newServerConnection.setId("0cc146e8-e5ed-482c-8814-270bc48c2980");
newServerConnection.setConnection(EXISTING_DOMAIN_STORAGE_NAME);
newServerConnection.setNfsVersion(NfsVersion.V4);
newServerConnection.setNfsRetrans((short) 5);
return newServerConnection;
}
use of org.ovirt.engine.core.common.businessentities.StorageServerConnections in project ovirt-engine by oVirt.
the class StorageServerConnectionDaoTest method testGetForIqn.
@Test
public void testGetForIqn() {
StorageServerConnections result = dao.getForIqn(existingEntity.getIqn());
assertNotNull(result);
assertEquals(existingEntity, result);
}
Aggregations