use of org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration in project ovirt-engine by oVirt.
the class NeutronAgentModel method flush.
public void flush(Provider<OpenstackNetworkProviderProperties> provider) {
OpenstackNetworkProviderProperties properties = provider.getAdditionalProperties();
if (properties == null) {
properties = new OpenstackNetworkProviderProperties();
provider.setAdditionalProperties(properties);
}
properties.setPluginType(NetworkProviderPluginTranslator.getPluginNameForDisplayString(getPluginType().getSelectedItem()));
if (!isPluginConfigurationAvailable().getEntity()) {
properties.setAgentConfiguration(null);
} else {
AgentConfiguration agentConfiguration = properties.getAgentConfiguration();
if (agentConfiguration == null) {
agentConfiguration = new AgentConfiguration();
properties.setAgentConfiguration(agentConfiguration);
}
agentConfiguration.setNetworkMappings(getInterfaceMappings().getEntity());
MessagingConfiguration messagingConfiguration = agentConfiguration.getMessagingConfiguration();
if (messagingConfiguration == null) {
messagingConfiguration = new MessagingConfiguration();
agentConfiguration.setMessagingConfiguration(messagingConfiguration);
}
messagingConfiguration.setAddress(getMessagingServer().getEntity());
String port = getMessagingServerPort().getEntity();
messagingConfiguration.setPort(port == null ? null : Integer.valueOf(port));
messagingConfiguration.setUsername(getMessagingServerUsername().getEntity());
messagingConfiguration.setPassword(getMessagingServerPassword().getEntity());
messagingConfiguration.setBrokerType(getBrokerType().getSelectedItem());
}
}
use of org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration in project ovirt-engine by oVirt.
the class NeutronAgentModel method init.
public void init(Provider<OpenstackNetworkProviderProperties> provider, ProviderType type) {
OpenstackNetworkProviderProperties properties = provider.getAdditionalProperties();
NetworkProviderPluginTranslator translator = NetworkProviderPluginTranslator.getTranslatorByProviderType(type);
String pluginName = translator.getDisplayStringForPluginName(properties == null ? translator.getDefault() : properties.getPluginType());
List<String> displayItems = translator.getPresetDisplayStrings();
getPluginType().setItems(displayItems);
getPluginType().setSelectedItem(pluginName);
pluginValidator = translator.getPluginValidator();
if (properties != null) {
AgentConfiguration agentConfiguration = properties.getAgentConfiguration();
if (agentConfiguration != null) {
getInterfaceMappings().setEntity(agentConfiguration.getNetworkMappings());
MessagingConfiguration messagingConfiguration = agentConfiguration.getMessagingConfiguration();
if (messagingConfiguration != null) {
getBrokerType().setSelectedItem(messagingConfiguration.getBrokerType());
getMessagingServer().setEntity(messagingConfiguration.getAddress());
Integer port = messagingConfiguration.getPort();
getMessagingServerPort().setEntity(port == null ? null : Integer.toString(port));
getMessagingServerUsername().setEntity(messagingConfiguration.getUsername());
getMessagingServerPassword().setEntity(messagingConfiguration.getPassword());
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration 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.OpenstackNetworkProviderProperties.AgentConfiguration in project ovirt-engine by oVirt.
the class NetworkProviderValidatorTest method mockProviderAdditionalProperties.
private void mockProviderAdditionalProperties() {
AgentConfiguration agentConfiguration = mock(AgentConfiguration.class);
OpenstackNetworkProviderProperties properties = mock(OpenstackNetworkProviderProperties.class);
when(properties.getAgentConfiguration()).thenReturn(agentConfiguration);
when(provider.getAdditionalProperties()).thenReturn(properties);
}
Aggregations