Search in sources :

Example 31 with Nic

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

the class BackendVmNicsResourceTest method doTestBadAddNic.

private void doTestBadAddNic(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddVmInterface, AddVmInterfaceParameters.class, new String[] { "VmId" }, new Object[] { VM_ID }, valid, success));
    Nic model = getModel(0);
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Nic(org.ovirt.engine.api.model.Nic) AddVmInterfaceParameters(org.ovirt.engine.core.common.action.AddVmInterfaceParameters)

Example 32 with Nic

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

the class BackendInstanceTypeNicsResource method list.

public Nics list() {
    Nics nics = new Nics();
    List<VmNetworkInterface> entities = getBackendCollection(QueryType.GetTemplateInterfacesByTemplateId, new IdQueryParameters(instanceTypeId));
    for (VmNetworkInterface entity : entities) {
        Nic nic = populate(map(entity), entity);
        nics.getNics().add(addLinks(nic));
    }
    return nics;
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Nic(org.ovirt.engine.api.model.Nic) Nics(org.ovirt.engine.api.model.Nics)

Example 33 with Nic

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

the class V3VmNicsServer method add.

@POST
@Consumes({ "application/xml", "application/json" })
public Response add(V3NIC v3Nic) {
    // Convert the NIC to the V4 format:
    Nic v4Nic = adaptIn(v3Nic);
    // Populate the VNIC profile (note that this can't be done in the adapter because in order to determine the
    // candidate VNIC profiles we need to know the identifier of the VM, and that isn't possible in the adapter):
    setVnicProfile(vmId, v3Nic, v4Nic);
    // VNIC profile, as the V4 server will detect/report/handle the issue better than we can do here):
    try {
        return adaptResponse(getDelegate().add(v4Nic));
    } catch (WebApplicationException exception) {
        throw adaptException(exception);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Nic(org.ovirt.engine.api.model.Nic) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

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