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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations