Search in sources :

Example 21 with Network

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

the class BackendDataCenterNetworksResourceTest method doTestBadAddNetwork.

private void doTestBadAddNetwork(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddNetwork, AddNetworkStoragePoolParameters.class, new String[] { "StoragePoolId" }, new Object[] { DATA_CENTER_ID }, valid, success));
    Network model = getModel(0);
    model.setDataCenter(new DataCenter());
    model.getDataCenter().setId(DATA_CENTER_ID.toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) WebApplicationException(javax.ws.rs.WebApplicationException) AddNetworkStoragePoolParameters(org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters) Network(org.ovirt.engine.api.model.Network)

Example 22 with Network

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

the class AbstractBackendNetworksResourceTest method getEntity.

@Override
protected org.ovirt.engine.core.common.businessentities.network.Network getEntity(int index) {
    org.ovirt.engine.core.common.businessentities.network.Network network = new org.ovirt.engine.core.common.businessentities.network.Network();
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setDisplay(false);
    networkCluster.setMigration(false);
    networkCluster.setRequired(false);
    networkCluster.setDefaultRoute(false);
    network.setCluster(networkCluster);
    network.setId(GUIDS[index]);
    network.setName(NAMES[index]);
    network.setDescription(DESCRIPTIONS[index]);
    network.setDataCenterId(GUIDS[1]);
    return network;
}
Also used : Network(org.ovirt.engine.api.model.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 23 with Network

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

the class AbstractBackendVnicProfilesResourceTest method testAddVnicProfile.

@Test
public void testAddVnicProfile() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpNetworkQueryExpectations();
    setUpCreationExpectations(ActionType.AddVnicProfile, AddVnicProfileParameters.class, new String[] {}, new Object[] {}, true, true, GUIDS[0], QueryType.GetVnicProfileById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { Guid.Empty }, getEntity(0));
    VnicProfile model = getModel(0);
    model.setNetwork(new Network());
    model.getNetwork().setId(NETWORK_ID.toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof VnicProfile);
    verifyModel((VnicProfile) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) Network(org.ovirt.engine.api.model.Network) VnicProfile(org.ovirt.engine.api.model.VnicProfile) Test(org.junit.Test)

Example 24 with Network

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

the class LinkHelperTest method testClusterNetworkLinks.

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

Example 25 with Network

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

the class IscsiBondMapperTest method verifyNetworks.

private static void verifyNetworks(Networks before, Networks after) {
    if (before == null) {
        assertNull(after);
    } else {
        assertEquals(before.getNetworks().size(), after.getNetworks().size());
        Set<String> ids = new HashSet<>();
        for (Network network : before.getNetworks()) {
            ids.add(network.getId());
        }
        for (Network network : after.getNetworks()) {
            ids.remove(network.getId());
        }
        assertEquals(0, ids.size());
    }
}
Also used : Network(org.ovirt.engine.api.model.Network) HashSet(java.util.HashSet)

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