use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testUnattachedStorageDomainWithStorageDomainsParameterQuery.
@Test
public void testUnattachedStorageDomainWithStorageDomainsParameterQuery() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Up);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
storageDomainList.add(storageDomain);
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), null);
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class BackendStorageDomainsResource method addExistingSAN.
private Response addExistingSAN(StorageDomain model, StorageType storageType, Guid hostId) {
getEntity(VDS.class, QueryType.GetVdsByVdsId, new IdQueryParameters(hostId), "Host: id=" + hostId);
List<LUNs> existingLuns = getDeviceList(hostId, storageType);
List<StorageServerConnections> existingStorageServerConnections = getLunsWithInitializedStorageType(existingLuns, storageType);
List<org.ovirt.engine.core.common.businessentities.StorageDomain> existingStorageDomains = getExistingBlockStorageDomain(hostId, storageType, existingStorageServerConnections);
StorageDomainStatic storageDomainToImport = getMatchingStorageDomain(asGuid(model.getId()), existingStorageDomains);
if (storageDomainToImport == null) {
throw new WebFaultException(new WebApplicationException(), "Storage Domain id " + model.getId() + " Does not exists", Status.NOT_FOUND);
}
StorageDomainMapper.map(model, storageDomainToImport);
StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(storageDomainToImport);
parameters.setVdsId(hostId);
return performCreate(ActionType.AddExistingBlockStorageDomain, parameters, ID_RESOLVER);
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class BackendStorageDomainsResource method add.
@Override
public Response add(StorageDomain storageDomain) {
validateParameters(storageDomain, "host.id|name", "type", "storage");
validateRange("nfs_timeio", storageDomain.getStorage().getNfsTimeo(), 0, 65535);
validateRange("nfs_retrans", storageDomain.getStorage().getNfsRetrans(), 0, 65535);
HostStorage storageConnectionFromUser = storageDomain.getStorage();
Guid hostId = getHostId(storageDomain);
StorageServerConnections cnx = null;
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain, "storage.type");
cnx = mapToCnx(storageDomain);
if (cnx.getStorageType().isFileDomain()) {
validateParameters(storageConnectionFromUser, "path");
}
} else {
cnx = getStorageServerConnection(storageConnectionFromUser.getId());
storageDomain.getStorage().setType(mapType(cnx.getStorageType()));
}
StorageDomainStatic entity = mapToStatic(storageDomain);
Response resp = null;
switch(entity.getStorageType()) {
case ISCSI:
case FCP:
if (storageDomain.isSetImport() && storageDomain.isImport()) {
validateParameters(storageDomain, "id");
resp = addExistingSAN(storageDomain, entity.getStorageType(), hostId);
} else {
resp = addSAN(storageDomain, entity.getStorageType(), entity, hostId);
}
break;
case NFS:
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain.getStorage(), "address");
}
resp = addDomain(ActionType.AddNFSStorageDomain, storageDomain, entity, hostId, cnx);
break;
case LOCALFS:
resp = addDomain(ActionType.AddLocalStorageDomain, storageDomain, entity, hostId, cnx);
break;
case POSIXFS:
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain.getStorage(), "vfsType");
}
resp = addDomain(ActionType.AddPosixFsStorageDomain, storageDomain, entity, hostId, cnx);
break;
case GLUSTERFS:
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain.getStorage(), "vfsType");
}
resp = addDomain(ActionType.AddGlusterFsStorageDomain, storageDomain, entity, hostId, cnx);
break;
default:
break;
}
if (resp != null) {
addLinks((StorageDomain) resp.getEntity(), getLinksToExclude(storageDomain));
}
return resp;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class StorageHandlingCommandBase method updateStorageDomainFormatIfNeeded.
protected void updateStorageDomainFormatIfNeeded(StorageDomain domain) {
final StorageDomainType sdType = domain.getStorageDomainType();
if (!sdType.isDataDomain()) {
log.debug("Skipping format update for domain '{}' (type '{}')", getStorageDomain().getId(), sdType);
return;
}
final StorageDomainStatic storageStaticData = domain.getStorageStaticData();
final StorageFormatType targetFormat = getStoragePool().getStoragePoolFormatType();
if (storageStaticData.getStorageFormat() != targetFormat) {
log.info("Updating storage domain '{}' (type '{}') to format '{}'", getStorageDomain().getId(), sdType, targetFormat);
storageStaticData.setStorageFormat(targetFormat);
storageDomainStaticDao.update(storageStaticData);
} else {
log.debug("Skipping format update for domain '{}' format is '{}'", getStorageDomain().getId(), storageStaticData.getStorageFormat());
}
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class BackendOpenStackVolumeProviderResourceTest method getStorageDomainStatic.
public StorageDomainStatic getStorageDomainStatic() {
StorageDomainStatic storageDomainStatic = mock(StorageDomainStatic.class);
when(storageDomainStatic.getId()).thenReturn(GUIDS[0]);
when(storageDomainStatic.getName()).thenReturn(NAMES[0]);
return storageDomainStatic;
}
Aggregations