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;
}
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;
}
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());
}
Aggregations