use of org.ovirt.engine.api.model.Property in project ovirt-engine by oVirt.
the class BackendLinkLayerDiscoveryProtocolResourceTest method verifyModel.
@Override
protected void verifyModel(LinkLayerDiscoveryProtocolElement model, int index) {
assertEquals(NAMES[index], model.getName());
assertEquals(getType(index), model.getType().intValue());
assertEquals(getOui(index), model.getOui().intValue());
assertEquals(getSubType(index), model.getSubtype().intValue());
List<Property> properties = model.getProperties().getProperties();
assertEquals(1, properties.size());
Property property = properties.get(0);
assertEquals(PROPERTY_NAME, properties.get(0).getName());
assertEquals(getPropertyValue(index), properties.get(0).getValue());
}
use of org.ovirt.engine.api.model.Property in project ovirt-engine by oVirt.
the class LinkLayerDiscoveryProtocolElementMapper method map.
@Mapping(from = Tlv.class, to = LinkLayerDiscoveryProtocolElement.class)
public static LinkLayerDiscoveryProtocolElement map(Tlv entity, LinkLayerDiscoveryProtocolElement template) {
LinkLayerDiscoveryProtocolElement model = template != null ? template : new LinkLayerDiscoveryProtocolElement();
model.setName(entity.getName());
model.setType(entity.getType());
model.setOui(entity.getOui());
model.setSubtype(entity.getSubtype());
Properties properties = new Properties();
for (Map.Entry<String, String> entry : entity.getProperties().entrySet()) {
Property property = new Property();
property.setName(entry.getKey());
property.setValue(entry.getValue());
properties.getProperties().add(property);
}
model.setProperties(properties);
return model;
}
use of org.ovirt.engine.api.model.Property in project ovirt-engine by oVirt.
the class OpenStackNetworkProviderMapper method map.
@Mapping(from = Provider.class, to = OpenStackNetworkProvider.class)
public static OpenStackNetworkProvider map(Provider<OpenstackNetworkProviderProperties> entity, OpenStackNetworkProvider template) {
OpenStackNetworkProvider model = template != null ? template : new OpenStackNetworkProvider();
model.setType(mapProviderType(entity.getType()));
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.setUnmanaged(entity.getIsUnmanaged());
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);
}
OpenstackNetworkProviderProperties additionalProperties = entity.getAdditionalProperties();
if (additionalProperties != null) {
if (additionalProperties.getTenantName() != null) {
model.setTenantName(additionalProperties.getTenantName());
}
String pluginType = additionalProperties.getPluginType();
if (pluginType != null) {
// for backwards compatibility, and should be removed in version 5 of the API.
if (entity.getType() == ProviderType.OPENSTACK_NETWORK && OpenstackNetworkPluginType.OPEN_VSWITCH.name().equalsIgnoreCase(pluginType)) {
model.setPluginType(NetworkPluginType.OPEN_VSWITCH);
}
model.setExternalPluginType(additionalProperties.getPluginType());
}
if (additionalProperties.getAgentConfiguration() != null) {
model.setAgentConfiguration(map(additionalProperties.getAgentConfiguration(), null));
}
model.setReadOnly(additionalProperties.getReadOnly());
model.setAutoSync(additionalProperties.getAutoSync());
}
return model;
}
use of org.ovirt.engine.api.model.Property 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.api.model.Property in project ovirt-engine by oVirt.
the class CustomPropertiesParser method fromMap.
/**
* Create a Properties object from a map containing key:value pairs.
*
* @param properties
* The map containing key:value pairs.
* @return A newly-created Properties object containing the key:value pairs.
*/
public static Properties fromMap(Map<String, String> properties) {
Properties res = new Properties();
for (Map.Entry<String, String> entry : properties.entrySet()) {
Property property = new Property();
property.setName(entry.getKey());
property.setValue(entry.getValue());
res.getProperties().add(property);
}
return res;
}
Aggregations