Search in sources :

Example 26 with Network

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

the class BackendVirtualFunctionAllowedNetworkResource method get.

@Override
public Network get() {
    final Networks networks = getParent().list();
    final Network network = networks.getNetworks().stream().filter(n -> n.getId().equals(id)).findFirst().orElse(null);
    if (network == null) {
        notFound();
    }
    return network;
}
Also used : Networks(org.ovirt.engine.api.model.Networks) Network(org.ovirt.engine.api.model.Network)

Example 27 with Network

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

the class BackendVirtualFunctionAllowedNetworksResource method list.

@Override
public Networks list() {
    final Set<Guid> networkIds = loadVfAllowedNetworks();
    final Networks networks = new Networks();
    for (Guid networkId : networkIds) {
        final Network network = new Network();
        network.setId(networkId.toString());
        networks.getNetworks().add(network);
        addLinks(network);
    }
    return networks;
}
Also used : Networks(org.ovirt.engine.api.model.Networks) Network(org.ovirt.engine.api.model.Network) Guid(org.ovirt.engine.core.compat.Guid)

Example 28 with Network

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

the class VnicProfileMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.network.VnicProfile.class, to = VnicProfile.class)
public static VnicProfile map(org.ovirt.engine.core.common.businessentities.network.VnicProfile entity, VnicProfile template) {
    VnicProfile model = template != null ? template : new VnicProfile();
    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.getNetworkId() != null) {
        model.setNetwork(new Network());
        model.getNetwork().setId(entity.getNetworkId().toString());
    }
    model.setPortMirroring(entity.isPortMirroring());
    if (entity.getCustomProperties() != null && !entity.getCustomProperties().isEmpty()) {
        CustomProperties hooks = new CustomProperties();
        hooks.getCustomProperties().addAll(CustomPropertiesParser.parse(DevicePropertiesUtils.getInstance().convertProperties(entity.getCustomProperties()), false));
        model.setCustomProperties(hooks);
    }
    if (entity.getNetworkQosId() != null) {
        model.setQos(new Qos());
        model.getQos().setId(entity.getNetworkQosId().toString());
    }
    final VnicPassThrough vnicPassThrough = new VnicPassThrough();
    vnicPassThrough.setMode(map(entity.isPassthrough()));
    model.setPassThrough(vnicPassThrough);
    if (entity.getNetworkFilterId() != null) {
        model.setNetworkFilter(new NetworkFilter());
        model.getNetworkFilter().setId(entity.getNetworkFilterId().toString());
    }
    if (entity.isPassthrough()) {
        model.setMigratable(entity.isMigratable());
    }
    return model;
}
Also used : VnicPassThrough(org.ovirt.engine.api.model.VnicPassThrough) Qos(org.ovirt.engine.api.model.Qos) Network(org.ovirt.engine.api.model.Network) NetworkFilter(org.ovirt.engine.api.model.NetworkFilter) VnicProfile(org.ovirt.engine.api.model.VnicProfile) CustomProperties(org.ovirt.engine.api.model.CustomProperties)

Example 29 with Network

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

the class LinkHelperTest method testNetworkLinks.

@Test
public void testNetworkLinks() throws Exception {
    Network network = new Network();
    network.setId(NETWORK_ID);
    LinkHelper.addLinks(network);
    assertEquals(NETWORK_HREF, network.getHref());
}
Also used : Network(org.ovirt.engine.api.model.Network) Test(org.junit.Test)

Example 30 with Network

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

the class BackendAssignedVnicProfilesResource method add.

@Override
public Response add(VnicProfile vnicProfile) {
    if (!vnicProfile.isSetNetwork() || !vnicProfile.getNetwork().isSetId()) {
        vnicProfile.setNetwork(new Network());
        vnicProfile.getNetwork().setId(networkId);
    }
    return super.add(vnicProfile);
}
Also used : Network(org.ovirt.engine.api.model.Network)

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