Search in sources :

Example 6 with Nic

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

the class V3NICInAdapter method adapt.

@Override
public Nic adapt(V3NIC from) {
    Nic to = new Nic();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetBootProtocol()) {
        to.setBootProtocol(BootProtocol.fromValue(from.getBootProtocol()));
    }
    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.isSetInstanceType()) {
        to.setInstanceType(adaptIn(from.getInstanceType()));
    }
    if (from.isSetInterface()) {
        to.setInterface(NicInterface.fromValue(from.getInterface()));
    }
    if (from.isSetLinked()) {
        to.setLinked(from.isLinked());
    }
    if (from.isSetMac()) {
        to.setMac(adaptIn(from.getMac()));
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNetwork()) {
        to.setNetwork(adaptIn(from.getNetwork()));
    }
    if (from.isSetOnBoot()) {
        to.setOnBoot(from.isOnBoot());
    }
    if (from.isSetPlugged()) {
        to.setPlugged(from.isPlugged());
    }
    if (from.isSetReportedDevices()) {
        to.setReportedDevices(new ReportedDevices());
        to.getReportedDevices().getReportedDevices().addAll(adaptIn(from.getReportedDevices().getReportedDevices()));
    }
    if (from.isSetStatistics()) {
        to.setStatistics(new Statistics());
        to.getStatistics().getStatistics().addAll(adaptIn(from.getStatistics().getStatistics()));
    }
    if (from.isSetTemplate()) {
        to.setTemplate(adaptIn(from.getTemplate()));
    }
    if (from.isSetVm()) {
        to.setVm(adaptIn(from.getVm()));
    }
    if (from.isSetVms()) {
        to.setVms(new Vms());
        to.getVms().getVms().addAll(adaptIn(from.getVms().getVMs()));
    }
    if (from.isSetVnicProfile()) {
        to.setVnicProfile(adaptIn(from.getVnicProfile()));
    }
    // In V3 the "active" property used to be a synonym of "plugged":
    if (from.isSetActive() && to.isSetPlugged()) {
        to.setPlugged(from.isActive());
    }
    return to;
}
Also used : Nic(org.ovirt.engine.api.model.Nic) ReportedDevices(org.ovirt.engine.api.model.ReportedDevices) Statistics(org.ovirt.engine.api.model.Statistics) Vms(org.ovirt.engine.api.model.Vms)

Example 7 with Nic

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

the class BackendTemplateNicsResourceTest method testAddIncompleteParameters.

@Test
public void testAddIncompleteParameters() throws Exception {
    Nic model = new Nic();
    model.setName(null);
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Nic", "add", "name");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Nic(org.ovirt.engine.api.model.Nic) Test(org.junit.Test)

Example 8 with Nic

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

the class BackendTemplateNicsResourceTest method testAddNic.

@Test
public void testAddNic() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddVmTemplateInterface, AddVmTemplateInterfaceParameters.class, new String[] {}, new Object[] {}, true, true, null, QueryType.GetTemplateInterfacesByTemplateId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { VM_ID }, asList(getEntity(0)));
    Nic model = getModel(0);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Nic);
    verifyModel((Nic) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) Nic(org.ovirt.engine.api.model.Nic) Test(org.junit.Test)

Example 9 with Nic

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

the class BackendVmNicResourceTest method testStatisticalQuery.

@Test
public void testStatisticalQuery() throws Exception {
    VmNetworkInterface entity = setUpStatisticalExpectations();
    @SuppressWarnings("unchecked") BackendStatisticsResource<Nic, VmNetworkInterface> statisticsResource = (BackendStatisticsResource<Nic, VmNetworkInterface>) resource.getStatisticsResource();
    assertNotNull(statisticsResource);
    verifyQuery(statisticsResource.getQuery(), entity);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Nic(org.ovirt.engine.api.model.Nic) Test(org.junit.Test)

Example 10 with Nic

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

the class BackendVmNicResourceTest method getNic.

protected Nic getNic(boolean withNetwork) {
    Nic nic = new Nic();
    nic.setMac(new Mac());
    nic.getMac().setAddress("00:1a:4a:16:85:18");
    if (withNetwork) {
        Network network = new Network();
        network.setId(GUIDS[0].toString());
    }
    Network network = new Network();
    network.setId(GUIDS[0].toString());
    return nic;
}
Also used : Network(org.ovirt.engine.api.model.Network) Nic(org.ovirt.engine.api.model.Nic) Mac(org.ovirt.engine.api.model.Mac)

Aggregations

Nic (org.ovirt.engine.api.model.Nic)33 Test (org.junit.Test)11 WebApplicationException (javax.ws.rs.WebApplicationException)8 Vm (org.ovirt.engine.api.model.Vm)6 Nics (org.ovirt.engine.api.model.Nics)5 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)4 Response (javax.ws.rs.core.Response)3 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)3 ArrayList (java.util.ArrayList)2 Mac (org.ovirt.engine.api.model.Mac)2 Network (org.ovirt.engine.api.model.Network)2 ReportedDevices (org.ovirt.engine.api.model.ReportedDevices)2 VnicProfile (org.ovirt.engine.api.model.VnicProfile)2 SystemResource (org.ovirt.engine.api.resource.SystemResource)2 VmResource (org.ovirt.engine.api.resource.VmResource)2 VmsResource (org.ovirt.engine.api.resource.VmsResource)2 AddVmInterfaceParameters (org.ovirt.engine.core.common.action.AddVmInterfaceParameters)2 AddVmTemplateInterfaceParameters (org.ovirt.engine.core.common.action.AddVmTemplateInterfaceParameters)2 Comparator.comparing (java.util.Comparator.comparing)1 Objects (java.util.Objects)1