use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostResource method completeSlaveNames.
private void completeSlaveNames(BusinessEntityMap<VdsNetworkInterface> nicsFromBackend, HostNic bond) {
if (bond.isSetBonding() && bond.getBonding().isSetSlaves()) {
for (HostNic slave : bond.getBonding().getSlaves().getHostNics()) {
if (!slave.isSetName() && slave.isSetId()) {
Guid slaveId = new Guid(slave.getId());
String slaveNameFromBackend = nicsFromBackend.get(slaveId).getName();
slave.setName(slaveNameFromBackend);
}
}
}
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostNicNetworkAttachmentsResource method add.
@Override
public Response add(org.ovirt.engine.api.model.NetworkAttachment attachment) {
verifyHostAndNicExistence();
if (attachment.isSetHostNic()) {
Guid hostNicGuid = Guid.createGuidFromString(attachment.getHostNic().getId());
if (!nicId.equals(hostNicGuid)) {
// TODO MM: add message.
return Response.status(Response.Status.BAD_REQUEST).build();
}
} else {
HostNic hostNIC = new HostNic();
hostNIC.setId(nicId.toString());
attachment.setHostNic(hostNIC);
}
return super.add(attachment);
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostNicNetworkAttachmentsResource method addParents.
@Override
protected org.ovirt.engine.api.model.NetworkAttachment addParents(org.ovirt.engine.api.model.NetworkAttachment model) {
model.setHostNic(new HostNic());
model.getHostNic().setId(nicId.toString());
model.getHostNic().setHost(new Host());
model.getHostNic().getHost().setId(getHostId().toString());
return model;
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostNicsResource method map.
protected HostNic map(VdsNetworkInterface iface, HostNic template, List<VdsNetworkInterface> ifaces) {
HostNic nic = super.map(iface, template);
if (iface.getBonded() != null && iface.getBonded()) {
nic = addSlaveLinks(nic, getCollection(ifaces));
nic = addActiveSlaveLink(nic, iface, getCollection(ifaces));
} else if (iface.getBondName() != null) {
nic = addMasterLink(nic, iface.getBondName(), getCollection(ifaces));
}
return nic;
}
use of org.ovirt.engine.api.model.HostNic in project ovirt-engine by oVirt.
the class BackendHostNicsResource method lookupNic.
public HostNic lookupNic(String id, boolean forcePopulate) {
List<VdsNetworkInterface> ifaces = getCollection();
for (VdsNetworkInterface iface : ifaces) {
if (iface.getId().toString().equals(id)) {
HostNic hostNic = map(iface, ifaces);
if (forcePopulate) {
deprecatedPopulate(hostNic, iface);
doPopulate(hostNic, iface);
} else {
populate(hostNic, iface);
}
for (org.ovirt.engine.core.common.businessentities.network.Network nwk : getClusterNetworks()) {
if (nwk.getName().equals(iface.getNetworkName())) {
hostNic.getNetwork().setId(nwk.getId().toString());
hostNic.getNetwork().setName(null);
break;
}
}
return addLinks(hostNic);
}
}
return notFound();
}
Aggregations