java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml | 7
+
java/code/src/com/redhat/rhn/domain/server/ServerFactory.java | 12
++
java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java | 47
+++++-----
java/code/webapp/WEB-INF/pages/systems/sdc/hardware.jsp | 40
+++++++-
4 files changed, 82 insertions(+), 24 deletions(-)
New commits:
commit c5562a1153aa929fef027a99d94290313aa14432
Author: Colin Coe <coec(a)war.coesta.com>
Date: Fri Aug 27 23:34:29 2010 +0800
624377 - restore original functionality and information
diff --git a/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
b/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
index 0551660..917b583 100644
--- a/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
@@ -35,7 +35,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<query name="Device.findStorageByServer">
<![CDATA[from com.redhat.rhn.domain.server.Device as t
- where t.server = :server and (t.deviceClass = 'HD' or
t.deviceClass = 'FLOPPY')
+ where t.server = :server and t.deviceClass = 'HD'
order by t.device]]>
</query>
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
index 66e2c39..766c989 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -119,7 +119,7 @@ public class ServerFactory extends HibernateFactory {
/**
* Lookup all storage Devices associated with the server.
- * @param sid The server ID for the values you would like to lookup
+ * @param s The server for the values you would like to lookup
* @return List of devices
*/
public static List<Device> lookupStorageDevicesByServer(Server s) {
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
index 9a716eb..c269d2e 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
@@ -103,7 +103,7 @@ public class SystemHardwareAction extends RhnAction {
request.setAttribute("system_ram", server.getRam());
request.setAttribute("system_swap", server.getSwap());
- StringBuffer dmiBios = new StringBuffer();
+ StringBuffer dmiBios = new StringBuffer();
if (server.getDmi().getBios() != null) {
if (server.getDmi().getBios().getVendor() != null &&
server.getDmi().getBios().getVendor() != "") {
@@ -149,7 +149,6 @@ public class SystemHardwareAction extends RhnAction {
}
request.setAttribute("network_interfaces", nicList2);
-// List<Device> hdd = new ArrayList();
List<String> hdd = new ArrayList();
List miscDevices = new ArrayList();
List videoDevices = new ArrayList();
@@ -182,7 +181,7 @@ public class SystemHardwareAction extends RhnAction {
device.put("device", d.getDevice());
device.put("driver", d.getDriver());
device.put("pcitype", d.getPcitype().toString());
- if ((d.getDeviceClass().equals("HD")) ||
(d.getDeviceClass().equals("FLOPPY"))) {
+ if (d.getDeviceClass().equals("HD")) {
continue;
}
else if (d.getDeviceClass().equals("VIDEO")) {
@@ -204,22 +203,8 @@ public class SystemHardwareAction extends RhnAction {
}
}
-// Collections.sort(hdd);
-// List storageDevices = new ArrayList();
-// for (Device hd : hdd) {
-//System.out.println("2 - Found storage device: " + hd);
-// Device d = server.getDevice(hd);
-// Map device = new HashMap();
-// device.put("description", d.getDescription());
-// device.put("device", d.getDevice());
-// device.put("bus", d.getBus());
-// storageDevices.add(device);
-// }
-
-// Collections.sort(hdd);
- List<Device> values = ServerFactory.lookupStorageDevicesByServer(server);
List storageDevices = new ArrayList();
- for (Device hd : values) {
+ for (Device hd :
(List<Device>)ServerFactory.lookupStorageDevicesByServer(server)) {
Device d = hd;
Map device = new HashMap();
device.put("description", d.getDescription());
@@ -227,7 +212,7 @@ public class SystemHardwareAction extends RhnAction {
device.put("bus", d.getBus());
storageDevices.add(device);
}
-System.out.println("storageDevices.size() = " + storageDevices.size());
+
request.setAttribute("storageDevices", storageDevices);
request.setAttribute("videoDevices", videoDevices);
request.setAttribute("audioDevices", audioDevices);
commit 82727ccbf4e53c4bab2071e906d0b314a9b65732
Author: Colin Coe <colin.coe(a)gmail.com>
Date: Fri Aug 27 13:04:09 2010 +0800
Fix hardware page
diff --git a/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
b/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
index 426561b..0551660 100644
--- a/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/Device.hbm.xml
@@ -32,4 +32,11 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
insert="false" update="false"/>
</class>
+
+ <query name="Device.findStorageByServer">
+ <![CDATA[from com.redhat.rhn.domain.server.Device as t
+ where t.server = :server and (t.deviceClass = 'HD' or
t.deviceClass = 'FLOPPY')
+ order by t.device]]>
+ </query>
+
</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
index 3ac38ac..66e2c39 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -118,6 +118,18 @@ public class ServerFactory extends HibernateFactory {
}
/**
+ * Lookup all storage Devices associated with the server.
+ * @param sid The server ID for the values you would like to lookup
+ * @return List of devices
+ */
+ public static List<Device> lookupStorageDevicesByServer(Server s) {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("server", s);
+ return (List<Device>) singleton.listObjectsByNamedQuery(
+ "Device.findStorageByServer", params);
+ }
+
+ /**
* Get the Logger for the derived class so log messages show up on the
* correct class
*/
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
index 1d5910d..9a716eb 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemHardwareAction.java
@@ -19,6 +19,7 @@ import com.redhat.rhn.domain.action.ActionFactory;
import com.redhat.rhn.domain.server.CPU;
import com.redhat.rhn.domain.server.Device;
import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.server.NetworkInterface;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.struts.RequestContext;
@@ -102,10 +103,26 @@ public class SystemHardwareAction extends RhnAction {
request.setAttribute("system_ram", server.getRam());
request.setAttribute("system_swap", server.getSwap());
+ StringBuffer dmiBios = new StringBuffer();
+ if (server.getDmi().getBios() != null) {
+ if (server.getDmi().getBios().getVendor() != null &&
+ server.getDmi().getBios().getVendor() != "") {
+ dmiBios.append(server.getDmi().getBios().getVendor() + " ");
+ }
+ if (server.getDmi().getBios().getVersion() != null &&
+ server.getDmi().getBios().getVersion() != "") {
+ dmiBios.append(server.getDmi().getBios().getVersion() + " ");
+ }
+ if (server.getDmi().getBios().getRelease() != null &&
+ server.getDmi().getBios().getRelease() != "") {
+ dmiBios.append(server.getDmi().getBios().getRelease());
+ }
+ }
+
request.setAttribute("dmi_vendor", server.getDmi().getVendor());
request.setAttribute("dmi_system", server.getDmi().getSystem());
request.setAttribute("dmi_product", server.getDmi().getProduct());
- request.setAttribute("dmi_bios", server.getDmi().getBios());
+ request.setAttribute("dmi_bios", dmiBios.toString());
request.setAttribute("dmi_asset_tag", server.getDmi().getAsset());
request.setAttribute("dmi_board", server.getDmi().getBoard());
@@ -132,12 +149,7 @@ public class SystemHardwareAction extends RhnAction {
}
request.setAttribute("network_interfaces", nicList2);
- List<String> deviceList = new ArrayList();
- for (Device d : server.getDevices()) {
- deviceList.add(d.getDescription());
- }
- Collections.sort(deviceList);
-
+// List<Device> hdd = new ArrayList();
List<String> hdd = new ArrayList();
List miscDevices = new ArrayList();
List videoDevices = new ArrayList();
@@ -150,10 +162,12 @@ public class SystemHardwareAction extends RhnAction {
String desc = null;
String vendor = null;
- StringTokenizer st = new StringTokenizer(d.getDescription(), "|");
- vendor = st.nextToken();
- if (st.hasMoreTokens()) {
- desc = st.nextToken();
+ if (d.getDescription() != null) {
+ StringTokenizer st = new StringTokenizer(d.getDescription(),
"|");
+ vendor = st.nextToken();
+ if (st.hasMoreTokens()) {
+ desc = st.nextToken();
+ }
}
if (desc != null) {
@@ -168,11 +182,8 @@ public class SystemHardwareAction extends RhnAction {
device.put("device", d.getDevice());
device.put("driver", d.getDriver());
device.put("pcitype", d.getPcitype().toString());
- if ((d.getDeviceClass().equals("HD")) ||
- (d.getDeviceClass().equals("FLOPPY"))) {
- if (d.getDevice() != null) {
- hdd.add(d.getDevice());
- }
+ if ((d.getDeviceClass().equals("HD")) ||
(d.getDeviceClass().equals("FLOPPY"))) {
+ continue;
}
else if (d.getDeviceClass().equals("VIDEO")) {
videoDevices.add(device);
@@ -193,17 +204,30 @@ public class SystemHardwareAction extends RhnAction {
}
}
- Collections.sort(hdd);
+// Collections.sort(hdd);
+// List storageDevices = new ArrayList();
+// for (Device hd : hdd) {
+//System.out.println("2 - Found storage device: " + hd);
+// Device d = server.getDevice(hd);
+// Map device = new HashMap();
+// device.put("description", d.getDescription());
+// device.put("device", d.getDevice());
+// device.put("bus", d.getBus());
+// storageDevices.add(device);
+// }
+
+// Collections.sort(hdd);
+ List<Device> values = ServerFactory.lookupStorageDevicesByServer(server);
List storageDevices = new ArrayList();
- for (String hd : hdd) {
- Device d = server.getDevice(hd);
+ for (Device hd : values) {
+ Device d = hd;
Map device = new HashMap();
device.put("description", d.getDescription());
device.put("device", d.getDevice());
device.put("bus", d.getBus());
storageDevices.add(device);
}
-
+System.out.println("storageDevices.size() = " + storageDevices.size());
request.setAttribute("storageDevices", storageDevices);
request.setAttribute("videoDevices", videoDevices);
request.setAttribute("audioDevices", audioDevices);
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/hardware.jsp
b/java/code/webapp/WEB-INF/pages/systems/sdc/hardware.jsp
index 1681d45..ec949aa 100644
--- a/java/code/webapp/WEB-INF/pages/systems/sdc/hardware.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/hardware.jsp
@@ -82,7 +82,7 @@
<c:if test="${empty dmi_asset_tag}" var="no_asset_tag"/>
<c:if test="${empty dmi_board}" var="no_board"/>
- <c:if test="${not (no_vendor or no_bios or no_system or no_product or
no_asset_tag or no_board)}">
+ <c:if test="${!(empty dmi_vendor and empty dmi_bios and empty dmi_system and
empty dmi_product and empty dmi_asset_tag and empty dmi_board)}">
<h2><bean:message
key="sdc.details.hardware.dmi"/></h2>
<table class="details">
<tr>
@@ -175,15 +175,44 @@
</c:choose>
<tr class="${style_class}">
<td>${current.name}</td>
- <td>${current.ip}</td>
- <td>${current.netmask}</td>
- <td>${current.broadcast}</td>
- <td>${current.hwaddr}</td>
+ <c:choose>
+ <c:when test="${empty current.ip}">
+ <td><span
class="no-details">(unknown)</span></td>
+ </c:when>
+ <c:otherwise>
+ <td>${current.ip}</td>
+ </c:otherwise>
+ </c:choose>
+ <c:choose>
+ <c:when test="${empty current.netmask}">
+ <td><span
class="no-details">(unknown)</span></td>
+ </c:when>
+ <c:otherwise>
+ <td>${current.netmask}</td>
+ </c:otherwise>
+ </c:choose>
+ <c:choose>
+ <c:when test="${empty current.broadcast}">
+ <td><span
class="no-details">(unknown)</span></td>
+ </c:when>
+ <c:otherwise>
+ <td>${current.broadcast}</td>
+ </c:otherwise>
+ </c:choose>
+ <c:choose>
+ <c:when test="${empty current.hwaddr}">
+ <td><span
class="no-details">(unknown)</span></td>
+ </c:when>
+ <c:otherwise>
+ <td>${current.hwaddr}</td>
+ </c:otherwise>
+ </c:choose>
<td>${current.module}</td>
</tr>
</c:forEach>
</table>
+ <c:if test="${not empty videoDevices}">
<h2><bean:message
key="sdc.details.hardware.storage"/></h2>
<table class="list" width="90%" cellspacing="0">
<thead>
@@ -213,6 +242,7 @@
</c:forEach>
</tbody>
</table>
+ </c:if>
<c:if test="${not empty videoDevices}">
<h2><bean:message
key="sdc.details.hardware.video"/></h2>