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