Search in sources :

Example 21 with DataCenter

use of org.ovirt.engine.api.model.DataCenter in project ovirt-engine by oVirt.

the class DataCenterMapperTest method testStatusMapping.

private void testStatusMapping(StoragePoolStatus storagePoolStatus, DataCenterStatus dataCenterStatus) {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(storagePoolStatus);
    DataCenter dataCenter = DataCenterMapper.map(storagePool, null);
    assertEquals(dataCenter.getStatus(), dataCenterStatus);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) DataCenter(org.ovirt.engine.api.model.DataCenter)

Example 22 with DataCenter

use of org.ovirt.engine.api.model.DataCenter in project ovirt-engine by oVirt.

the class OpenStackVolumeProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackVolumeProvider.class)
public static OpenStackVolumeProvider map(Provider<OpenStackVolumeProviderProperties> entity, OpenStackVolumeProvider template) {
    OpenStackVolumeProvider model = template != null ? template : new OpenStackVolumeProvider();
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getUrl() != null) {
        model.setUrl(entity.getUrl());
    }
    if (entity.getAuthUrl() != null) {
        model.setAuthenticationUrl(entity.getAuthUrl());
    }
    model.setRequiresAuthentication(entity.isRequiringAuthentication());
    if (entity.getUsername() != null) {
        model.setUsername(entity.getUsername());
    }
    // The password isn't mapped for security reasons.
    // if (entity.getPassword() != null) {
    // model.setPassword(entity.getPassword());
    // }
    Map<String, String> customProperties = entity.getCustomProperties();
    if (customProperties != null) {
        Properties properties = new Properties();
        for (Map.Entry<String, String> entry : customProperties.entrySet()) {
            Property property = new Property();
            property.setName(entry.getKey());
            property.setValue(entry.getValue());
            properties.getProperties().add(property);
        }
        model.setProperties(properties);
    }
    OpenStackVolumeProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
        if (additionalProperties.getStoragePoolId() != null) {
            DataCenter dataCenter = new DataCenter();
            dataCenter.setId(additionalProperties.getStoragePoolId().toString());
            model.setDataCenter(dataCenter);
        }
    }
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) OpenStackVolumeProviderProperties(org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider) Properties(org.ovirt.engine.api.model.Properties) OpenStackVolumeProviderProperties(org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 23 with DataCenter

use of org.ovirt.engine.api.model.DataCenter in project ovirt-engine by oVirt.

the class LinkHelperTest method testDataCenterLinks.

@Test
public void testDataCenterLinks() throws Exception {
    DataCenter dataCenter = new DataCenter();
    dataCenter.setId(DATA_CENTER_ID);
    LinkHelper.addLinks(dataCenter);
    assertEquals(DATA_CENTER_HREF, dataCenter.getHref());
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Test(org.junit.Test)

Example 24 with DataCenter

use of org.ovirt.engine.api.model.DataCenter in project ovirt-engine by oVirt.

the class LinkHelperTest method testAttachedStorageDomainLinks.

@Test
public void testAttachedStorageDomainLinks() throws Exception {
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(STORAGE_DOMAIN_ID);
    storageDomain.setDataCenter(new DataCenter());
    storageDomain.getDataCenter().setId(DATA_CENTER_ID);
    LinkHelper.addLinks(storageDomain);
    assertEquals(ATTACHED_STORAGE_DOMAIN_HREF, storageDomain.getHref());
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) DataCenter(org.ovirt.engine.api.model.DataCenter) Test(org.junit.Test)

Example 25 with DataCenter

use of org.ovirt.engine.api.model.DataCenter in project ovirt-engine by oVirt.

the class AbstractBackendVnicProfileResource method addLinks.

@Override
protected VnicProfile addLinks(VnicProfile model, Class<? extends BaseResource> suggestedParent, String... subCollectionMembersToExclude) {
    if (model.isSetQos() && model.getQos().isSetId()) {
        QosBase qos = getEntity(QosBase.class, QueryType.GetQosById, new IdQueryParameters(asGuid(model.getQos().getId())), "qos");
        model.getQos().setDataCenter(new DataCenter());
        model.getQos().getDataCenter().setId(qos.getStoragePoolId().toString());
    }
    return super.addLinks(model, suggestedParent, subCollectionMembersToExclude);
}
Also used : QosBase(org.ovirt.engine.core.common.businessentities.qos.QosBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DataCenter(org.ovirt.engine.api.model.DataCenter)

Aggregations

DataCenter (org.ovirt.engine.api.model.DataCenter)42 Test (org.junit.Test)10 WebApplicationException (javax.ws.rs.WebApplicationException)6 Network (org.ovirt.engine.api.model.Network)6 StorageDomain (org.ovirt.engine.api.model.StorageDomain)5 Response (javax.ws.rs.core.Response)4 Qos (org.ovirt.engine.api.model.Qos)4 Quota (org.ovirt.engine.api.model.Quota)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 Cluster (org.ovirt.engine.api.model.Cluster)3 Permission (org.ovirt.engine.api.model.Permission)3 Role (org.ovirt.engine.api.model.Role)3 AddNetworkStoragePoolParameters (org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters)3 QosBase (org.ovirt.engine.core.common.businessentities.qos.QosBase)3 QosQueryParameterBase (org.ovirt.engine.core.common.queries.QosQueryParameterBase)3 Cpu (org.ovirt.engine.api.model.Cpu)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1