Search in sources :

Example 1 with OpenStackNetworkProvider

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

the class BackendOpenStackNetworkResource method addParents.

@Override
protected OpenStackNetwork addParents(OpenStackNetwork network) {
    OpenStackNetworkProvider provider = new OpenStackNetworkProvider();
    provider.setId(providerId);
    network.setOpenstackNetworkProvider(provider);
    return super.addParents(network);
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider)

Example 2 with OpenStackNetworkProvider

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

the class BackendOpenStackNetworksResource method addParents.

@Override
protected OpenStackNetwork addParents(OpenStackNetwork image) {
    OpenStackNetworkProvider provider = new OpenStackNetworkProvider();
    provider.setId(providerId);
    image.setOpenstackNetworkProvider(provider);
    return super.addParents(image);
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider)

Example 3 with OpenStackNetworkProvider

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

the class BackendOpenStackSubnetResource method addParents.

@Override
protected OpenStackSubnet addParents(OpenStackSubnet subnet) {
    OpenStackNetworkProvider provider = new OpenStackNetworkProvider();
    provider.setId(providerId);
    OpenStackNetwork network = new OpenStackNetwork();
    network.setId(networkId);
    network.setOpenstackNetworkProvider(provider);
    subnet.setOpenstackNetwork(network);
    return super.addParents(subnet);
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) OpenStackNetwork(org.ovirt.engine.api.model.OpenStackNetwork)

Example 4 with OpenStackNetworkProvider

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

the class BackendOpenStackSubnetsResource method addParents.

@Override
protected OpenStackSubnet addParents(OpenStackSubnet subnet) {
    OpenStackNetworkProvider provider = new OpenStackNetworkProvider();
    provider.setId(providerId);
    OpenStackNetwork network = new OpenStackNetwork();
    network.setId(networkId);
    network.setOpenstackNetworkProvider(provider);
    subnet.setOpenstackNetwork(network);
    return super.addParents(subnet);
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) OpenStackNetwork(org.ovirt.engine.api.model.OpenStackNetwork)

Example 5 with OpenStackNetworkProvider

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

the class OpenStackNetworkProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackNetworkProvider.class)
public static OpenStackNetworkProvider map(Provider<OpenstackNetworkProviderProperties> entity, OpenStackNetworkProvider template) {
    OpenStackNetworkProvider model = template != null ? template : new OpenStackNetworkProvider();
    model.setType(mapProviderType(entity.getType()));
    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.setUnmanaged(entity.getIsUnmanaged());
    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);
    }
    OpenstackNetworkProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
        String pluginType = additionalProperties.getPluginType();
        if (pluginType != null) {
            // for backwards compatibility, and should be removed in version 5 of the API.
            if (entity.getType() == ProviderType.OPENSTACK_NETWORK && OpenstackNetworkPluginType.OPEN_VSWITCH.name().equalsIgnoreCase(pluginType)) {
                model.setPluginType(NetworkPluginType.OPEN_VSWITCH);
            }
            model.setExternalPluginType(additionalProperties.getPluginType());
        }
        if (additionalProperties.getAgentConfiguration() != null) {
            model.setAgentConfiguration(map(additionalProperties.getAgentConfiguration(), null));
        }
        model.setReadOnly(additionalProperties.getReadOnly());
        model.setAutoSync(additionalProperties.getAutoSync());
    }
    return model;
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Properties(org.ovirt.engine.api.model.Properties) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.ovirt.engine.api.model.Property) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Aggregations

OpenStackNetworkProvider (org.ovirt.engine.api.model.OpenStackNetworkProvider)8 OpenStackNetwork (org.ovirt.engine.api.model.OpenStackNetwork)2 Properties (org.ovirt.engine.api.model.Properties)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.Test)1 Property (org.ovirt.engine.api.model.Property)1 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)1 Mapping (org.ovirt.engine.api.restapi.types.Mapping)1 V3OpenStackNetworkProvider (org.ovirt.engine.api.v3.types.V3OpenStackNetworkProvider)1 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)1