use of org.opennms.netmgt.provision.persist.requisition.RequisitionInterface in project opennms by OpenNMS.
the class DefaultProvisionService method createUpdateRequistion.
private boolean createUpdateRequistion(final String addrString, final OnmsNode node, final String locationName, String m_foreignSource) {
LOG.debug("Creating/Updating requistion {} for newSuspect {}...", m_foreignSource, addrString);
try {
Requisition r = null;
if (m_foreignSource != null) {
r = m_foreignSourceRepository.getRequisition(m_foreignSource);
if (r == null) {
r = new Requisition(m_foreignSource);
}
}
r.updateDateStamp();
RequisitionNode rn = new RequisitionNode();
RequisitionInterface iface = new RequisitionInterface();
iface.setDescr("disc-if");
iface.setIpAddr(addrString);
iface.setManaged(true);
iface.setSnmpPrimary(PrimaryType.PRIMARY);
iface.setStatus(Integer.valueOf(1));
RequisitionInterfaceCollection ric = new RequisitionInterfaceCollection();
ric.add(iface);
rn.setInterfaces(ric.getObjects());
rn.setBuilding(m_foreignSource);
rn.setForeignId(node.getForeignId());
rn.setNodeLabel(node.getLabel());
rn.setLocation(locationName);
r.putNode(rn);
m_foreignSourceRepository.save(r);
m_foreignSourceRepository.flush();
} catch (ForeignSourceRepositoryException e) {
LOG.error("Couldn't create/update requistion for newSuspect " + addrString, e);
return false;
}
LOG.debug("Created/Updated requistion {} for newSuspect {}.", m_foreignSource, addrString);
return true;
}
use of org.opennms.netmgt.provision.persist.requisition.RequisitionInterface in project opennms by OpenNMS.
the class RequisitionBuilder method withContainer.
public RequisitionBuilder withContainer(final ContainerAlias alias, final String... services) {
// We're assuming that the Minion container is on the same
// host as the service containers
final ContainerInfo containerInfo = minionSystem.getContainerInfo(alias);
final String containerIpAddr = containerInfo.networkSettings().ipAddress();
RequisitionNode node = new RequisitionNode();
node.setNodeLabel(alias.toString());
node.setForeignId(alias.toString());
RequisitionInterface iface = new RequisitionInterface();
iface.setSnmpPrimary(PrimaryType.PRIMARY);
iface.setIpAddr(containerIpAddr);
for (String svcName : services) {
RequisitionMonitoredService svc = new RequisitionMonitoredService();
svc.setServiceName(svcName);
iface.putMonitoredService(svc);
}
node.putInterface(iface);
requisition.putNode(node);
return this;
}
Aggregations