use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class FusedForeignSourceRepository method importResourceRequisition.
/**
* {@inheritDoc}
*/
@Override
public synchronized Requisition importResourceRequisition(final Resource resource) throws ForeignSourceRepositoryException {
final Requisition requisition = m_deployedForeignSourceRepository.importResourceRequisition(resource);
final String foreignSource = requisition.getForeignSource();
cleanUpDeployedForeignSources(foreignSource);
cleanUpSnapshots(requisition);
return requisition;
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class DetectorsOnMinionIT method checkServicesDetectedOnMinion.
@Test
public void checkServicesDetectedOnMinion() throws ClientProtocolException, IOException, InterruptedException {
final InetSocketAddress opennmsHttp = m_testEnvironment.getServiceAddress(ContainerAlias.OPENNMS, 8980);
RestClient client = new RestClient(opennmsHttp);
Requisition requisition = new Requisition("foreignSource");
List<RequisitionInterface> interfaces = new ArrayList<>();
RequisitionInterface requisitionInterface = new RequisitionInterface();
requisitionInterface.setIpAddr(LOCALHOST);
requisitionInterface.setManaged(true);
requisitionInterface.setSnmpPrimary(PrimaryType.PRIMARY);
interfaces.add(requisitionInterface);
RequisitionNode node = new RequisitionNode();
node.setNodeLabel("label");
node.setLocation("MINION");
node.setInterfaces(interfaces);
node.setForeignId("foreignId");
requisition.insertNode(node);
client.addOrReplaceRequisition(requisition);
client.importRequisition("foreignSource");
await().atMost(5, MINUTES).pollDelay(0, SECONDS).pollInterval(30, SECONDS).until(getnumberOfServicesDetected(client), greaterThan(0));
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class NxosTelemetryIT method addRequisition.
public static OnmsNode addRequisition(InetSocketAddress opennmsHttp, boolean isMinion, Date startOfTest) {
RestClient client = new RestClient(opennmsHttp);
Requisition requisition = new Requisition("telemetry");
List<RequisitionInterface> interfaces = new ArrayList<>();
RequisitionInterface requisitionInterface = new RequisitionInterface();
requisitionInterface.setIpAddr("192.168.0.1");
requisitionInterface.setManaged(true);
requisitionInterface.setSnmpPrimary(PrimaryType.PRIMARY);
interfaces.add(requisitionInterface);
RequisitionNode node = new RequisitionNode();
String label = "nexus9k";
node.setNodeLabel(label);
node.setForeignId("nxos");
node.setInterfaces(interfaces);
if (isMinion) {
// For a requisition, foreignId needs to be unique, change foreignId
node.setLocation("MINION");
node.setForeignId("nexus9k");
// Change label so that node matches with foreignId
label = "nxos";
node.setNodeLabel(label);
}
requisition.insertNode(node);
client.addOrReplaceRequisition(requisition);
client.importRequisition("telemetry");
InetSocketAddress pgsql = m_testEnvironment.getServiceAddress(ContainerAlias.POSTGRES, 5432);
HibernateDaoFactory daoFactory = new HibernateDaoFactory(pgsql);
NodeDao nodeDao = daoFactory.getDao(NodeDaoHibernate.class);
final OnmsNode onmsNode = await().atMost(3, MINUTES).pollInterval(30, SECONDS).until(DaoUtils.findMatchingCallable(nodeDao, new CriteriaBuilder(OnmsNode.class).ge("createTime", startOfTest).eq("label", label).toCriteria()), notNullValue());
assertNotNull(onmsNode);
return onmsNode;
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class SyslogOverlappingIpAddressIT method testAssociateSyslogsWithNodesWithOverlappingIpAddresses.
/**
* @see https://issues.opennms.org/browse/NMS-8798
*
* @throws Exception
*/
@Test
public void testAssociateSyslogsWithNodesWithOverlappingIpAddresses() throws Exception {
final Date startOfTest = new Date();
final String hostIpAddress = "1.2.3.4";
// Create requisition with two node in different locations but same IP
final RestClient client = new RestClient(testEnvironment.getServiceAddress(ContainerAlias.OPENNMS, 8980));
final Requisition requisition = new Requisition("overlapping");
final RequisitionNode node1 = new RequisitionNode();
node1.setNodeLabel("node_1");
node1.setLocation("MINION");
final RequisitionInterface interface1 = new RequisitionInterface();
interface1.setIpAddr(hostIpAddress);
interface1.setManaged(true);
interface1.setSnmpPrimary(PrimaryType.PRIMARY);
node1.setInterfaces(ImmutableList.of(interface1));
node1.setForeignId("node_1");
requisition.insertNode(node1);
final RequisitionNode node2 = new RequisitionNode();
node2.setNodeLabel("node_2");
node2.setLocation("BANANA");
final RequisitionInterface interface2 = new RequisitionInterface();
interface2.setIpAddr(hostIpAddress);
interface2.setManaged(true);
interface2.setSnmpPrimary(PrimaryType.PRIMARY);
node2.setInterfaces(ImmutableList.of(interface2));
node2.setForeignId("node_2");
requisition.insertNode(node2);
client.addOrReplaceRequisition(requisition);
client.importRequisition("overlapping");
// Wait for the nodes to be provisioned
final OnmsNode onmsNode1 = await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.findMatchingCallable(getDaoFactory().getDao(NodeDaoHibernate.class), new CriteriaBuilder(OnmsNode.class).eq("label", "node_1").toCriteria()), notNullValue());
final OnmsNode onmsNode2 = await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.findMatchingCallable(getDaoFactory().getDao(NodeDaoHibernate.class), new CriteriaBuilder(OnmsNode.class).eq("label", "node_2").toCriteria()), notNullValue());
// Sending syslog messages to each node and expect it to appear on the node
sendMessage(ContainerAlias.MINION, hostIpAddress, 1);
await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(getDaoFactory().getDao(EventDaoHibernate.class), new CriteriaBuilder(OnmsEvent.class).eq("eventUei", "uei.opennms.org/vendor/cisco/syslog/SEC-6-IPACCESSLOGP/aclDeniedIPTraffic").ge("eventCreateTime", startOfTest).eq("node", onmsNode1).toCriteria()), is(1));
sendMessage(ContainerAlias.MINION_OTHER_LOCATION, hostIpAddress, 1);
await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(getDaoFactory().getDao(EventDaoHibernate.class), new CriteriaBuilder(OnmsEvent.class).eq("eventUei", "uei.opennms.org/vendor/cisco/syslog/SEC-6-IPACCESSLOGP/aclDeniedIPTraffic").ge("eventCreateTime", startOfTest).eq("node", onmsNode2).toCriteria()), is(1));
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class ShowImport method execute.
@Override
public Object execute() throws Exception {
final CompletableFuture<Requisition> future = client.requisition().withRequisitionProviderType(type).withParameters(parse(parameters)).withLocation(location).withSystemId(systemId).withTimeToLive(ttlInMs).execute();
while (true) {
try {
try {
Requisition requisition = future.get(1, TimeUnit.SECONDS);
if (xmlOutput) {
return JaxbUtils.marshal(requisition);
} else {
return requisition;
}
} catch (InterruptedException e) {
System.out.println("\nInterrupted.");
} catch (ExecutionException e) {
System.out.printf("\nRequisition retrieval failed with: %s\n", e);
}
break;
} catch (TimeoutException e) {
// pass
}
System.out.print(".");
System.out.flush();
}
return null;
}
Aggregations