Search in sources :

Example 36 with Network

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

the class IscsiBondMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.IscsiBond.class, to = IscsiBond.class)
public static IscsiBond map(org.ovirt.engine.core.common.businessentities.IscsiBond from, IscsiBond to) {
    IscsiBond iscsiBond = (to != null) ? to : new IscsiBond();
    DataCenter dataCenter = new DataCenter();
    dataCenter.setId(from.getStoragePoolId().toString());
    iscsiBond.setDataCenter(dataCenter);
    iscsiBond.setName(from.getName());
    iscsiBond.setDescription(from.getDescription());
    if (from.getId() != null) {
        iscsiBond.setId(from.getId().toString());
    }
    Networks networks = new Networks();
    for (Guid id : from.getNetworkIds()) {
        Network network = new Network();
        network.setId(id.toString());
        networks.getNetworks().add(network);
    }
    iscsiBond.setNetworks(networks);
    StorageConnections connections = new StorageConnections();
    for (String id : from.getStorageConnectionIds()) {
        StorageConnection conn = new StorageConnection();
        conn.setId(id);
        connections.getStorageConnections().add(conn);
    }
    iscsiBond.setStorageConnections(connections);
    return iscsiBond;
}
Also used : Networks(org.ovirt.engine.api.model.Networks) DataCenter(org.ovirt.engine.api.model.DataCenter) Network(org.ovirt.engine.api.model.Network) IscsiBond(org.ovirt.engine.api.model.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) StorageConnections(org.ovirt.engine.api.model.StorageConnections)

Example 37 with Network

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

the class NetworkAttachmentMapper method getModelNetwork.

private static Network getModelNetwork(NetworkAttachment model) {
    Network network = model.getNetwork();
    if (network == null) {
        network = new Network();
        model.setNetwork(network);
    }
    return network;
}
Also used : Network(org.ovirt.engine.api.model.Network)

Example 38 with Network

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

the class NetworkAttachmentMapper method map.

@Mapping(from = NetworkAttachment.class, to = org.ovirt.engine.core.common.businessentities.network.NetworkAttachment.class)
public static org.ovirt.engine.core.common.businessentities.network.NetworkAttachment map(NetworkAttachment model, org.ovirt.engine.core.common.businessentities.network.NetworkAttachment template) {
    org.ovirt.engine.core.common.businessentities.network.NetworkAttachment entity = template == null ? new org.ovirt.engine.core.common.businessentities.network.NetworkAttachment() : template;
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetNetwork()) {
        Network networkModel = model.getNetwork();
        if (networkModel.isSetId()) {
            entity.setNetworkId(GuidUtils.asGuid(networkModel.getId()));
        }
        if (networkModel.isSetName()) {
            entity.setNetworkName(networkModel.getName());
        }
    }
    if (model.isSetHostNic()) {
        HostNic hostNic = model.getHostNic();
        if (hostNic.isSetId()) {
            entity.setNicId(GuidUtils.asGuid(hostNic.getId()));
        } else {
            entity.setNicId(null);
        }
        if (hostNic.isSetName()) {
            entity.setNicName(hostNic.getName());
        } else {
            entity.setNicName(null);
        }
    }
    if (model.isSetProperties()) {
        entity.setProperties(CustomPropertiesParser.toMap(model.getProperties()));
    }
    if (model.isSetIpAddressAssignments()) {
        entity.setIpConfiguration(new org.ovirt.engine.core.common.businessentities.network.IpConfiguration());
        IpAddressAssignments ipAddressAssignments = model.getIpAddressAssignments();
        entity.getIpConfiguration().setIPv4Addresses(new ArrayList<>());
        entity.getIpConfiguration().setIpV6Addresses(new ArrayList<>());
        for (IpAddressAssignment ipAddressAssignment : ipAddressAssignments.getIpAddressAssignments()) {
            if (IpVersion.V6 == getIpVersion(ipAddressAssignment)) {
                entity.getIpConfiguration().getIpV6Addresses().add(mapIpv6AddressAssignment(ipAddressAssignment));
            } else {
                entity.getIpConfiguration().getIPv4Addresses().add(mapIpv4AddressAssignment(ipAddressAssignment));
            }
        }
    }
    if (model.isSetDnsResolverConfiguration()) {
        entity.setDnsResolverConfiguration(DnsResolverConfigurationMapper.map(entity.getDnsResolverConfiguration(), model.getDnsResolverConfiguration()));
    }
    if (model.isSetQos()) {
        HostNetworkQos hostNetworkQos = (HostNetworkQos) QosMapper.map(model.getQos(), null);
        entity.setHostNetworkQos(AnonymousHostNetworkQos.fromHostNetworkQos(hostNetworkQos));
    }
    return entity;
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) HostNic(org.ovirt.engine.api.model.HostNic) Network(org.ovirt.engine.api.model.Network) IpAddressAssignments(org.ovirt.engine.api.model.IpAddressAssignments) IpAddressAssignment(org.ovirt.engine.api.model.IpAddressAssignment)

