Martin Sivák has uploaded a new change for review.

Change subject: [WIP] Expose the HBA devices in frontend
......................................................................

[WIP] Expose the HBA devices in frontend

Change-Id: I44efcf1feabb3491aa46bd9294b14424483872c1
Signed-off-by: Martin Sivak <[email protected]>
---
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/HABItem.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostHardwareView.java
4 files changed, 114 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/15091/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/HABItem.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/HABItem.java
new file mode 100644
index 0000000..d068ef5
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/HABItem.java
@@ -0,0 +1,33 @@
+package org.ovirt.engine.ui.common.widget.form;
+
+import org.ovirt.engine.ui.common.widget.label.TextBoxLabel;
+public class HABItem extends FormBuilder {
+
+    TextBoxLabel interfaceName;
+    TextBoxLabel interfaceType;
+    TextBoxLabel interfaceWWNN;
+    TextBoxLabel portWWPNs;
+
+    /**
+     *
+     */
+    public HABItem(GeneralFormPanel formPanel,
+                   String nameLabel, String interfaceName,
+                   String typeLabel, String interfaceType,
+                   String wwnnLabel, String interfaceWWNN,
+                   String wwpnsLabel, String portWWPNs) {
+
+        super(formPanel, 1, 4);
+
+        this.interfaceName.setText(interfaceName);
+        this.interfaceType.setText(interfaceType);
+        this.interfaceWWNN.setText(interfaceWWNN);
+        this.portWWPNs.setText(portWWPNs);
+
+        addFormItem(new FormItem(nameLabel, this.interfaceName, 0, 0));
+        addFormItem(new FormItem(typeLabel, this.interfaceType, 1, 0));
+        addFormItem(new FormItem(wwnnLabel, this.interfaceWWNN, 2, 0));
+        addFormItem(new FormItem(wwpnsLabel, this.portWWPNs, 3, 0));
+    }
+
+}
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java
index c776268..d32c058 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java
@@ -1,5 +1,10 @@
 package org.ovirt.engine.ui.uicommonweb.models.hosts;
 
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
 import org.ovirt.engine.core.compat.StringHelper;
@@ -116,6 +121,7 @@
         return hardwareFamily;
     }
 
+    @SuppressWarnings("deprecation")
     public void setHardwareFamily(String value)
     {
         if (!StringHelper.stringsEqual(hardwareFamily, value))
@@ -123,6 +129,22 @@
             hardwareFamily = value;
             onPropertyChanged(new PropertyChangedEventArgs("family")); 
//$NON-NLS-1$
         }
+    }
+
+    public enum HbaDeviceKeys { MODEL_NAME, // Model name field
+                                TYPE,       // Device type
+                                WWNN,       // WWNN of the NIC
+                                WWNPS       // Comma separated list of WWNPs 
(port ids)
+    };
+
+    private List<EnumMap<HbaDeviceKeys, String>> hbaDevices;
+
+    public List<EnumMap<HbaDeviceKeys, String>> getHbaDevices() {
+        return hbaDevices;
+    }
+
+    public void setHbaDevices(List<EnumMap<HbaDeviceKeys, String>> hbaDevices) 
{
+        this.hbaDevices = hbaDevices;
     }
 
     public HostHardwareGeneralModel()
@@ -147,6 +169,25 @@
         setHardwareUUID(vds.getHardwareUUID());
         setHardwareSerialNumber(vds.getHardwareSerialNumber());
         setHardwareFamily(vds.getHardwareFamily());
+
+        /* Go through the list of HBA devices and transfer the necessary info
+           to the GWT host hardware model */
+        List<EnumMap<HbaDeviceKeys, String>> hbaDevices = new 
ArrayList<EnumMap<HbaDeviceKeys, String>>();
+        List<Map<String, String>> fcDevices = vds.getHBAs().get("FC"); 
//$NON-NLS-1$
+
+        if (fcDevices != null) {
+            for (Map<String, String> device: fcDevices) {
+                EnumMap<HbaDeviceKeys, String> deviceModel = new 
EnumMap<HbaDeviceKeys, String>(HbaDeviceKeys.class);
+                deviceModel.put(HbaDeviceKeys.MODEL_NAME, 
device.get("model")); //$NON-NLS-1$
+                deviceModel.put(HbaDeviceKeys.WWNN, device.get("wwnn")); 
//$NON-NLS-1$
+                deviceModel.put(HbaDeviceKeys.WWNPS, device.get("wwnp")); 
//$NON-NLS-1$
+                deviceModel.put(HbaDeviceKeys.TYPE, "FC"); //$NON-NLS-1$
+
+                hbaDevices.add(deviceModel);
+            }
+        }
+
+        setHbaDevices(hbaDevices);
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 8cd22e6..eca254b 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -1131,8 +1131,20 @@
     @DefaultStringValue("Family")
     String hardwareFamilyGeneral();
 
