Search in sources :

Example 6 with VnicProfile

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

the class BackendVnicProfilesResourceTest method createIncompleteVnicProfile.

@Override
protected VnicProfile createIncompleteVnicProfile() {
    VnicProfile vnicProfile = super.createIncompleteVnicProfile();
    vnicProfile.setName(NAMES[0]);
    return vnicProfile;
}
Also used : VnicProfile(org.ovirt.engine.api.model.VnicProfile)

Example 7 with VnicProfile

use of org.ovirt.engine.api.model.VnicProfile 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 8 with VnicProfile

use of org.ovirt.engine.api.model.VnicProfile 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 9 with VnicProfile

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

the class BackendVnicProfileResourceTest method getModel.

static VnicProfile getModel(int index) {
    VnicProfile model = new VnicProfile();
    model.setId(GUIDS[index].toString());
    model.setName(NAMES[index]);
    model.setDescription(DESCRIPTIONS[index]);
    return model;
}
Also used : VnicProfile(org.ovirt.engine.api.model.VnicProfile)

Example 10 with VnicProfile

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

the class NicMapper method map.

@Mapping(from = VmNetworkInterface.class, to = Nic.class)
public static Nic map(VmNetworkInterface entity, Nic template) {
    Nic model = template != null ? template : new Nic();
    if (entity.getVmId() != null) {
        model.setVm(new Vm());
        model.getVm().setId(entity.getVmId().toString());
    }
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getMacAddress() != null) {
        model.setMac(new Mac());
        model.getMac().setAddress(entity.getMacAddress());
    }
    model.setLinked(entity.isLinked());
    model.setInterface(map(entity.getType()));
    model.setPlugged(entity.isPlugged());
    if (entity.getVnicProfileId() != null) {
        model.setVnicProfile(new VnicProfile());
        model.getVnicProfile().setId(entity.getVnicProfileId().toString());
    }
    return model;
}
Also used : Vm(org.ovirt.engine.api.model.Vm) VnicProfile(org.ovirt.engine.api.model.VnicProfile) Nic(org.ovirt.engine.api.model.Nic) Mac(org.ovirt.engine.api.model.Mac)

Aggregations

VnicProfile (org.ovirt.engine.api.model.VnicProfile)13 Network (org.ovirt.engine.api.model.Network)5 WebApplicationException (javax.ws.rs.WebApplicationException)3 Test (org.junit.Test)3 CustomProperties (org.ovirt.engine.api.model.CustomProperties)2 Nic (org.ovirt.engine.api.model.Nic)2 Qos (org.ovirt.engine.api.model.Qos)2 Vm (org.ovirt.engine.api.model.Vm)2 VnicProfileResource (org.ovirt.engine.api.resource.VnicProfileResource)2 VnicProfilesResource (org.ovirt.engine.api.resource.VnicProfilesResource)2 BackendApiResource (org.ovirt.engine.api.restapi.resource.BackendApiResource)2 V3Network (org.ovirt.engine.api.v3.types.V3Network)2 V3Networks (org.ovirt.engine.api.v3.types.V3Networks)2 V3PortMirroring (org.ovirt.engine.api.v3.types.V3PortMirroring)2 Comparator.comparing (java.util.Comparator.comparing)1 HashMap (java.util.HashMap)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Response (javax.ws.rs.core.Response)1