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