use of org.opennms.netmgt.model.ncs.NCSComponent 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);
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class NCSTypeListController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String type = request.getParameter("type");
String foreignSource = request.getParameter("foreignSource");
String foreignId = request.getParameter("foreignId");
NCSComponent component = null;
String treeView = "<br/><p>No Components To View, Please check the type, foreign source and foreign id are correct</p>";
if (!type.equals("null") && !foreignSource.equals("null") && !foreignId.equals("null")) {
component = m_componentDao.findByTypeAndForeignIdentity(type, foreignSource, foreignId);
treeView = "<ul class=\"TreeView\" id=\"TreeView\">\n" + getComponentHTML(component) + "</ul>";
}
ModelAndView modelAndView = new ModelAndView("ncs/ncs-type");
modelAndView.addObject("treeView", treeView);
return modelAndView;
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class NCSListFormattingTest method testRecursiveMethod.
@Test
public void testRecursiveMethod() {
NCSComponent svc = new NCSBuilder("Service", "NA-Service", "123").setName("CokeP2P").pushComponent("ServiceElement", "NA-ServiceElement", "8765").setName("PE1:SE1").setNodeIdentity("space", "1111-PE1").popComponent().pushComponent("ServiceElement", "NA-ServiceElement", "8766").setName("PE2:SE2").popComponent().get();
String expected = "<ul>\n" + "<li>CokeP2P<ul>\n" + "<li>PE1:SE1</li>\n" + "<li>PE2:SE2</li>\n" + "</ul>" + "</li>\n" + "</ul>";
String result = "<ul>\n" + getComponentHTML(svc) + "</ul>";
assertEquals(expected, result);
System.err.println("recursive: " + result);
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class DefaultNCSCorrelationService method findComponentsByNodeIdAndAttrParmMaps.
@Override
public List<NCSComponent> findComponentsByNodeIdAndAttrParmMaps(Event e, AttrParmMap... parameterMap) {
assert e.getNodeid() != null;
assert e.getNodeid() != 0;
List<NCSComponent> components = m_componentRepo.findComponentsByNodeId(e.getNodeid().intValue());
List<NCSComponent> matching = new LinkedList<NCSComponent>();
for (NCSComponent component : components) {
if (matches(component, e, parameterMap)) {
matching.add(component);
}
}
return matching;
}
use of org.opennms.netmgt.model.ncs.NCSComponent in project opennms by OpenNMS.
the class DefaultNCSCorrelationService method findSubComponents.
@Override
public List<NCSComponent> findSubComponents(Long componentId) {
NCSComponent comp = m_componentRepo.get(componentId);
Set<NCSComponent> subcomponents = comp.getSubcomponents();
for (NCSComponent subcomponent : subcomponents) {
m_componentRepo.initialize(subcomponent);
}
return new ArrayList<NCSComponent>(subcomponents);
}
Aggregations