Search in sources :

Example 1 with Properties

use of org.ovirt.engine.api.model.Properties in project ovirt-engine by oVirt.

the class V3ExternalHostProviderInAdapter method adapt.

@Override
public ExternalHostProvider adapt(V3ExternalHostProvider from) {
    ExternalHostProvider to = new ExternalHostProvider();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetAuthenticationUrl()) {
        to.setAuthenticationUrl(from.getAuthenticationUrl());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetPassword()) {
        to.setPassword(from.getPassword());
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    if (from.isSetRequiresAuthentication()) {
        to.setRequiresAuthentication(from.isRequiresAuthentication());
    }
    if (from.isSetUrl()) {
        to.setUrl(from.getUrl());
    }
    if (from.isSetUsername()) {
        to.setUsername(from.getUsername());
    }
    return to;
}
Also used : V3ExternalHostProvider(org.ovirt.engine.api.v3.types.V3ExternalHostProvider) ExternalHostProvider(org.ovirt.engine.api.model.ExternalHostProvider) Properties(org.ovirt.engine.api.model.Properties)

Example 2 with Properties

use of org.ovirt.engine.api.model.Properties 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 Properties

use of org.ovirt.engine.api.model.Properties 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 Properties

use of org.ovirt.engine.api.model.Properties in project ovirt-engine by oVirt.

the class V3OpenStackNetworkProviderInAdapter method adapt.

@Override
public OpenStackNetworkProvider adapt(V3OpenStackNetworkProvider from) {
    OpenStackNetworkProvider to = new OpenStackNetworkProvider();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetAgentConfiguration()) {
        to.setAgentConfiguration(adaptIn(from.getAgentConfiguration()));
    }
    if (from.isSetAuthenticationUrl()) {
        to.setAuthenticationUrl(from.getAuthenticationUrl());
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetPassword()) {
        to.setPassword(from.getPassword());
    }
    if (from.isSetPluginType()) {
        to.setPluginType(NetworkPluginType.fromValue(from.getPluginType()));
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    if (from.isSetRequiresAuthentication()) {
        to.setRequiresAuthentication(from.isRequiresAuthentication());
    }
    if (from.isSetTenantName()) {
        to.setTenantName(from.getTenantName());
    }
    if (from.isSetUrl()) {
        to.setUrl(from.getUrl());
    }
    if (from.isSetUsername()) {
        to.setUsername(from.getUsername());
    }
    to.setType(OpenStackNetworkProviderType.NEUTRON);
    return to;
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) V3OpenStackNetworkProvider(org.ovirt.engine.api.v3.types.V3OpenStackNetworkProvider) Properties(org.ovirt.engine.api.model.Properties)

Example 5 with Properties

use of org.ovirt.engine.api.model.Properties in project ovirt-engine by oVirt.

the class V3OpenStackVolumeTypeInAdapter method adapt.

@Override
public OpenStackVolumeType adapt(V3OpenStackVolumeType from) {
    OpenStackVolumeType to = new OpenStackVolumeType();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetOpenstackVolumeProvider()) {
        to.setOpenstackVolumeProvider(adaptIn(from.getOpenstackVolumeProvider()));
    }
    if (from.isSetProperties()) {
        to.setProperties(new Properties());
        to.getProperties().getProperties().addAll(adaptIn(from.getProperties().getProperties()));
    }
    return to;
}
Also used : OpenStackVolumeType(org.ovirt.engine.api.model.OpenStackVolumeType) V3OpenStackVolumeType(org.ovirt.engine.api.v3.types.V3OpenStackVolumeType) Properties(org.ovirt.engine.api.model.Properties)

Aggregations

Properties (org.ovirt.engine.api.model.Properties)18 Map (java.util.Map)5 Property (org.ovirt.engine.api.model.Property)5 HashMap (java.util.HashMap)4 Mapping (org.ovirt.engine.api.restapi.types.Mapping)3 OpenStackImageProvider (org.ovirt.engine.api.model.OpenStackImageProvider)2 OpenStackNetworkProvider (org.ovirt.engine.api.model.OpenStackNetworkProvider)2 OpenStackVolumeProvider (org.ovirt.engine.api.model.OpenStackVolumeProvider)2 SchedulingPolicy (org.ovirt.engine.api.model.SchedulingPolicy)2 V3SchedulingPolicy (org.ovirt.engine.api.v3.types.V3SchedulingPolicy)2 V3SchedulingPolicyThresholds (org.ovirt.engine.api.v3.types.V3SchedulingPolicyThresholds)2 WebApplicationException (javax.ws.rs.WebApplicationException)1 CustomProperty (org.ovirt.engine.api.model.CustomProperty)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 ExternalHostProvider (org.ovirt.engine.api.model.ExternalHostProvider)1 ExternalProvider (org.ovirt.engine.api.model.ExternalProvider)1 HostNic (org.ovirt.engine.api.model.HostNic)1 IpAddressAssignments (org.ovirt.engine.api.model.IpAddressAssignments)1 LinkLayerDiscoveryProtocolElement (org.ovirt.engine.api.model.LinkLayerDiscoveryProtocolElement)1 NetworkAttachment (org.ovirt.engine.api.model.NetworkAttachment)1