Example 39 with Network

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

the class BackendHostNicsResource method setCustomProperties.

private void setCustomProperties(Map<Guid, NetworkAttachment> attachmentsByNetworkId, Map<String, Guid> networkNameToNetworkIdMap, HostNic hostNic) {
    Network network = hostNic.getNetwork();
    if (network == null) {
        return;
    }
    String networkName = network.getName();
    NetworkAttachment networkAttachment = attachmentsByNetworkId.get(networkNameToNetworkIdMap.get(networkName));
    if (networkAttachment == null) {
        return;
    }
    Map<String, String> properties = networkAttachment.getProperties();
    if (properties != null) {
        hostNic.setProperties(CustomPropertiesParser.fromMap(properties));
    }
}
Also used : Network(org.ovirt.engine.api.model.Network) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 40 with Network

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

the class BackendNetworkLabelResource method get.

@Override
public NetworkLabel get() {
    NetworkLabels labels = parent.list();
    if (labels != null) {
        for (NetworkLabel label : labels.getNetworkLabels()) {
            if (label.getId().equals(id)) {
                label.setNetwork(new Network());
                label.getNetwork().setId(parent.getNetworkId().toString());
                return addLinks(label);
            }
        }
    }
    return notFound();
}
Also used : NetworkLabels(org.ovirt.engine.api.model.NetworkLabels) Network(org.ovirt.engine.api.model.Network) NetworkLabel(org.ovirt.engine.api.model.NetworkLabel)

Aggregations

Network (org.ovirt.engine.api.model.Network)45 Test (org.junit.Test)16 WebApplicationException (javax.ws.rs.WebApplicationException)9 Response (javax.ws.rs.core.Response)6 DataCenter (org.ovirt.engine.api.model.DataCenter)6 VnicProfile (org.ovirt.engine.api.model.VnicProfile)5 V3Network (org.ovirt.engine.api.v3.types.V3Network)4 Guid (org.ovirt.engine.core.compat.Guid)4 Networks (org.ovirt.engine.api.model.Networks)3 V3Networks (org.ovirt.engine.api.v3.types.V3Networks)3 V3PortMirroring (org.ovirt.engine.api.v3.types.V3PortMirroring)3 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 HostNic (org.ovirt.engine.api.model.HostNic)2 NetworkLabels (org.ovirt.engine.api.model.NetworkLabels)2 Nic (org.ovirt.engine.api.model.Nic)2 ClusterNetworksResource (org.ovirt.engine.api.resource.ClusterNetworksResource)2 NetworkResource (org.ovirt.engine.api.resource.NetworkResource)2 NetworksResource (org.ovirt.engine.api.resource.NetworksResource)2 SystemResource (org.ovirt.engine.api.resource.SystemResource)2 VnicProfileResource (org.ovirt.engine.api.resource.VnicProfileResource)2