Search in sources :

Example 1 with OpenStackImageProviderProperties

use of org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties in project ovirt-engine by oVirt.

the class OpenStackImageProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackImageProvider.class)
public static OpenStackImageProvider map(Provider<OpenStackImageProviderProperties> entity, OpenStackImageProvider template) {
    OpenStackImageProvider model = template != null ? template : new OpenStackImageProvider();
    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);
    }
    OpenStackImageProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
    }
    return model;
}
Also used : OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider) Properties(org.ovirt.engine.api.model.Properties) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 2 with OpenStackImageProviderProperties

use of org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties in project ovirt-engine by oVirt.

the class ProviderDaoImpl method createFullParametersMapper.

@Override
protected MapSqlParameterSource createFullParametersMapper(Provider<?> entity) {
    MapSqlParameterSource mapper = createBaseProviderParametersMapper(entity);
    String tenantName = null;
    String pluginType = null;
    boolean readOnly = false;
    boolean autoSync = false;
    AgentConfiguration agentConfiguration = null;
    AdditionalProperties additionalProperties = null;
    if (entity.getAdditionalProperties() != null) {
        switch(entity.getType()) {
            case EXTERNAL_NETWORK:
            case OPENSTACK_NETWORK:
                OpenstackNetworkProviderProperties networkProperties = (OpenstackNetworkProviderProperties) entity.getAdditionalProperties();
                readOnly = networkProperties.getReadOnly();
                tenantName = networkProperties.getTenantName();
                pluginType = networkProperties.getPluginType();
                agentConfiguration = networkProperties.getAgentConfiguration();
                autoSync = networkProperties.getAutoSync();
                break;
            case OPENSTACK_IMAGE:
                OpenStackImageProviderProperties imageProperties = (OpenStackImageProviderProperties) entity.getAdditionalProperties();
                tenantName = imageProperties.getTenantName();
                break;
            case OPENSTACK_VOLUME:
                OpenStackVolumeProviderProperties volumeProperties = (OpenStackVolumeProviderProperties) entity.getAdditionalProperties();
                tenantName = volumeProperties.getTenantName();
                break;
            case VMWARE:
            case KVM:
            case XEN:
                additionalProperties = entity.getAdditionalProperties();
                break;
            default:
                break;
        }
    }
    // We always add the values since JdbcTeplate expects them to be set, otherwise it throws an exception.
    mapper.addValue("tenant_name", tenantName);
    mapper.addValue("plugin_type", pluginType);
    mapper.addValue("agent_configuration", SerializationFactory.getSerializer().serialize(agentConfiguration));
    mapper.addValue("additional_properties", SerializationFactory.getSerializer().serialize(additionalProperties));
    mapper.addValue("read_only", readOnly);
    mapper.addValue("auto_sync", autoSync);
    return mapper;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) AgentConfiguration(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration) OpenStackVolumeProviderProperties(org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties) AdditionalProperties(org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)

Example 3 with OpenStackImageProviderProperties

use of org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties in project ovirt-engine by oVirt.

the class ProviderModel method flush.

private void flush() {
    provider.setName(name.getEntity());
    provider.setType(type.getSelectedItem());
    provider.setDescription(description.getEntity());
    provider.setUrl(url.getEntity());
    provider.setIsUnmanaged(isUnmanaged.getEntity());
    if (isTypeNetwork()) {
        getNeutronAgentModel().flush(provider);
        OpenstackNetworkProviderProperties properties = (OpenstackNetworkProviderProperties) provider.getAdditionalProperties();
        properties.setReadOnly(readOnly.getEntity());
        properties.setAutoSync(autoSync.getEntity());
    } else if (isTypeOpenStackImage()) {
        provider.setAdditionalProperties(new OpenStackImageProviderProperties());
    } else if (isTypeOpenStackVolume()) {
        provider.setAdditionalProperties(new OpenStackVolumeProviderProperties(getDataCenter().getSelectedItem().getId()));
    } else if (isTypeVmware()) {
        provider.setAdditionalProperties(getVmwarePropertiesModel().getVmwareVmProviderProperties(dataCenter.getSelectedItem() != null ? dataCenter.getSelectedItem().getId() : null));
        provider.setUrl(getVmwarePropertiesModel().getUrl());
    } else if (isTypeKVM()) {
        provider.setUrl(getKvmPropertiesModel().getUrl().getEntity());
        provider.setAdditionalProperties(getKvmPropertiesModel().getKVMVmProviderProperties(dataCenter.getSelectedItem() != null ? dataCenter.getSelectedItem().getId() : null));
    } else if (isTypeXEN()) {
        provider.setUrl(getXenPropertiesModel().getUrl().getEntity());
        provider.setAdditionalProperties(getXenPropertiesModel().getXENVmProviderProperties(dataCenter.getSelectedItem() != null ? dataCenter.getSelectedItem().getId() : null));
    }
    boolean authenticationRequired = requiresAuthentication.getEntity();
    provider.setRequiringAuthentication(authenticationRequired);
    if (authenticationRequired) {
        provider.setUsername(getUsername().getEntity());
        provider.setPassword(getPassword().getEntity());
        if (getTenantName().getIsAvailable()) {
            TenantProviderProperties properties = (TenantProviderProperties) provider.getAdditionalProperties();
            if (properties == null) {
                properties = new TenantProviderProperties();
                provider.setAdditionalProperties(properties);
            }
            properties.setTenantName(getTenantName().getEntity());
        }
        provider.setAuthUrl(getAuthUrl().getEntity());
    } else {
        provider.setUsername(null);
        provider.setPassword(null);
        if (getTenantName().getIsAvailable()) {
            TenantProviderProperties properties = (TenantProviderProperties) provider.getAdditionalProperties();
            if (properties != null) {
                properties.setTenantName(null);
            }
        }
        provider.setAuthUrl(null);
    }
}
Also used : TenantProviderProperties(org.ovirt.engine.core.common.businessentities.TenantProviderProperties) OpenStackVolumeProviderProperties(org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)

Aggregations

OpenStackImageProviderProperties (org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)3 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)2 OpenStackVolumeProviderProperties (org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 OpenStackImageProvider (org.ovirt.engine.api.model.OpenStackImageProvider)1 Properties (org.ovirt.engine.api.model.Properties)1 Property (org.ovirt.engine.api.model.Property)1 Mapping (org.ovirt.engine.api.restapi.types.Mapping)1 AgentConfiguration (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration)1 AdditionalProperties (org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties)1 TenantProviderProperties (org.ovirt.engine.core.common.businessentities.TenantProviderProperties)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1