-    @DefaultStringValue("HAB Inventory")
-    String hardwareHABInventory();
+    @DefaultStringValue("HBA Inventory")
+    String hardwareHBAInventory();
+
+    @DefaultStringValue("Model name")
+    String hbaModelName();
+
+    @DefaultStringValue("Device type")
+    String hbaDeviceType();
+
+    @DefaultStringValue("WWNN")
+    String hbaWWNN();
+
+    @DefaultStringValue("WWPNs")
+    String hbaWWPNs();
 
     @DefaultStringValue("Kernel Version")
     String kernelVersionHostGeneral();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostHardwareView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostHardwareView.java
index bc8a88e..02e584b 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostHardwareView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostHardwareView.java
@@ -1,5 +1,7 @@
 package org.ovirt.engine.ui.webadmin.section.main.view.tab.host;
 
+import java.util.EnumMap;
+
 import javax.inject.Inject;
 
 import org.ovirt.engine.core.common.businessentities.VDS;
@@ -8,6 +10,7 @@
 import org.ovirt.engine.ui.common.widget.form.FormBuilder;
 import org.ovirt.engine.ui.common.widget.form.FormItem;
 import org.ovirt.engine.ui.common.widget.form.GeneralFormPanel;
+import org.ovirt.engine.ui.common.widget.form.HABItem;
 import org.ovirt.engine.ui.common.widget.label.TextBoxLabel;
 import org.ovirt.engine.ui.uicommonweb.models.hosts.HostHardwareGeneralModel;
 import org.ovirt.engine.ui.uicommonweb.models.hosts.HostListModel;
@@ -20,8 +23,8 @@
 import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.client.ui.Widget;
 import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Widget;
 
 public class SubTabHostHardwareView extends AbstractSubTabFormView<VDS, 
HostListModel, HostHardwareGeneralModel> implements 
SubTabHostHardwarePresenter.ViewDef, Editor<HostHardwareGeneralModel> {
 
@@ -41,6 +44,7 @@
     @UiField
     FlowPanel habInventory;
 
+    ApplicationConstants constants;
     FormBuilder formBuilder;
 
     private final Driver driver = GWT.create(Driver.class);
@@ -53,6 +57,7 @@
     public SubTabHostHardwareView(DetailModelProvider<HostListModel, 
HostHardwareGeneralModel> modelProvider,
             ApplicationResources resources, ApplicationConstants constants) {
         super(modelProvider);
+        this.constants = constants;
 
         // Init form panel:
         formPanel = new GeneralFormPanel();
@@ -76,14 +81,30 @@
     @Override
     public void setMainTabSelectedItem(VDS selectedItem) {
         driver.edit(getDetailModel());
-        formBuilder.update(getDetailModel());
 
         /* refresh all the information about HAB (FC, iSCSI) devices */
         habInventory.clear();
-        /* TODO traverse the model and get all the HABs
-           then call the following for each item:
-           habInventory.add(new HABItem(...));
+
+        if (selectedItem != null) {
+
+        /* traverse the model and get all the HABs
          */
+            for (EnumMap<HostHardwareGeneralModel.HbaDeviceKeys, String> 
hbaDevice: getDetailModel().getHbaDevices()) {
+                 formPanel = new GeneralFormPanel();
+                 new HABItem(formPanel,
+                             this.constants.hbaModelName(),
+                             
hbaDevice.get(HostHardwareGeneralModel.HbaDeviceKeys.MODEL_NAME),
+                             this.constants.hbaDeviceType(),
+                             
hbaDevice.get(HostHardwareGeneralModel.HbaDeviceKeys.TYPE),
+                             this.constants.hbaWWNN(),
+                             
hbaDevice.get(HostHardwareGeneralModel.HbaDeviceKeys.WWNN),
+                             this.constants.hbaWWPNs(),
+                             
hbaDevice.get(HostHardwareGeneralModel.HbaDeviceKeys.WWNPS));
+                 habInventory.add(formPanel);
+            }
+        }
+
+        formBuilder.update(getDetailModel());
     }
 
 }


--
To view, visit http://gerrit.ovirt.org/15091
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I44efcf1feabb3491aa46bd9294b14424483872c1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to