Search in sources :

Example 21 with NetworkBuilder

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

the class ImpactProgagationRulesIT method setUp.

@Before
public void setUp() throws JAXBException, UnsupportedEncodingException {
    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());
    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);
    // Get engine
    m_engine = findEngineByName("impactPropagationRules");
//        // Create a Marshaller
//        JAXBContext context = JAXBContext.newInstance(NCSComponent.class);
//        Marshaller marshaller = context.createMarshaller();
//        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//        
//        // save the output in a byte array
//        ByteArrayOutputStream out = new ByteArrayOutputStream();
//
//        // marshall the output
//        marshaller.marshal(svc, out);
//
//        // verify its matches the expected results
//        byte[] utf8 = out.toByteArray();
//
//        String result = new String(utf8, StandardCharsets.UTF_8);
//        
//        System.err.println(result);
}
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 22 with NetworkBuilder

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

the class RancidProvisioningAdapterIT method setUp.

@Before
public void setUp() throws Exception {
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("test.example.com").setForeignSource("rancid").setForeignId("1");
    nb.addInterface("192.168.0.1");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
    m_addOperation = m_adapter.new AdapterOperation(m_nodeDao.findByForeignId("rancid", "1").getId(), AdapterOperationType.ADD, new SimpleQueuedProvisioningAdapter.AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS));
    m_deleteOperation = m_adapter.new AdapterOperation(m_nodeDao.findByForeignId("rancid", "1").getId(), AdapterOperationType.DELETE, new SimpleQueuedProvisioningAdapter.AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS));
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) AdapterOperation(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation) Before(org.junit.Before)

Example 23 with NetworkBuilder

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

the class SnmpAssetProvisioningAdapterIT method setUp.

@Before
public void setUp() throws Exception {
    // Use the mock.logLevel system property to control the log level
    MockLogAppender.setupLogging(true);
    // Set the operation delay to 1 second so that queued operations execute immediately
    m_adapter.setDelay(1);
    m_adapter.setTimeUnit(TimeUnit.SECONDS);
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("test.example.com").setForeignSource("rancid").setForeignId("1").setSysObjectId(".1.3");
    nb.addInterface("192.168.0.1");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
    // Make sure that the localhost SNMP connection config factory has overridden
    // the normal config factory
    assertTrue(m_adapter.getSnmpPeerFactory() instanceof ProxySnmpAgentConfigFactory);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) Before(org.junit.Before)

Example 24 with NetworkBuilder

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

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

Example 25 with NetworkBuilder

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

the class DependencyLoadingRulesIT 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);
    //		m_pwCompId = svc.getSubcomponent("NA-ServiceElement", "9876")
    //		                 .getSubcomponent("NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)")
    //		                 .getId();
    // Get engine
    m_engine = findEngineByName("dependencyLoadingRules");
}
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)

Aggregations

NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)42 Before (org.junit.Before)20 OnmsNode (org.opennms.netmgt.model.OnmsNode)14 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)9 File (java.io.File)6 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 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)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 InsufficientInformationException (org.opennms.core.utils.InsufficientInformationException)2