From: SourceForge.net <no...@so...> - 2008-09-24 15:38:07
|
Bugs item #1975134, was opened at 2008-05-27 11:12 Message generated for change (Comment added) made by raman_arora You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=712784&aid=1975134&group_id=128809 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Java Client Group: Usability Status: Open Resolution: None Priority: 5 Private: No Submitted By: Alon Aradi (allonr) Assigned to: ~Ramandeep Arora~ (raman_arora) Summary: CIM subscription uses wrong IP when there are multiple IPs Initial Comment: I'm working on the IBM Director project. We are using the SBLIM CIM client for communication between the Director server side and the Director agent side (where there is a CIMOM). The CIM client version is: PRODUCTNAME=SBLIM CIM Client COPYRIGHT=(C) Copyright IBM Corp. 2005, 2006 VERSION= Experimental August 21 2006 BUILDDATE=08/21/06 TIME=04:20:03 PM We subscribe for indications on the CIMOM. I noticed that when there is more then one IP on the Director server side, the subscription is made using the wrong IP. On my laptop I have two IPs: C:\Documents and Settings\tpowner>ipconfig Windows IP Configuration Ethernet adapter {583FBDE7-6CEE-4E56-BD92-8AE880EFDE5D}: Connection-specific DNS Suffix . : Autoconfiguration IP Address. . . : 169.254.212.59 Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : Ethernet adapter Wireless Connection: Media State . . . . . . . . . . . : Media disconnected Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : haifa.ibm.com IP Address. . . . . . . . . . . . : 9.148.193.166 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 9.148.193.4 When I do "cimsubscribe -lh" on the agent, I get: CIM_IndicationHandlerCIMXML.CreationClassName="CIM_IndicationHandlerCIMXML",Name="tp-allonr",SystemCreationClassName="CIM_ComputerSystem",SystemName="pelgeya.haifa.ibm.com" Caption = Description = ElementName = OtherPersistenceType = Owner = CreationClassName = CIM_IndicationHandlerCIMXML Destination = http:// 169.254.212.59:6989/CIMListener/DirectorConsumer/UID=7f904188ce196405 Name = tp-allonr SystemCreationClassName = CIM_ComputerSystem SystemName = pelgeya.haifa.ibm.com PersistenceType = 2 The destination has my local IP instead of the global one - 9.148.193.166. Because of this I don't get indications. Here is the code we are calling to get the CIM listener instance from the SBLIM CIM client: public CIMInstance getIndicationListener( CIMListener listener) throws CIMException { if (listener == null) throw new CIMException(CIMException.CIM_ERR_INVALID_PARAMETER, "null listener argument"); if (!initializeIndicationServer()) throw new CIMException(CIMException.CIM_ERR_FAILED, "Could not initialize indication listener"); int port; String host; try { host = indicationServer.getHostIP(); port = indicationServer.getPort(); CIMClass clazz = getClass(new CIMObjectPath("CIM_ListenerDestinationCIMXML"), false, false, false, null); CIMInstance inst = clazz.newInstance(); inst.setProperty("CreationClassName", new CIMValue("CIM_IndicationHandlerCIMXML", CIMDataType.getPredefinedType(CIMDataType.STRING))); inst.setProperty("SystemCreationClassName", new CIMValue("CIM_ComputerSystem", CIMDataType.getPredefinedType(CIMDataType.STRING))); inst.setProperty("Name", new CIMValue(getUniqueID(host, port), CIMDataType.getPredefinedType(CIMDataType.STRING))); inst.setProperty("SystemName", new CIMValue(host, CIMDataType.getPredefinedType(CIMDataType.STRING))); String id = String.valueOf(listener.hashCode()); inst.setProperty("Destination", new CIMValue("http://" + host + ":" + port+"/"+id, CIMDataType.getPredefinedType(CIMDataType.STRING))); return inst; } catch (CIMException e) { throw e; } catch (Exception e) { throw new CIMException(CIMException.CIM_ERR_FAILED, e); } } public String getHostIP() throws UnknownHostException { return InetAddress.getLocalHost().getHostAddress(); } The IP is taken from the JAVA static method InetAddress.getLocalHost().getHostAddress(). In case of two IPs, it won't always work. There is a global variable that holds the IP that was passed in the constructor of the CIMClient, in the namespace object: uri = this.nameSpace.getHostURI(); I think that this global variable (uri) should be used to set the "Destination" property in the CIM listener instance. ---------------------------------------------------------------------- >Comment By: ~Ramandeep Arora~ (raman_arora) Date: 2008-09-24 10:37 Message: As mentioned by Dave that 1.x will remain at Java 1.4. as we dont have isReachable( NIC, , ) available in 1.4 it is not feasible to implement all that in 1.4. we can get all active IP addresses or NIC / eths but unable to ping outside using that specific ip/eth in 1.4. like following code can give all active addresses and your work around (except isReachable) can give eths using 1.4. If there is any work around for 1.4 we will be more than happy to implement and replace getHostIP. private static void printAllAddress(String host) throws Exception { InetAddress[] allAddr = InetAddress.getAllByName(host); for (int i = 0; i < allAddr.length; i++) { System.out.println("Address is :" + allAddr[i]); if ( ! (allAddr[i].isAnyLocalAddress() || allAddr[i].isLinkLocalAddress() || allAddr[i].isLoopbackAddress() ) ) { System.out.println("Address :" + allAddr[i]); } } } ---------------------------------------------------------------------- Comment By: Dave Blaschke (blaschke-oss) Date: 2008-09-05 06:37 Message: Logged In: YES user_id=1215427 Originator: NO There is talk for the 2.x stream to move up to Java 5, but none at this time for 1.x since it is in maintenance mode. We will look and see what we can so with your proposed solution. Lowering the priority back to 5 (medium) since there is a workaround available for the problem. Feel free to raise it back if you deem necessary. Thanks for your input. ---------------------------------------------------------------------- Comment By: Alon Aradi (allonr) Date: 2008-08-28 02:12 Message: Logged In: YES user_id=2099974 Originator: YES Eventually we wrote a work around to get the right IP. We are going through all the NICs on the system and try to ping the CIMOM. We use the IP associated with the first NIC that successfully pinged the CIMOM. I suggest you use the same technique. Here is the method we use (compiles only with JAVA 5) : private static String getLocalServerAddress(String destination) { try { InetAddress inetAddr = InetAddress.getByName(destination); Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface nif : Collections.list(interfaces)) { try { if (inetAddr.isReachable(nif, 0, 10000)) { InetAddress saveIpV6 = null; Enumeration <InetAddress> localAddrs = nif.getInetAddresses(); for (InetAddress locAddr : Collections.list(localAddrs)) { if (locAddr instanceof Inet4Address) { String ipAddr = locAddr.getHostAddress(); return ipAddr; } if (locAddr instanceof Inet6Address) { saveIpV6 = locAddr; } } if (saveIpV6 != null) { String ipAddr = "[" + saveIpV6.getHostAddress() + "]"; return ipAddr; } } } catch (IOException e) { Logger.throwing(e); } } } catch (UnknownHostException e) { Logger.throwing(e); } catch (SocketException e) { Logger.throwing(e); } return InetAddress.getLocalHost().getHostAddress(); } ---------------------------------------------------------------------- Comment By: Dave Blaschke (blaschke-oss) Date: 2008-06-19 08:18 Message: Logged In: YES user_id=1215427 Originator: NO Note from Alon: I tested it now with the latest build on couple of our machines and it didn't work as you can see here: String ip = iServerSocket.getInetAddress().getHostAddress(); ---> always returns "0.0.0.0" String localhost = InetAddress.getLocalHost().getHostAddress(); return "0.0.0.0".equals(ip) ? localhost : ip; ---------------------------------------------------------------------- Comment By: Dave Blaschke (blaschke-oss) Date: 2008-06-04 15:11 Message: Logged In: YES user_id=1215427 Originator: NO Just for grins, could you please try replacing the current HttpServerConnection.getHostIP() with the following code: String ip = iServerSocket.getInetAddress().getHostAddress(); String localhost = InetAddress.getLocalHost().getHostAddress(); return "0.0.0.0".equals(ip) ? localhost : ip; That is the logic that 2.x uses... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=712784&aid=1975134&group_id=128809 |