Search in sources :

Example 11 with HostStorage

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;
}
Also used : StorageType(org.ovirt.engine.api.model.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 12 with HostStorage

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;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 13 with HostStorage

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;
}
Also used : LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 14 with HostStorage

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;
}
Also used : VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 15 with HostStorage

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);
}
Also used : Response(javax.ws.rs.core.Response) StorageDomain(org.ovirt.engine.api.model.StorageDomain) Host(org.ovirt.engine.api.model.Host) HostStorage(org.ovirt.engine.api.model.HostStorage) Test(org.junit.Test)

Aggregations

HostStorage (org.ovirt.engine.api.model.HostStorage)20 Test (org.junit.Test)8 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)7 StorageDomain (org.ovirt.engine.api.model.StorageDomain)6 Host (org.ovirt.engine.api.model.Host)4 Guid (org.ovirt.engine.core.compat.Guid)4 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)3 LogicalUnits (org.ovirt.engine.api.model.LogicalUnits)3 StorageConnection (org.ovirt.engine.api.model.StorageConnection)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 Response (javax.ws.rs.core.Response)2 Disk (org.ovirt.engine.api.model.Disk)2 VolumeGroup (org.ovirt.engine.api.model.VolumeGroup)2 DiskFormat (org.ovirt.engine.api.model.DiskFormat)1 DiskStatus (org.ovirt.engine.api.model.DiskStatus)1 HostStorages (org.ovirt.engine.api.model.HostStorages)1 StorageType (org.ovirt.engine.api.model.StorageType)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)1