|
|
|
Philippe Guillebert-2
|
Hi
We've got a little issue with the current Rancid integration : our nodeLabels are arbitrary (not ip, not DNS names). So, in our Rancid configuration (router.db), we use primary IP addresses as names. And, with the current SVN HEAD, InventoryService uses nodeLabel and supposes it's the name in router.db. This patches adds a fallback : when the node cannot be found by label, it tries to use primaryInterface or the first interface it finds. It's tested and works for me ;) I'm puzzled about : OnmsIpInterface primaryInterface = node.getPrimaryInterface(); It should give me the primaryInterface, but doesn't, even for nodes where there is a 'P' in the column issnmpprimary in the ipinterface table. Am I getting the primary interface concept right ? So I borrowed code from another function in RancidProvisioningAdapter ( getSuitableIpForRancid() ) and that's why, in the patch, I get all interfaces and pick the first. Not very elegant, but it works. I hope this will be integrated in SVN by our friends the other side of the alps :) Have a nice day -- Philippe Guillebert Bull, Architect of an Open World Tél : +33 (0)1 30 80 61 81 http://www.bull.com Index: InventoryService.java =================================================================== --- InventoryService.java (revision 13486) +++ InventoryService.java (working copy) @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import org.apache.log4j.Category; @@ -11,6 +12,7 @@ import org.opennms.core.resource.Vault; import org.opennms.netmgt.config.RWSConfig; import org.opennms.netmgt.dao.NodeDao; +import org.opennms.netmgt.model.OnmsIpInterface; import org.opennms.netmgt.model.OnmsNode; import org.opennms.rancid.ConnectionProperties; import org.opennms.rancid.InventoryElement2; @@ -114,11 +116,46 @@ nodeModel.put("RWSStatus","OK"); OnmsNode node = m_nodeDao.get(nodeid); - String rancidName = node.getLabel(); + String rancidName; + log().debug("getRancidNodeBase rancid node name search..."); + + // Test if node label is known in Rancid + if(checkRancidNode(node.getLabel())) { + rancidName = node.getLabel(); + log().debug("getRancidNodeBase rancid node name found by label : " + rancidName); + } + else { + // else, fall back to the Primary IP address if it exists + String intf = ""; + OnmsIpInterface primaryInterface = node.getPrimaryInterface(); + + if (primaryInterface == null) { + log().debug("getRancidNodeBase primaryIP not found"); + Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); + for (OnmsIpInterface onmsIpInterface : ipInterfaces) { + log().debug("getRancidNodeBase alternate intf found : " + onmsIpInterface.getIpAddress()); + intf = onmsIpInterface.getIpAddress(); + break; + } + } + else { + intf = primaryInterface.getIpAddress(); + } + + if(intf != null && intf.length() > 0 && checkRancidNode(intf)) { + rancidName = intf; + log().debug("getRancidNodeBase rancid node name found by IPAddr : " + rancidName); + } + else { + // TODO manage unknown nodes better ? + rancidName = node.getLabel(); + log().debug("getRancidNodeBase rancid node name NOT found"); + } + } + log().debug("getRancidNodeBase rancid node name: " + rancidName); - nodeModel.put("id", rancidName); nodeModel.put("db_id", nodeid); nodeModel.put("status_general", ElementUtil.getNodeStatusString(node.getType().charAt(0))); [philippe_guillebert.vcf] begin:vcard fn:Philippe Guillebert n:Guillebert;Philippe org:Bull Telecom & Media;Operation Support Systems email;internet:[hidden email] title:SmartOSS Technical Manager tel;work:+33 1 30 80 61 81 version:2.1 end:vcard ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Please read the OpenNMS Mailing List FAQ: http://www.opennms.org/index.php/Mailing_List_FAQ opennms-devel mailing list To *unsubscribe* or change your subscription options, see the bottom of this page: https://lists.sourceforge.net/lists/listinfo/opennms-devel |
||||||||||||||||
|
Antonio Russo
|
Philippe there was an issue in getPrimaryInterface, now is fixed.
Regards Antonio Il giorno 29/mag/09, alle ore 10:29, Philippe Guillebert ha scritto: > Hi > > We've got a little issue with the current Rancid integration : our > nodeLabels are arbitrary (not ip, not DNS names). So, in our Rancid > configuration (router.db), we use primary IP addresses as names. > > And, with the current SVN HEAD, InventoryService uses nodeLabel and > supposes it's the name in router.db. > > This patches adds a fallback : when the node cannot be found by > label, it tries to use primaryInterface or the first interface it > finds. > > It's tested and works for me ;) > > I'm puzzled about : > OnmsIpInterface primaryInterface = node.getPrimaryInterface(); > > It should give me the primaryInterface, but doesn't, even for nodes > where there is a 'P' in the column issnmpprimary in the ipinterface > table. > > Am I getting the primary interface concept right ? > > So I borrowed code from another function in > RancidProvisioningAdapter ( getSuitableIpForRancid() ) and that's > why, in the patch, I get all interfaces and pick the first. Not very > elegant, but it works. > > I hope this will be integrated in SVN by our friends the other side > of the alps :) > > Have a nice day > > -- > Philippe Guillebert > > Bull, Architect of an Open World > Tél : +33 (0)1 30 80 61 81 > http://www.bull.com > > Index: InventoryService.java > =================================================================== > --- InventoryService.java (revision 13486) > +++ InventoryService.java (working copy) > @@ -4,6 +4,7 @@ > import java.util.Iterator; > import java.util.List; > import java.util.Map; > +import java.util.Set; > import java.util.TreeMap; > > import org.apache.log4j.Category; > @@ -11,6 +12,7 @@ > import org.opennms.core.resource.Vault; > import org.opennms.netmgt.config.RWSConfig; > import org.opennms.netmgt.dao.NodeDao; > +import org.opennms.netmgt.model.OnmsIpInterface; > import org.opennms.netmgt.model.OnmsNode; > import org.opennms.rancid.ConnectionProperties; > import org.opennms.rancid.InventoryElement2; > @@ -114,11 +116,46 @@ > > nodeModel.put("RWSStatus","OK"); > OnmsNode node = m_nodeDao.get(nodeid); > - String rancidName = node.getLabel(); > + String rancidName; > > + log().debug("getRancidNodeBase rancid node name search..."); > + > + // Test if node label is known in Rancid > + if(checkRancidNode(node.getLabel())) { > + rancidName = node.getLabel(); > + log().debug("getRancidNodeBase rancid node name found > by label : " + rancidName); > + } > + else { > + // else, fall back to the Primary IP address if it exists > + String intf = ""; > + OnmsIpInterface primaryInterface = > node.getPrimaryInterface(); > + > + if (primaryInterface == null) { > + log().debug("getRancidNodeBase primaryIP not found"); > + Set<OnmsIpInterface> ipInterfaces = > node.getIpInterfaces(); > + for (OnmsIpInterface onmsIpInterface : > ipInterfaces) { > + log().debug("getRancidNodeBase alternate intf > found : " + onmsIpInterface.getIpAddress()); > + intf = onmsIpInterface.getIpAddress(); > + break; > + } > + } > + else { > + intf = primaryInterface.getIpAddress(); > + } > + > + if(intf != null && intf.length() > 0 && > checkRancidNode(intf)) { > + rancidName = intf; > + log().debug("getRancidNodeBase rancid node name > found by IPAddr : " + rancidName); > + } > + else { > + // TODO manage unknown nodes better ? > + rancidName = node.getLabel(); > + log().debug("getRancidNodeBase rancid node name NOT > found"); > + } > + } > + > log().debug("getRancidNodeBase rancid node name: " + > rancidName); > > - > nodeModel.put("id", rancidName); > nodeModel.put("db_id", nodeid); > nodeModel.put("status_general", > ElementUtil.getNodeStatusString(node.getType().charAt(0))); > < > philippe_guillebert > .vcf > > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity > professionals. Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp as they present alongside digital heavyweights like > Barbarian > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com > _______________________________________________ > Please read the OpenNMS Mailing List FAQ: > http://www.opennms.org/index.php/Mailing_List_FAQ > > opennms-devel mailing list > > To *unsubscribe* or change your subscription options, see the bottom > of this page: > https://lists.sourceforge.net/lists/listinfo/opennms-devel ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Please read the OpenNMS Mailing List FAQ: http://www.opennms.org/index.php/Mailing_List_FAQ opennms-devel mailing list To *unsubscribe* or change your subscription options, see the bottom of this page: https://lists.sourceforge.net/lists/listinfo/opennms-devel |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |