Search in sources :

Example 1 with Property

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());
}
Also used : Property(org.ovirt.engine.api.model.Property)

Example 2 with Property

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;
}
Also used : Properties(org.ovirt.engine.api.model.Properties) Map(java.util.Map) Property(org.ovirt.engine.api.model.Property) LinkLayerDiscoveryProtocolElement(org.ovirt.engine.api.model.LinkLayerDiscoveryProtocolElement)

Example 3 with Property

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;
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Properties(org.ovirt.engine.api.model.Properties) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.ovirt.engine.api.model.Property) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 4 with Property

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;
}
Also used : OpenStackImageProvider(org.ovirt.engine.api.model.OpenStackImageProvider) Properties(org.ovirt.engine.api.model.Properties) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) OpenStackImageProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 5 with Property

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;
}
Also used : Properties(org.ovirt.engine.api.model.Properties) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.ovirt.engine.api.model.Property) CustomProperty(org.ovirt.engine.api.model.CustomProperty)

Aggregations

Property (org.ovirt.engine.api.model.Property)6 Map (java.util.Map)5 Properties (org.ovirt.engine.api.model.Properties)5 HashMap (java.util.HashMap)4 Mapping (org.ovirt.engine.api.restapi.types.Mapping)3 CustomProperty (org.ovirt.engine.api.model.CustomProperty)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 LinkLayerDiscoveryProtocolElement (org.ovirt.engine.api.model.LinkLayerDiscoveryProtocolElement)1 OpenStackImageProvider (org.ovirt.engine.api.model.OpenStackImageProvider)1 OpenStackNetworkProvider (org.ovirt.engine.api.model.OpenStackNetworkProvider)1 OpenStackVolumeProvider (org.ovirt.engine.api.model.OpenStackVolumeProvider)1 OpenStackImageProviderProperties (org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)1 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)1 OpenStackVolumeProviderProperties (org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties)1