Search in sources :

Example 11 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class MonolithicDependencyRulesIT 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);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) NCSBuilder(org.opennms.netmgt.model.ncs.NCSBuilder) Before(org.junit.Before)

Example 12 with NetworkBuilder

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<>();
    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);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) ArrayList(java.util.ArrayList)

Example 13 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class JtiIT method setUp.

@Before
public void setUp() throws IOException {
    rrdBaseDir = tempFolder.newFolder("rrd");
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("R1").setForeignSource("Juniper").setForeignId("1").setSysObjectId(".1.3.6.1.4.1.9.1.222").setType(OnmsNode.NodeType.ACTIVE);
    nb.addInterface("192.0.2.1").setIsSnmpPrimary("P").setIsManaged("P");
    nb.addInterface("172.23.2.12").setIsSnmpPrimary("P").setIsManaged("P");
    nodeDao.save(nb.getCurrentNode());
    // Resync after adding nodes/interfaces
    interfaceToNodeCache.dataSourceSync();
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) Before(org.junit.Before)

Example 14 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class AbstractSingleHardwareAdapterTest method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@BeforeTransaction
public void setUp() throws Exception {
    MockLogAppender.setupLogging(true);
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("Test").setForeignSource("Test").setForeignId("1").setSysObjectId(".1.3.6.1.4.1.9.1.1196");
    nb.addInterface("192.168.0.1").setIsSnmpPrimary("P").setIsManaged("P");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
    m_adapter.afterPropertiesSet();
    m_nodeId = m_nodeDao.findByForeignId("Test", "1").getId();
    AdapterOperationSchedule ops = new AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS);
    m_operation = m_adapter.new AdapterOperation(m_nodeId, AdapterOperationType.ADD, ops);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) AdapterOperationSchedule(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperationSchedule) AdapterOperation(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Example 15 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class SnmpHardwareInventoryProvisioningAdapterIT method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@BeforeTransaction
public void setUp() throws Exception {
    MockLogAppender.setupLogging(true);
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("R1").setForeignSource("Cisco").setForeignId("1").setSysObjectId(".1.3.6.1.4.1.9.1.222");
    nb.addInterface("192.168.0.1").setIsSnmpPrimary("P").setIsManaged("P");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("R2").setForeignSource("Cisco").setForeignId("2").setSysObjectId(".1.3.6.1.4.1.9.1.222");
    nb.addInterface("192.168.0.2").setIsSnmpPrimary("P").setIsManaged("P");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("R3").setForeignSource("Cisco").setForeignId("3").setSysObjectId(".1.3.6.1.4.1.9.1.222");
    nb.addInterface("192.168.0.3").setIsSnmpPrimary("P").setIsManaged("P");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("R4").setForeignSource("Cisco").setForeignId("4").setSysObjectId(".1.3.6.1.4.1.9.1.222");
    nb.addInterface("192.168.0.4").setIsSnmpPrimary("P").setIsManaged("P");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
    m_adapter.afterPropertiesSet();
    for (int i = 1; i <= 4; i++) {
        Integer nodeId = m_nodeDao.findByForeignId("Cisco", Integer.toString(i)).getId();
        AdapterOperationSchedule ops = new AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS);
        AdapterOperation op = m_adapter.new AdapterOperation(nodeId, AdapterOperationType.ADD, ops);
        m_operations.add(new TestOperation(nodeId, op));
    }
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) AdapterOperationSchedule(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperationSchedule) AdapterOperation(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Aggregations

NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)45 Before (org.junit.Before)21 OnmsNode (org.opennms.netmgt.model.OnmsNode)15 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)9 File (java.io.File)6 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)5 NCSBuilder (org.opennms.netmgt.model.ncs.NCSBuilder)5 Date (java.util.Date)4 Test (org.junit.Test)4 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)4 AdapterOperation (org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation)4 ArrayList (java.util.ArrayList)3 InterfaceBuilder (org.opennms.netmgt.model.NetworkBuilder.InterfaceBuilder)3 OnmsAccessPoint (org.opennms.netmgt.model.OnmsAccessPoint)3 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)3 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)3 UnknownHostException (java.net.UnknownHostException)2 HashMap (java.util.HashMap)2 MockPlatformTransactionManager (org.opennms.core.test.MockPlatformTransactionManager)2 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)2