use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class DatabasePopulator method doPopulateDatabase.
private void doPopulateDatabase() {
LOG.debug("==== DatabasePopulator Starting ====");
final NetworkBuilder builder = new NetworkBuilder();
final OnmsNode node1 = buildNode1(builder);
getNodeDao().save(node1);
getNodeDao().flush();
OnmsNode node2 = buildNode2(builder);
getNodeDao().save(node2);
getNodeDao().flush();
setNode2(node2);
OnmsNode node3 = buildNode3(builder);
getNodeDao().save(node3);
getNodeDao().flush();
setNode3(node3);
OnmsNode node4 = buildNode4(builder);
getNodeDao().save(node4);
getNodeDao().flush();
setNode4(node4);
OnmsNode node5 = buildNode5(builder);
getNodeDao().save(node5);
getNodeDao().flush();
setNode5(node5);
OnmsNode node6 = buildNode6(builder);
getNodeDao().save(node6);
getNodeDao().flush();
setNode6(node6);
final OnmsEvent event = buildEvent(builder.getDistPoller());
event.setEventCreateTime(new Date(1436881548292L));
event.setEventTime(new Date(1436881548292L));
getEventDao().save(event);
getEventDao().flush();
final OnmsNotification notif = buildTestNotification(builder, event);
getNotificationDao().save(notif);
getNotificationDao().flush();
final OnmsUserNotification userNotif = buildTestUserNotification(notif);
getUserNotificationDao().save(userNotif);
getUserNotificationDao().flush();
final OnmsUserNotification userNotif2 = buildTestUser2Notification(notif);
getUserNotificationDao().save(userNotif2);
getUserNotificationDao().flush();
final OnmsMonitoredService svc = getMonitoredServiceDao().get(node1.getId(), InetAddressUtils.addr("192.168.1.1"), "SNMP");
final OnmsOutage resolved = new OnmsOutage(new Date(1436881548292L), new Date(1436881548292L), event, event, svc, null, null);
getOutageDao().save(resolved);
getOutageDao().flush();
final OnmsOutage unresolved = new OnmsOutage(new Date(1436881548292L), event, svc);
getOutageDao().save(unresolved);
getOutageDao().flush();
final OnmsAlarm alarm = buildAlarm(event);
getAlarmDao().save(alarm);
getAlarmDao().flush();
final OnmsAcknowledgment ack = new OnmsAcknowledgment();
ack.setAckTime(new Date(1437073152156L));
ack.setAckType(AckType.UNSPECIFIED);
ack.setAckAction(AckAction.UNSPECIFIED);
ack.setAckUser("admin");
getAcknowledgmentDao().save(ack);
getAcknowledgmentDao().flush();
final OnmsMonitoringLocation def = new OnmsMonitoringLocation();
def.setLocationName("RDU");
def.setMonitoringArea("East Coast");
def.setPollingPackageNames(Collections.singletonList("example1"));
def.setCollectionPackageNames(Collections.singletonList("example1"));
def.setGeolocation("Research Triangle Park, NC");
def.setLatitude(35.715751f);
def.setLongitude(-79.16262f);
def.setPriority(1L);
def.setTags(Collections.singletonList("blah"));
m_monitoringLocationDao.save(def);
LOG.debug("= DatabasePopulatorExtension Populate Starting =");
for (Extension eachExtension : extensions) {
DaoSupport daoSupport = eachExtension.getDaoSupport();
OnmsDao<?, ?> dao = daoSupport != null ? daoSupport.getDao() : null;
Class<? super OnmsDao<?, ?>> daoClass = daoSupport != null ? daoSupport.getDaoClass() : null;
registerDao(daoClass, dao);
dao = lookupDao(daoClass);
eachExtension.onPopulate(this, dao);
if (dao != null) {
dao.flush();
}
}
LOG.debug("= DatabasePopulatorExtension Populate Finished =");
LOG.debug("==== DatabasePopulator Finished ====");
}
use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class EasyMockDataPopulator method populateDatabase.
public void populateDatabase() {
final String icmp = "ICMP";
final String snmp = "SNMP";
final String http = "HTTP";
final NetworkBuilder builder = new NetworkBuilder();
setNode1(builder.addNode("node1").setForeignSource("imported:").setForeignId("1").setType(NodeType.ACTIVE).setSysObjectId("1.3.6.1.4.1.5813.1.25").getNode());
Assert.assertNotNull("newly built node 1 should not be null", getNode1());
builder.setBuilding("HQ");
builder.addSnmpInterface(1).setCollectionEnabled(true).setIfOperStatus(1).setIfSpeed(10000000).setIfDescr("ATM0").setIfAlias("Initial ifAlias value").setIfType(37).addIpInterface("192.168.1.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addSnmpInterface(2).setCollectionEnabled(true).setIfOperStatus(1).setIfSpeed(10000000).setIfName("eth0").setIfType(6).addIpInterface("192.168.1.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addSnmpInterface(3).setCollectionEnabled(false).setIfOperStatus(1).setIfSpeed(10000000).addIpInterface("192.168.1.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
builder.addSnmpInterface(4).setCollectionEnabled(false).setIfOperStatus(1).setIfSpeed(10000000).addIpInterface("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%5").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
final OnmsNode node1 = builder.getCurrentNode();
setNode1(node1);
builder.addNode("node2").setForeignSource("imported:").setForeignId("2").setType(NodeType.ACTIVE);
builder.setBuilding("HQ");
builder.addInterface("192.168.2.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("192.168.2.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("192.168.2.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node2 = builder.getCurrentNode();
setNode2(node2);
builder.addNode("node3").setForeignSource("imported:").setForeignId("3").setType(NodeType.ACTIVE);
builder.addInterface("192.168.3.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("192.168.3.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("192.168.3.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node3 = builder.getCurrentNode();
setNode3(node3);
builder.addNode("node4").setForeignSource("imported:").setForeignId("4").setType(NodeType.ACTIVE);
builder.addInterface("192.168.4.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("192.168.4.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("192.168.4.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node4 = builder.getCurrentNode();
setNode4(node4);
//This node purposely doesn't have a foreignId style assetNumber
builder.addNode("alternate-node1").setType(NodeType.ACTIVE).getAssetRecord().setAssetNumber("5");
builder.addInterface("10.1.1.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.1.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.1.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node5 = builder.getCurrentNode();
setNode5(node5);
//This node purposely doesn't have a assetNumber and is used by a test to check the category
builder.addNode("alternate-node2").setType(NodeType.ACTIVE).getAssetRecord().setDisplayCategory("category1");
builder.addInterface("10.1.2.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.2.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.2.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node6 = builder.getCurrentNode();
setNode6(node6);
builder.addNode("alternate-node3").setType(NodeType.ACTIVE).getAssetRecord().setDisplayCategory("category1");
builder.addInterface("10.1.3.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.3.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.3.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node7 = builder.getCurrentNode();
setNode7(node7);
builder.addNode("alternate-node4").setType(NodeType.ACTIVE).getAssetRecord().setDisplayCategory("category1");
builder.addInterface("10.1.4.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.4.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.4.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node8 = builder.getCurrentNode();
setNode8(node8);
List<OnmsNode> nodes = new ArrayList<OnmsNode>();
nodes.add(node1);
nodes.add(node2);
nodes.add(node3);
nodes.add(node4);
nodes.add(node5);
nodes.add(node6);
nodes.add(node7);
nodes.add(node8);
setNodes(nodes);
}
use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class ReverseDnsRecordTest method setUp.
@Before
public void setUp() throws Exception {
nb = new NetworkBuilder();
nb.addNode(hostname).setForeignSource("dns").setForeignId("1");
nb.addSnmpInterface(100).setIfName(ifname).addIpInterface(ip);
}
use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class Nms4930NetworkBuilder method addMacNodeWithSnmpInterface.
public void addMacNodeWithSnmpInterface(String mac, String ip, Integer ifindex) {
NetworkBuilder nb = getNetworkBuilder();
nb.addNode(ip).setForeignSource("linkd").setForeignId(ip).setType(NodeType.ACTIVE);
nb.addInterface(ip).setIsSnmpPrimary("N").setIsManaged("M").addSnmpInterface(ifindex).setIfName("eth0").setIfType(6).setPhysAddr(mac).setIfDescr("eth0");
m_nodeDao.save(nb.getCurrentNode());
m_nodeDao.flush();
IpNetToMedia at0 = new IpNetToMedia();
at0.setSourceIfIndex(100);
at0.setPhysAddress(mac);
at0.setLastPollTime(at0.getCreateTime());
at0.setSourceNode(m_nodeDao.findByForeignId("linkd", ip));
try {
at0.setNetAddress(InetAddress.getByName(ip));
} catch (UnknownHostException e) {
e.printStackTrace();
}
at0.setIpNetToMediaType(IpNetToMediaType.IPNETTOMEDIA_TYPE_DYNAMIC);
m_ipNetToMediaDao.saveOrUpdate(at0);
m_ipNetToMediaDao.flush();
}
use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class NCSComponentDaoIT method setUp.
@Before
public void setUp() {
NetworkBuilder bldr = new NetworkBuilder();
// Make sure that the default OnmsMonitoringLocation is saved
m_locationDao.saveOrUpdate(bldr.getLocation());
bldr.addNode("PE1").setForeignSource("space").setForeignId("1111-PE1");
m_nodeDao.save(bldr.getCurrentNode());
m_pe1NodeId = bldr.getCurrentNode().getId();
bldr.addNode("PE2").setForeignSource("space").setForeignId("2222-PE2");
m_nodeDao.save(bldr.getCurrentNode());
m_pe2NodeId = bldr.getCurrentNode().getId();
NCSComponent svc = new NCSBuilder("Service", "NA-Service", "123").setName("CokeP2P").pushComponent("ServiceElement", "NA-ServiceElement", "8765").setName("PE1,SE1").setNodeIdentity("space", "1111-PE1").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765,jnxVpnIf").setName("jnxVpnIf").setNodeIdentity("space", "1111-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfDown").setAttribute("jnxVpnIfVpnType", "5").setAttribute("jnxVpnIfVpnName", "ge-1/0/2.50").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765,link").setName("link").setNodeIdentity("space", "1111-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/linkUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/linkDown").setAttribute("linkName", "ge-1/0/2").popComponent().popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)").setName("jnxVpnPw-vcid(50)").setNodeIdentity("space", "1111-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwDown").setAttribute("jnxVpnPwVpnType", "5").setAttribute("jnxVpnPwVpnName", "ge-1/0/2.50").setDependenciesRequired(DependencyRequirements.ANY).pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765,lspA-PE1-PE2").setName("lspA-PE1-PE2").setNodeIdentity("space", "1111-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspA-PE1-PE2").popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "8765,lspB-PE1-PE2").setName("lspB-PE1-PE2").setNodeIdentity("space", "1111-PE1").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspB-PE1-PE2").popComponent().popComponent().popComponent().pushComponent("ServiceElement", "NA-ServiceElement", "9876").setName("PE2,SE1").setNodeIdentity("space", "2222-PE2").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnIf").setName("jnxVpnIf").setNodeIdentity("space", "2222-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfDown").setAttribute("jnxVpnIfVpnType", "5").setAttribute("jnxVpnIfVpnName", "ge-3/1/4.50").pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,link").setName("link").setNodeIdentity("space", "2222-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/linkUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/linkDown").setAttribute("linkName", "ge-3/1/4").popComponent().popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)").setName("jnxVpnPw-vcid(50)").setNodeIdentity("space", "2222-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnPwDown").setAttribute("jnxVpnPwVpnType", "5").setAttribute("jnxVpnPwVpnName", "ge-3/1/4.50").setDependenciesRequired(DependencyRequirements.ANY).pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,lspA-PE2-PE1").setName("lspA-PE2-PE1").setNodeIdentity("space", "2222-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspA-PE2-PE1").popComponent().pushComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,lspB-PE2-PE1").setName("lspB-PE2-PE1").setNodeIdentity("space", "2222-PE2").setUpEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathUp").setDownEventUei("uei.opennms.org/vendor/Juniper/traps/mplsLspPathDown").setAttribute("mplsLspName", "lspB-PE2-PE1").popComponent().popComponent().popComponent().get();
m_repository.save(svc);
}
Aggregations