Description of problem: API system.getDmi() method does not return any value if some row at DB is null Version-Release number of selected component (if applicable): Spacewalk 1.6 Nightly Version How reproducible: 100% Steps to Reproduce: Look Additional info Actual results: If some rows at RHNSERVERDMI table is blank, system.getDmi() method does not return any value Expected results: system.getDmi() method return the values when RHNSERVERDMI has some blank rows Additional info: python script --------------------- # api-dmi.py import xmlrpclib SATELLITE_URL = "http://<SERVER>/rpc/api" SATELLITE_LOGIN = "<USER>" SATELLITE_PASSWORD = "<PASSWORD>" server = xmlrpclib.Server(SATELLITE_URL, verbose=0) token = server.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD) systems_list = server.system.listSystems(token) for system in systems_list: sys_dmi = server.system.getDmi(token,int(system['id'])) print system['id'] if sys_dmi: print sys_dmi else: print "No DMI information" print "**" * 10 + "\n" server.auth.logout(token) +++++++++++++++++++++++++++++++++++ executing python script --------------------- notebook $> python api-dmi.py 1000010091 {'product': 'KVM', 'vendor': 'Red Hat', 'bios_vendor': 'QEMU', 'system': 'KVM Not Specified', 'bios_release': '01/01/2007', 'board': '', 'bios_version': 'QEMU', 'asset': '(chassis: Not Specified) (chassis: Not Specified) (board: ) (system: Not Specified)'} ******************** 1000010090 {'product': 'KVM', 'vendor': 'Red Hat', 'bios_vendor': 'QEMU', 'system': 'KVM Not Specified', 'bios_release': '01/01/2007', 'board': '', 'bios_version': 'QEMU', 'asset': '(chassis: Not Specified) (chassis: Not Specified) (board: ) (system: Not Specified)'} ******************** 1000010115 {'product': 'ProLiant DL320 G4', 'vendor': 'HP', 'bios_vendor': 'HP', 'system': 'ProLiant DL320 G4 Not Specified', 'bios_release': '07/18/2008', 'board': '', 'bios_version': 'D20', 'asset': '(chassis: USM5450234) (chassis: ) (board: ) (system: USM5450234)'} ******************** 1000010000 {'product': 'SUN BLADE X6240 SERVER MODULE', 'vendor': 'SUN MICROSYSTEMS', 'bios_vendor': 'American Megatrends Inc.', 'system': 'SUN BLADE X6240 SERVER MODULE 0.00.01', 'bios_release': '06/05/2009', 'board': 'SUN MICROSYSTEMS', 'bios_version': '1.17', 'asset': '(chassis: 0000000000) (chassis: Null) (board: 0328MSL-081450009E) (system: 0000000000)'} ******************** 1000010003 No DMI information ******************** +++++++++++++++++++++++++++++++++++ querying database ------------------------ SQL> desc rhnserverdmi; Name Null? Type ----------------------------------------------------------------------------------------------------- -------- -------------------------------------------------------------------- ID NOT NULL NUMBER SERVER_ID NOT NULL NUMBER VENDOR VARCHAR2(256) SYSTEM VARCHAR2(256) PRODUCT VARCHAR2(256) BIOS_VENDOR VARCHAR2(256) BIOS_VERSION VARCHAR2(256) BIOS_RELEASE VARCHAR2(256) ASSET VARCHAR2(256) BOARD VARCHAR2(256) CREATED NOT NULL DATE MODIFIED NOT NULL DATE SQL> set pagesize 180; SQL> set linesize 180; SQL> col VENDOR for a30; SQL> col SYSTEM for a40; SQL> col BIOS_VENDOR for a30; SQL> col BIOS_VERSION for a20; SQL> col BIOS_RELEASE for a15; SQL> col PRODUCT for a50; SQL> col ASSET for a90; SQL> col BOARD for a20; *** Grabbing information from machine which does not returned information at API method() SQL> select ID, SERVER_ID, VENDOR, SYSTEM, PRODUCT from rhnserverdmi where SERVER_ID = 1000010003; ID SERVER_ID VENDOR SYSTEM PRODUCT ---------- ---------- ------------------------------ --------------- -------------------------------------------------- 184 1000010003 American Megatrends Inc. SUN BLADE X8440 SERVER MODULE SQL> select ID, BIOS_VENDOR, BIOS_VERSION, BIOS_RELEASE from rhnserverdmi where SERVER_ID = 1000010003; ID BIOS_VENDOR BIOS_VERSION BIOS_RELEASE ---------- ------------------------------ -------------------- --------------- 184 American Megatrends Inc. 08/06/2008 SQL> select ID, ASSET, BOARD, CREATED, MODIFIED from rhnserverdmi where SERVER_ID = 1000010003; ID ASSET BOARD CREATED MODIFIED ---------- ------------------------------------------------------------------------------------------ -------------------- --------- --------- 184 (chassis: 0735AY0038) (chassis: NULL) (board: 0060HSV-0735000226) (system: 0735AY0038) Sun Microsystems 22-SEP-11 22-SEP-11 *** Grabbing information from machine which returned information at API method() SQL> select ID, SERVER_ID, VENDOR, SYSTEM, PRODUCT from rhnserverdmi where SERVER_ID = 1000010000; ID SERVER_ID VENDOR SYSTEM PRODUCT ---------- ---------- ------------------------------ ---------------------------------------- -------------------------------------------------- 183 1000010000 SUN MICROSYSTEMS SUN BLADE X6240 SERVER MODULE 0.00.01 SUN BLADE X6240 SERVER MODULE SQL> select ID, BIOS_VENDOR, BIOS_VERSION, BIOS_RELEASE from rhnserverdmi where SERVER_ID = 1000010000; ID BIOS_VENDOR BIOS_VERSION BIOS_RELEASE ---------- ------------------------------ -------------------- --------------- 183 American Megatrends Inc. 1.17 06/05/2009 SQL> select ID, ASSET, BOARD, CREATED, MODIFIED from rhnserverdmi where SERVER_ID = 1000010000; ID ASSET BOARD CREATED MODIFIED ---------- ------------------------------------------------------------------------------------------ -------------------- --------- --------- 183 (chassis: 0000000000) (chassis: Null) (board: 0328MSL-081450009E) (system: 0000000000) SUN MICROSYSTEMS 22-SEP-11 22-SEP-11 As we can see above, the different beetwen the both boxes is that one of them does not have BIOS_VERSION and SYSTEM rows filled (the missing box were not displayed by API method) *** Troubleshooting *** To check if the issue were related with the missing information, we filled manually the missing rows and re-run the script as below: SQL> update rhnserverdmi set SYSTEM = 'SYSTEM_MANUAL_FILLED', BIOS_VERSION = '1.17' where SERVER_ID = 1000010003; 1 row updated. SQL> select ID, SERVER_ID, VENDOR, SYSTEM, PRODUCT from rhnserverdmi where SERVER_ID = 1000010003; ID SERVER_ID VENDOR SYSTEM PRODUCT ---------- ---------- ------------------------------ ---------------------------------------- -------------------------------------------------- 184 1000010003 American Megatrends Inc. SYSTEM_MANUAL_FILLED SUN BLADE X8440 SERVER MODULE SQL> select ID, BIOS_VENDOR, BIOS_VERSION, BIOS_RELEASE from rhnserverdmi where SERVER_ID = 1000010003; ID BIOS_VENDOR BIOS_VERSION BIOS_RELEASE ---------- ------------------------------ -------------------- --------------- 184 American Megatrends Inc. 1.17 08/06/2008 SQL> commit; Commit complete. ** Executing the python script ---------------------------------- notebook $> python api-dmi.py { ... SNIP ... } 1000010000 {'product': 'SUN BLADE X6240 SERVER MODULE', 'vendor': 'SUN MICROSYSTEMS', 'bios_vendor': 'American Megatrends Inc.', 'system': 'SUN BLADE X6240 SERVER MODULE 0.00.01', 'bios_release': '06/05/2009', 'board': 'SUN MICROSYSTEMS', 'bios_version': '1.17', 'asset': '(chassis: 0000000000) (chassis: Null) (board: 0328MSL-081450009E) (system: 0000000000)'} ******************** 1000010003 {'product': 'SUN BLADE X8440 SERVER MODULE', 'vendor': 'American Megatrends Inc.', 'bios_vendor': 'American Megatrends Inc.', 'system': 'SYSTEM_MANUAL_FILLED', 'bios_release': '08/06/2008', 'board': 'Sun Microsystems', 'bios_version': '1.17', 'asset': '(chassis: 0735AY0038) (chassis: NULL) (board: 0060HSV-0735000226) (system: 0735AY0038)'} ******************** As we can see the issue is related when RHNSERVERDMI table misses some information, API does not return any information. SQL> select ID, SERVER_ID, VENDOR, SYSTEM, PRODUCT from rhnserverdmi where SERVER_ID = 1000010003; ID SERVER_ID VENDOR SYSTEM PRODUCT ---------- ---------- ------------------------------ ---------------------------------------- -------------------------------------------------- 184 1000010003 American Megatrends Inc. SUN BLADE X8440 SERVER MODULE SQL> commit; Commit complete. notebook $> python api-dmi.py { ... SNIP ... } 1000010000 {'product': 'SUN BLADE X6240 SERVER MODULE', 'vendor': 'SUN MICROSYSTEMS', 'bios_vendor': 'American Megatrends Inc.', 'system': 'SUN BLADE X6240 SERVER MODULE 0.00.01', 'bios_release': '06/05/2009', 'board': 'SUN MICROSYSTEMS', 'bios_version': '1.17', 'asset': '(chassis: 0000000000) (chassis: Null) (board: 0328MSL-081450009E) (system: 0000000000)'} ******************** 1000010003 No DMI information ********************
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java ----------------------------------------- 2839 /** 2840 * Gets the hardware profile of a specific system 2841 * 2842 * @param sessionKey User's session key 2843 * @param sid This system's ID 2844 * @return Map contianing the DMI information of the system 2845 * 2846 * @xmlrpc.doc Gets the DMI information of a system. 2847 * @xmlrpc.param #param("string", "sessionKey") 2848 * @xmlrpc.param #param("int", "serverId") 2849 * @xmlrpc.returntype 2850 * $DmiSerializer 2851 */ 2852 public Object getDmi(String sessionKey, Integer sid) { 2853 User loggedInUser = getLoggedInUser(sessionKey); 2854 Server server = lookupServer(loggedInUser, sid); 2855 Dmi dmi = server.getDmi(); 2856 if (dmi == null) { 2857 return new HashMap(); 2858 } 2859 return dmi; 2860 } java/code/src/com/redhat/rhn/domain/server/Dmi.java ---------------------------------------- 26 public class Dmi extends BaseDomainHelper { 27 28 private Long id; 29 private Server server; 30 private String vendor; 31 private String system; 32 private String product; 33 private Bios bios; 34 private String asset; 35 private String board; java/code/src/com/redhat/rhn/domain/server/Dmi.hbm.xml ----------------------------------------- 5 <hibernate-mapping> 6 <class name="com.redhat.rhn.domain.server.Dmi" table="rhnServerDmi"> 7 <id name="id" type="long" column="id"> 8 <meta attribute="scope-set">protected</meta> 9 <generator class="sequence"> 10 <param name="sequence">rhn_ram_id_seq</param> 11 </generator> 12 </id> 13 14 <many-to-one name="server" 15 class="com.redhat.rhn.domain.server.Server" 16 column="server_id" /> 17 <property name="vendor" column="vendor" type="string" length="256" /> 18 >--->---<property name="system" column="system" type="string" length="256" /> 19 >--->---<property name="product" column="product" type="string" length="256" /> 20 >--->---<property name="asset" column="asset" type="string" length="256" /> 21 >--->---<property name="board" column="board" type="string" length="256" /> 22 <property name="created" column="created" type="timestamp" 23 insert="false" update="false"/> 24 <property name="modified" column="modified" type="timestamp" 25 insert="false" update="false"/> 26 27 <component name="bios" class="com.redhat.rhn.domain.server.Dmi$Bios"> 28 <property name="vendor" column="bios_vendor" 29 type="string" length="256" /> 30 <property name="version" column="bios_version" 31 type="string" length="256" /> 32 <property name="release" column="bios_release" 33 type="string" length="256" /> 34 </component> 35 36 </class> 37 </hibernate-mapping> HIBERNATE DEBBUGING ======================================= 2757 [2011-09-26 21:22:37,453] INFO - Reading mappings from resource : com/redhat/rhn/domain/server/Dmi.hbm.xml 2758 [2011-09-26 21:22:37,454] DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] 2759 [2011-09-26 21:22:37,454] DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/ 2760 [2011-09-26 21:22:37,454] DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath 2761 [2011-09-26 21:22:37,457] INFO - Mapping class: com.redhat.rhn.domain.server.Dmi -> rhnServerDmi 2762 [2011-09-26 21:22:37,457] DEBUG - Mapped property: id -> id 2763 [2011-09-26 21:22:37,457] DEBUG - Mapped property: server -> server_id 2764 [2011-09-26 21:22:37,457] DEBUG - Mapped property: vendor -> vendor 2765 [2011-09-26 21:22:37,457] DEBUG - Mapped property: system -> system 2766 [2011-09-26 21:22:37,458] DEBUG - Mapped property: product -> product 2767 [2011-09-26 21:22:37,458] DEBUG - Mapped property: asset -> asset 2768 [2011-09-26 21:22:37,458] DEBUG - Mapped property: board -> board 2769 [2011-09-26 21:22:37,458] DEBUG - Mapped property: created -> created 2770 [2011-09-26 21:22:37,458] DEBUG - Mapped property: modified -> modified 2771 [2011-09-26 21:22:37,458] DEBUG - Mapped property: vendor -> bios_vendor 2772 [2011-09-26 21:22:37,458] DEBUG - Mapped property: version -> bios_version 2773 [2011-09-26 21:22:37,458] DEBUG - Mapped property: release -> bios_release 2774 [2011-09-26 21:22:37,458] DEBUG - Mapped property: bios -> bios_vendor, bios_version, bios_release ++++++ DMI #183 (working box) 38078 [2011-09-26 21:23:13,015] DEBUG - com.redhat.rhn.domain.server.MonitoredServer{virtualInstance=null, dmi=com.redhat.rhn.domain.server.Dmi#183, configChannelsHibernate=[com.redhat.rhn.domain.config.ConfigChannel#2], notes=<uninitialized>, probes=<uninitialized>, channelsChanged=26 July 2011 , pushClient=com.redhat.rhn.domain.server.PushClient#3, networks=<uninitialized>, virtualGuests=<uninitialized>, release=5Server, modified=2011-09-12 20:59:02, name=sun-x6240-1.gsslab.rdu.redhat.com, channels=<uninitialized>, serverInfo=com.redhat.rhn.domain.server.ServerInfo#1000010000, history=<uninitialized>, groups=<uninitialized>, autoUpdate=N, id=1000010000, localChannels=<uninitialized>, runningKernel=2.6.18-238.12.1.el5, devices=<uninitialized>, ram=com.redhat.rhn.domain.server.Ram#183, serverUuid=null, org=com.redhat.rhn.domain.org.Org#3, os=redhat-release, cpu=com.redhat.rhn.domain.server.CPU#183, created=2011-07-12 12:27:12, lastBoot=1310497216, cobblerId=MTMxNTg2MTkxOS45MjM4NDY3MTQuNDM4MzE, networkInterfaces=<uninitialized>, lock=null, creator=com.redhat.rhn.domain.user.legacy.UserImpl#3, packages=<uninitialized>, info=null, secret=358d8242059dba7e5b8e8daa592c9935, location=null, capabilities=<uninitialized>, autoDeliver=N, digitalServerId=ID-1000010000, serverArch=com.redhat.rhn.domain.server.ServerArch#1017, proxyInfo=null, provisionState=null, description=Initial Registration Parameters: 38079 OS: redhat-release 38080 Release: 5Server 38081 CPU Arch: x86_64-redhat-linux, customDataValues=<uninitialized>} 38085 [2011-09-26 21:23:13,015] DEBUG - com.redhat.rhn.domain.server.Dmi{asset=(chassis: 0000000000) (chassis: Null) (board: 0328MSL-081450009E) (system: 0000000000), server=com.redhat.rhn.domain.server.Server#1000010000, board=SUN MICROSYSTEMS, created=2011-09-22 16:53:24, vendor=SUN MICROSYSTEMS, modified=2011-09-22 16:53:24, bios=component[vendor,version,release]{release=06/05/2009, version=1.17, vendor=American Megatrends Inc.}, id=183, product=SUN BLADE X6240 SERVER MODULE, system=SUN BLADE X6240 SERVER MODULE 0.00.01} ++++++ DMI#184 (issue box --> missing SYSTEM information) 38378 [2011-09-26 21:23:13,355] DEBUG - com.redhat.rhn.domain.server.MonitoredServer{virtualInstance=null, dmi=com.redhat.rhn.domain.server.Dmi#184, co nfigChannelsHibernate=[com.redhat.rhn.domain.config.ConfigChannel#2], notes=<uninitialized>, probes=<uninitialized>, channelsChanged=26 July 2011 , pushClient=com.redhat.rhn.domain.server.PushClient#2, networks=<uninitialized>, virtualGuests=<uninitialized>, release=6Server, modified=2011-09-23 12:42:58, name=sun-x8440.gsslab.rdu.redhat.com, channels=<uninitialized>, serverInfo=com.redhat.rhn.domain.server.ServerInfo#1000010003, history=<uninitialized>, groups=<uninitialized>, autoUpdate=N, id=1000010003, localChannels=<uninitialized>, runningKernel=2.6.32-71.el6.x86_64, devices=<uninitialized>, ram=com.redhat.rhn.domain.server.Ram#184, serverUuid=null, org=com.redhat.rhn.domain.org.Org#3, os=redhat-release-server, cpu=com.redhat.rhn.domain.server.CPU#184, created=2011-07-18 14:13:09, lastBoot=1311777842, cobblerId=MTMxNjc5MjExMC43ODQ2NTQxNjYuODgxMTM, networkInterfaces=<uninitialized>, lock=null, creator=com.redhat.rhn.domain.user.legacy.UserImpl#3, packages=<uninitialized>, info=null, secret=5ab8204f317185805bef469b30134077, location=null, capabilities=<uninitialized>, autoDeliver=N, digitalServerId=ID-1000010003, serverArch=com.redhat.rhn.domain.server.ServerArch#1017, proxyInfo=null, provisionState=null, description=Initial Registration Parameters: 38379 OS: redhat-release-server 38380 Release: 6Server 38381 CPU Arch: x86_64, customDataValues=<uninitialized>} 38384 [2011-09-26 21:23:13,355] DEBUG - com.redhat.rhn.domain.server.Dmi{asset=(chassis: 0735AY0038) (chassis: NULL) (board: 0060HSV-0735000226) (system: 0735AY0038), server=com.redhat.rhn.domain.server.Server#1000010003, board=Sun Microsystems, created=2011-09-22 16:53:30, vendor=American Megatrends Inc., modified=2011-09-26 20:30:07, bios=component[vendor,version,release]{release=08/06/2008, version=1.17, vendor=American Megatrends Inc.}, id=184, product=SUN BLADE X8440 SERVER MODULE, system=null}
Hello, Investigation further the issue we could verify that the issue happens when SYSTEM field at DB is NULL/BLANK. Look below: SQL> update rhnserverdmi set BIOS_VERSION = '' where SERVER_ID = 1000010003; SQL> update rhnserverdmi set BIOS_VENDOR = '' where SERVER_ID = 1000010003; SQL> update rhnserverdmi set PRODUCT = '' where SERVER_ID = 1000010003; SQL> update rhnserverdmi set BOARD = '' where SERVER_ID = 1000010003; SQL> update rhnserverdmi set VENDOR = '' where SERVER_ID = 1000010003; SQL> update rhnserverdmi set ASSET = '' where SERVER_ID = 1000010003; SQL> select ID, SERVER_ID, VENDOR, SYSTEM, PRODUCT from rhnserverdmi where SERVER_ID = 1000010003; ID SERVER_ID VENDOR SYSTEM PRODUCT ---------- ---------- ------------------------------ ------------------------------ -------------------------------------------------- 184 1000010003 SYSTEM_MANUAL_FILLED SQL> select ID, BIOS_VENDOR, BIOS_VERSION, BIOS_RELEASE from rhnserverdmi where SERVER_ID = 1000010003; ID BIOS_VENDOR BIOS_VERSION BIOS_RELEASE ---------- ------------------------------ -------------------- --------------- 184 1.17 SQL> select ID, ASSET, BOARD, CREATED, MODIFIED from rhnserverdmi where SERVER_ID = 1000010003; ID ASSET BOARD CREATED MODIFIED ---------- ------------------------------------------------------------------------------------------ -------------------- --------- --------- 184 22-SEP-11 27-SEP-11 Calling API method ------------------------------- notebook $> python api-dmi.py { ... SNIP ... } ******************** 1000010003 {'product': '', 'vendor': '', 'bios_vendor': '', 'system': 'SYSTEM_MANUAL_FILLED', 'bios_release': '', 'board': '', 'bios_version': '1.17', 'asset': ''} ******************** ******* Setting SYSTEM to BLANK SQL> update rhnserverdmi set SYSTEM = '' where SERVER_ID = 1000010003; 1 row updated SQL> commit; Commit complete. SQL> select ID, SERVER_ID, VENDOR, SYSTEM, PRODUCT from rhnserverdmi where SERVER_ID = 1000010003; ID SERVER_ID VENDOR SYSTEM PRODUCT ---------- ---------- ------------------------------ ------------------------------ -------------------------------------------------- 184 1000010003 Calling API method ------------------------------- notebook $> python api-dmi.py { ... SNIP ... } ******************** 1000010003 No DMI information ******************** hibernate log ---------------------------- 114331 [2011-09-27 15:09:53,749] DEBUG - com.redhat.rhn.domain.server.ServerInfo{server=com.redhat.rhn.domain.server.Server#1000010003, id=1000010003, checkin=2011-09-27 14:34:08, checkinCounter=3132} 114332 [2011-09-27 15:09:53,749] DEBUG - com.redhat.rhn.domain.server.Dmi{asset=null, server=com.redhat.rhn.domain.server.Server#1000010003, board=null, created=2011-09-22 16:53:30, vendor=null, modified=2011-09-27 15:08:50, bios=component[vendor,version,release]{release=null, version=1.17, vendor=null}, id=184, product=null, system=null} Still investigating... Best, mmello
This behaviour was introduced by fix to bug 452956 which added + if (dmi.getSystem() == null) { + return; + } to java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/DmiSerializer.java. In other words, exactly the behaviour you observe.
Hello Jan, Thank your for heads up. Working into the patch. Best, mmello
Created attachment 526335 [details] patch proposed Hello, Follow a patch addressed to this BZ. Created an test package and worked as expected. Patch already sent to spacewalk-devel maillist Mail Thread: https://www.redhat.com/archives/spacewalk-devel/2011-October/msg00000.html Best, mmello
Created attachment 526570 [details] patch proposed Better looking patch
Created attachment 526817 [details] patch proposed Please, mail thread -> https://www.redhat.com/archives/spacewalk-devel/2011-October/msg00009.html
Fixed in Spacewalk master, 6742bdedf6669d146316da043048ab16f0862ca9.
Spacewalk 1.6 has been released.