use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class NsclientCollectorTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
startServer("None&8&", "10");
// Initialize Mocks
m_transactionManager = new MockPlatformTransactionManager();
m_ipInterfaceDao = EasyMock.createMock(IpInterfaceDao.class);
m_eventProxy = EasyMock.createMock(EventProxy.class);
NetworkBuilder builder = new NetworkBuilder();
builder.addNode("winsrv");
builder.addInterface(getServer().getInetAddress().getHostAddress()).addSnmpInterface(1).setCollectionEnabled(true);
builder.getCurrentNode().setId(1);
OnmsIpInterface iface = builder.getCurrentNode().getIpInterfaces().iterator().next();
iface.setIsSnmpPrimary(PrimaryType.PRIMARY);
iface.setId(1);
EasyMock.expect(m_ipInterfaceDao.load(1)).andReturn(iface).anyTimes();
EasyMock.replay(m_ipInterfaceDao, m_eventProxy);
// Initialize NSClient Configuration
String nsclient_config = "<nsclient-config port=\"" + getServer().getLocalPort() + "\" retry=\"1\" timeout=\"3000\" />";
NSClientPeerFactory.setInstance(new NSClientPeerFactory(new ByteArrayInputStream(nsclient_config.getBytes())));
NSClientDataCollectionConfigFactory.setInstance(new NSClientDataCollectionConfigFactory("src/test/resources/nsclient-datacollection-config.xml"));
// Initialize Collection Agent
m_collectionAgent = DefaultCollectionAgent.create(1, m_ipInterfaceDao, m_transactionManager);
}
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));
}
}
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);
}
use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class EnLinkdIT method testDeleteBridgeB.
@Test
public void testDeleteBridgeB() {
ABCTopology topology = new ABCTopology();
NetworkBuilder nb = new NetworkBuilder();
nb.addNode("nodeA").setForeignSource("linkd").setForeignId("nodeA").setSysObjectId("0.0").setSysName("nodeA").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.1").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("nodeB").setForeignSource("linkd").setForeignId("nodeB").setSysObjectId("0.0").setSysName("nodeB").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.2").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("nodeC").setForeignSource("linkd").setForeignId("nodeC").setSysObjectId("0.0").setSysName("nodeC").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.3").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
OnmsNode nodeA = m_nodeDao.findByForeignId("linkd", "nodeA");
OnmsNode nodeB = m_nodeDao.findByForeignId("linkd", "nodeB");
OnmsNode nodeC = m_nodeDao.findByForeignId("linkd", "nodeC");
topology.nodeAId = nodeA.getId();
topology.nodeBId = nodeB.getId();
topology.nodeCId = nodeC.getId();
topology.nodeA = nodeA;
topology.nodeB = nodeB;
topology.nodeC = nodeC;
BridgeBridgeLink ablink = new BridgeBridgeLink();
ablink.setNode(nodeB);
ablink.setBridgePort(topology.portBA);
ablink.setDesignatedNode(nodeA);
ablink.setDesignatedPort(topology.portAB);
ablink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
m_bridgeBridgeLinkDao.save(ablink);
BridgeBridgeLink bclink = new BridgeBridgeLink();
bclink.setNode(nodeC);
bclink.setBridgePort(topology.portCB);
bclink.setDesignatedNode(nodeB);
bclink.setDesignatedPort(topology.portBC);
bclink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
m_bridgeBridgeLinkDao.save(bclink);
BridgeMacLink mac1 = new BridgeMacLink();
mac1.setNode(nodeA);
mac1.setBridgePort(topology.portA);
mac1.setMacAddress(topology.mac1);
mac1.setBridgeMacLinkLastPollTime(mac1.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac1);
BridgeMacLink mac2 = new BridgeMacLink();
mac2.setNode(nodeB);
mac2.setBridgePort(topology.portB);
mac2.setMacAddress(topology.mac2);
mac2.setBridgeMacLinkLastPollTime(mac2.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac2);
BridgeMacLink mac3 = new BridgeMacLink();
mac3.setNode(nodeC);
mac3.setBridgePort(topology.portC);
mac3.setMacAddress(topology.mac3);
mac3.setBridgeMacLinkLastPollTime(mac3.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac3);
m_bridgeMacLinkDao.flush();
m_bridgeBridgeLinkDao.flush();
assertEquals(3, m_bridgeMacLinkDao.countAll());
assertEquals(2, m_bridgeBridgeLinkDao.countAll());
assertNotNull(m_bridgeTopologyDao);
m_linkd.getQueryManager().loadBridgeTopology();
assertEquals(1, m_bridgeTopologyDao.getAll().size());
BroadcastDomain nodeAbd = m_linkd.getQueryManager().getBroadcastDomain(nodeA.getId().intValue());
assertNotNull(nodeAbd);
BroadcastDomain nodeBbd = m_linkd.getQueryManager().getBroadcastDomain(nodeB.getId().intValue());
BroadcastDomain nodeCbd = m_linkd.getQueryManager().getBroadcastDomain(nodeC.getId().intValue());
assertEquals(nodeAbd, nodeBbd);
assertEquals(nodeAbd, nodeCbd);
assertNull(nodeAbd.getRootBridgeId());
assertTrue(nodeAbd.containBridgeId(nodeA.getId()));
assertTrue(nodeAbd.containBridgeId(nodeB.getId()));
assertTrue(nodeAbd.containBridgeId(nodeC.getId()));
nodeAbd.hierarchySetUp(nodeAbd.getBridge(nodeA.getId()));
assertNotNull(nodeAbd.getRootBridgeId());
topology.check(nodeAbd);
assertTrue(m_linkd.scheduleNodeCollection(nodeB.getId()));
m_linkd.deleteNode(nodeB.getId());
assertEquals(1, m_bridgeTopologyDao.getAll().size());
BroadcastDomain domain = m_bridgeTopologyDao.getAll().iterator().next();
topology.checkAC(domain);
}
use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.
the class EnLinkdIT method testDeleteBridgeA.
@Test
public void testDeleteBridgeA() {
ABCTopology topology = new ABCTopology();
NetworkBuilder nb = new NetworkBuilder();
nb.addNode("nodeA").setForeignSource("linkd").setForeignId("nodeA").setSysObjectId("0.0").setSysName("nodeA").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.1").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("nodeB").setForeignSource("linkd").setForeignId("nodeB").setSysObjectId("0.0").setSysName("nodeB").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.2").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("nodeC").setForeignSource("linkd").setForeignId("nodeC").setSysObjectId("0.0").setSysName("nodeC").setType(NodeType.ACTIVE);
nb.addInterface("10.0.1.3").setIsSnmpPrimary("P").setIsManaged("M");
m_nodeDao.save(nb.getCurrentNode());
OnmsNode nodeA = m_nodeDao.findByForeignId("linkd", "nodeA");
OnmsNode nodeB = m_nodeDao.findByForeignId("linkd", "nodeB");
OnmsNode nodeC = m_nodeDao.findByForeignId("linkd", "nodeC");
topology.nodeAId = nodeA.getId();
topology.nodeBId = nodeB.getId();
topology.nodeCId = nodeC.getId();
topology.nodeA = nodeA;
topology.nodeB = nodeB;
topology.nodeC = nodeC;
BridgeBridgeLink ablink = new BridgeBridgeLink();
ablink.setNode(nodeB);
ablink.setBridgePort(topology.portBA);
ablink.setDesignatedNode(nodeA);
ablink.setDesignatedPort(topology.portAB);
ablink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
m_bridgeBridgeLinkDao.save(ablink);
BridgeBridgeLink bclink = new BridgeBridgeLink();
bclink.setNode(nodeC);
bclink.setBridgePort(topology.portCB);
bclink.setDesignatedNode(nodeB);
bclink.setDesignatedPort(topology.portBC);
bclink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
m_bridgeBridgeLinkDao.save(bclink);
BridgeMacLink mac1 = new BridgeMacLink();
mac1.setNode(nodeA);
mac1.setBridgePort(topology.portA);
mac1.setMacAddress(topology.mac1);
mac1.setBridgeMacLinkLastPollTime(mac1.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac1);
BridgeMacLink mac2 = new BridgeMacLink();
mac2.setNode(nodeB);
mac2.setBridgePort(topology.portB);
mac2.setMacAddress(topology.mac2);
mac2.setBridgeMacLinkLastPollTime(mac2.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac2);
BridgeMacLink mac3 = new BridgeMacLink();
mac3.setNode(nodeC);
mac3.setBridgePort(topology.portC);
mac3.setMacAddress(topology.mac3);
mac3.setBridgeMacLinkLastPollTime(mac3.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(mac3);
m_bridgeMacLinkDao.flush();
m_bridgeBridgeLinkDao.flush();
assertEquals(3, m_bridgeMacLinkDao.countAll());
assertEquals(2, m_bridgeBridgeLinkDao.countAll());
assertNotNull(m_bridgeTopologyDao);
m_linkd.getQueryManager().loadBridgeTopology();
assertEquals(1, m_bridgeTopologyDao.getAll().size());
BroadcastDomain nodeAbd = m_linkd.getQueryManager().getBroadcastDomain(nodeA.getId().intValue());
assertNotNull(nodeAbd);
BroadcastDomain nodeBbd = m_linkd.getQueryManager().getBroadcastDomain(nodeB.getId().intValue());
BroadcastDomain nodeCbd = m_linkd.getQueryManager().getBroadcastDomain(nodeC.getId().intValue());
assertEquals(nodeAbd, nodeBbd);
assertEquals(nodeAbd, nodeCbd);
assertNull(nodeAbd.getRootBridgeId());
assertTrue(nodeAbd.containBridgeId(nodeA.getId()));
assertTrue(nodeAbd.containBridgeId(nodeB.getId()));
assertTrue(nodeAbd.containBridgeId(nodeC.getId()));
nodeAbd.hierarchySetUp(nodeAbd.getBridge(nodeA.getId()));
assertNotNull(nodeAbd.getRootBridgeId());
topology.check(nodeAbd);
assertTrue(m_linkd.scheduleNodeCollection(nodeA.getId()));
m_linkd.scheduleBridgeTopologyDiscovery(nodeA.getId());
m_linkd.deleteNode(nodeA.getId());
assertEquals(1, m_bridgeTopologyDao.getAll().size());
BroadcastDomain domain = m_bridgeTopologyDao.getAll().iterator().next();
topology.checkBC(domain);
}
Aggregations