Search in sources :

Example 1 with AdditionalProperties

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

the class ProviderDaoTest method generateNewEntity.

@Override
protected Provider<?> generateNewEntity() {
    Provider<AdditionalProperties> provider = new Provider<>();
    provider.setId(generateNonExistingId());
    provider.setName("brovider");
    provider.setUrl("http://brovider.com/");
    provider.setType(ProviderType.OPENSTACK_NETWORK);
    OpenstackNetworkProviderProperties additionalProperties = new OpenstackNetworkProviderProperties();
    additionalProperties.setReadOnly(Boolean.FALSE);
    additionalProperties.setTenantName("10ant");
    additionalProperties.setPluginType(OpenstackNetworkPluginType.OPEN_VSWITCH.name());
    provider.setAdditionalProperties(additionalProperties);
    provider.setAuthUrl("http://keystone-server:35357/v2.0/");
    return provider;
}
Also used : AdditionalProperties(org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Provider(org.ovirt.engine.core.common.businessentities.Provider)

Example 2 with AdditionalProperties

use of org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties 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 AdditionalProperties

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

the class ProviderValidatorTest method testValidateReadOnlyActions.

@Test
public void testValidateReadOnlyActions() {
    String providerName = "providerName";
    OpenstackNetworkProviderProperties additionalProperties = new OpenstackNetworkProviderProperties();
    additionalProperties.setReadOnly(true);
    Provider<AdditionalProperties> provider = new Provider<>();
    provider.setAdditionalProperties(additionalProperties);
    provider.setType(ProviderType.EXTERNAL_NETWORK);
    provider.setName(providerName);
    ProviderValidator validator = new ProviderValidator(provider);
    EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_EXTERNAL_PROVIDER_IS_READ_ONLY;
    assertThat(validator.validateReadOnlyActions(), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, providerName)));
    additionalProperties.setReadOnly(false);
    assertThat(validator.validateReadOnlyActions(), isValid());
    provider.setType(ProviderType.OPENSTACK_NETWORK);
    assertThat(validator.validateReadOnlyActions(), isValid());
}
Also used : AdditionalProperties(org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Provider(org.ovirt.engine.core.common.businessentities.Provider) Test(org.junit.Test)

Aggregations

OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)3 AdditionalProperties (org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties)3 Provider (org.ovirt.engine.core.common.businessentities.Provider)2 Test (org.junit.Test)1 OpenStackImageProviderProperties (org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)1 AgentConfiguration (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration)1 OpenStackVolumeProviderProperties (org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties)1 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1