use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class StorageDomainMapper method map.
@Mapping(from = StorageDomain.class, to = StorageServerConnections.class)
public static StorageServerConnections map(StorageDomain model, StorageServerConnections template) {
StorageServerConnections entity = template != null ? template : new StorageServerConnections();
if (model.isSetStorage() && model.getStorage().isSetType()) {
HostStorage storage = model.getStorage();
StorageType storageType = storage.getType();
if (storageType != null) {
entity.setStorageType(map(storageType, null));
switch(storageType) {
case ISCSI:
break;
case FCP:
break;
case GLANCE:
break;
case NFS:
if (storage.isSetAddress() && storage.isSetPath()) {
entity.setConnection(storage.getAddress() + ":" + storage.getPath());
}
if (storage.getNfsRetrans() != null) {
entity.setNfsRetrans(storage.getNfsRetrans().shortValue());
}
if (storage.getNfsTimeo() != null) {
entity.setNfsTimeo(storage.getNfsTimeo().shortValue());
}
if (storage.getNfsVersion() != null) {
entity.setNfsVersion(map(storage.getNfsVersion(), null));
}
if (storage.isSetMountOptions()) {
entity.setMountOptions(storage.getMountOptions());
}
break;
case LOCALFS:
if (storage.isSetPath()) {
entity.setConnection(storage.getPath());
}
break;
case POSIXFS:
case GLUSTERFS:
if (storage.isSetAddress() && storage.isSetPath()) {
entity.setConnection(storage.getAddress() + ":" + storage.getPath());
} else if (storage.isSetPath()) {
entity.setConnection(storage.getPath());
}
if (storage.isSetMountOptions()) {
entity.setMountOptions(storage.getMountOptions());
}
if (storage.isSetVfsType()) {
entity.setVfsType(storage.getVfsType());
}
default:
break;
}
}
}
return entity;
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class StorageDomainMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.StorageDomain.class, to = StorageDomain.class)
public static StorageDomain map(org.ovirt.engine.core.common.businessentities.StorageDomain entity, StorageDomain template) {
StorageDomain model = template != null ? template : new StorageDomain();
model.setId(entity.getId().toString());
model.setName(entity.getStorageName());
model.setDescription(entity.getDescription());
model.setComment(entity.getComment());
model.setType(map(entity.getStorageDomainType(), null));
model.setWarningLowSpaceIndicator(entity.getWarningLowSpaceIndicator());
model.setCriticalSpaceActionBlocker(entity.getCriticalSpaceActionBlocker());
model.setMaster(entity.getStorageDomainType() == org.ovirt.engine.core.common.businessentities.StorageDomainType.Master);
if (entity.getStatus() != null) {
model.setStatus(mapStorageDomainStatus(entity.getStatus()));
}
if (entity.getExternalStatus() != null) {
model.setExternalStatus(ExternalStatusMapper.map(entity.getExternalStatus()));
}
model.setStorage(new HostStorage());
model.getStorage().setType(map(entity.getStorageType(), null));
if (entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI || entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.FCP) {
model.getStorage().setVolumeGroup(new VolumeGroup());
model.getStorage().getVolumeGroup().setId(entity.getStorage());
}
if (entity.getAvailableDiskSize() != null) {
model.setAvailable(SizeConverter.convert(entity.getAvailableDiskSize().longValue(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
}
if (entity.getUsedDiskSize() != null) {
model.setUsed(SizeConverter.convert(entity.getUsedDiskSize().longValue(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
}
model.setCommitted(SizeConverter.convert(entity.getCommittedDiskSize(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
if (entity.getStorageFormat() != null) {
model.setStorageFormat(StorageFormatMapper.map(entity.getStorageFormat(), null));
}
model.setWipeAfterDelete(entity.getWipeAfterDelete());
model.setDiscardAfterDelete(entity.getDiscardAfterDelete());
model.setSupportsDiscard(entity.getSupportsDiscard());
// Not supported by sysfs since kernel version 4.12, and thus deprecated.
model.setSupportsDiscardZeroesData(false);
model.setBackup(entity.isBackup());
return model;
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class StorageLogicalUnitMapper method map.
@Mapping(from = LUNs.class, to = HostStorage.class)
public static HostStorage map(LUNs entity, HostStorage template) {
HostStorage model = template != null ? template : new HostStorage();
model.setId(entity.getLUNId());
model.setType(StorageDomainMapper.map(entity.getLunType(), null));
model.setLogicalUnits(new LogicalUnits());
model.getLogicalUnits().getLogicalUnits().add(map(entity, (LogicalUnit) null));
return model;
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class StorageVolumeGroupMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.StorageDomain.class, to = HostStorage.class)
public static HostStorage map(org.ovirt.engine.core.common.businessentities.StorageDomain entity, HostStorage template) {
HostStorage model = template != null ? template : new HostStorage();
model.setId(entity.getStorage());
model.setType(StorageDomainMapper.map(entity.getStorageType(), null));
model.setVolumeGroup(new VolumeGroup());
model.getVolumeGroup().setId(entity.getStorage());
return model;
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class BackendStorageDomainsResourceTest method testAddStorageDomainWithExistingConnectionId.
@Test
public void testAddStorageDomainWithExistingConnectionId() throws Exception {
Host host = new Host();
host.setId(GUIDS[0].toString());
setUriInfo(setUpBasicUriExpectations());
setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[POSIX_IDX].toString() }, setUpPosixStorageServerConnection(POSIX_IDX));
setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[POSIX_IDX].toString() }, setUpPosixStorageServerConnection(POSIX_IDX));
setUpGetEntityExpectations(QueryType.GetExistingStorageDomainList, GetExistingStorageDomainListParameters.class, new String[] { "Id", "StorageType", "StorageDomainType", "Path" }, new Object[] { GUIDS[0], STORAGE_TYPES_MAPPED[POSIX_IDX], TYPES_MAPPED[0], ADDRESSES[POSIX_IDX] + ":" + PATHS[POSIX_IDX] }, new ArrayList<>());
setUpCreationExpectations(ActionType.AddPosixFsStorageDomain, StorageDomainManagementParameter.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[POSIX_IDX], QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[POSIX_IDX] }, getEntity(POSIX_IDX));
StorageDomain model = new StorageDomain();
model.setName(getSafeEntry(POSIX_IDX, NAMES));
model.setDescription(getSafeEntry(POSIX_IDX, DESCRIPTIONS));
model.setType(getSafeEntry(POSIX_IDX, TYPES));
model.setStorage(new HostStorage());
model.setHost(new Host());
model.getHost().setId(GUIDS[0].toString());
model.getStorage().setId(GUIDS[POSIX_IDX].toString());
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof StorageDomain);
verifyModel((StorageDomain) response.getEntity(), POSIX_IDX);
}
Aggregations