Search in sources :

Example 6 with OpenStackVolumeProvider

use of org.ovirt.engine.api.model.OpenStackVolumeProvider 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 7 with OpenStackVolumeProvider

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

the class BackendOpenStackVolumeAuthenticationKeyResource method addParents.

@Override
protected OpenstackVolumeAuthenticationKey addParents(OpenstackVolumeAuthenticationKey authenticationKey) {
    OpenStackVolumeProvider provider = new OpenStackVolumeProvider();
    provider.setId(providerId);
    authenticationKey.setOpenstackVolumeProvider(provider);
    return super.addParents(authenticationKey);
}
Also used : OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider)

Example 8 with OpenStackVolumeProvider

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

the class BackendOpenStackVolumeProvidersResource method mapCollection.

private OpenStackVolumeProviders mapCollection(List<Provider> entities) {
    OpenStackVolumeProviders collection = new OpenStackVolumeProviders();
    for (Provider entity : entities) {
        OpenStackVolumeProvider provider = map(entity);
        collection.getOpenStackVolumeProviders().add(addLinks(populate(provider, entity)));
    }
    return collection;
}
Also used : OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider) OpenStackVolumeProviders(org.ovirt.engine.api.model.OpenStackVolumeProviders) Provider(org.ovirt.engine.core.common.businessentities.Provider) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider)

Example 9 with OpenStackVolumeProvider

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

the class BackendOpenStackVolumeTypeResource method addParents.

@Override
protected OpenStackVolumeType addParents(OpenStackVolumeType volumeType) {
    OpenStackVolumeProvider provider = new OpenStackVolumeProvider();
    provider.setId(providerId);
    volumeType.setOpenstackVolumeProvider(provider);
    return super.addParents(volumeType);
}
Also used : OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider)

Example 10 with OpenStackVolumeProvider

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

the class BackendOpenStackVolumeAuthenticationKeyResourceTest method getModel.

private OpenstackVolumeAuthenticationKey getModel(int index) {
    OpenstackVolumeAuthenticationKey model = new OpenstackVolumeAuthenticationKey();
    model.setId(GUIDS[index].toString());
    model.setDescription(DESCRIPTIONS[index]);
    OpenStackVolumeProvider provider = new OpenStackVolumeProvider();
    provider.setId(GUIDS[0].toString());
    model.setOpenstackVolumeProvider(provider);
    model.setUsageType(OpenstackVolumeAuthenticationKeyUsageType.CEPH);
    return model;
}
Also used : OpenstackVolumeAuthenticationKey(org.ovirt.engine.api.model.OpenstackVolumeAuthenticationKey) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider)

Aggregations

OpenStackVolumeProvider (org.ovirt.engine.api.model.OpenStackVolumeProvider)11 OpenstackVolumeAuthenticationKey (org.ovirt.engine.api.model.OpenstackVolumeAuthenticationKey)2 Properties (org.ovirt.engine.api.model.Properties)2 Mapping (org.ovirt.engine.api.restapi.types.Mapping)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.Test)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 OpenStackVolumeProviders (org.ovirt.engine.api.model.OpenStackVolumeProviders)1 Property (org.ovirt.engine.api.model.Property)1 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)1 V3OpenStackVolumeProvider (org.ovirt.engine.api.v3.types.V3OpenStackVolumeProvider)1 Provider (org.ovirt.engine.core.common.businessentities.Provider)1 OpenStackVolumeProviderProperties (org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties)1