Eliraz Levi has uploaded a new change for review.

Change subject: engine: adding out of sync indication
......................................................................

engine: adding out of sync indication

Bug-Url: https://bugzilla.redhat.com/1058675

Change-Id: I202527cce11cee02756c63ea338bbd888402381f
Signed-off-by: Eliraz Levi <el...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/ItemInfoPopup.java
3 files changed, 158 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/96/42396/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
index ae01ee0..080d4fc 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
@@ -24,6 +24,7 @@
 import org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import org.ovirt.engine.core.common.businessentities.network.NetworkAttachment;
+import 
org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
@@ -35,6 +36,7 @@
 import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.INewAsyncCallback;
 import org.ovirt.engine.ui.uicommonweb.BaseCommandTarget;
+import org.ovirt.engine.ui.uicommonweb.Linq;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
 import org.ovirt.engine.ui.uicommonweb.action.SimpleAction;
 import org.ovirt.engine.ui.uicommonweb.action.UiAction;
@@ -129,6 +131,10 @@
     private Map<String, NetworkLabelModel> networkLabelMap = new HashMap<>();
 
     private final NewNetworkLabelModel newLabelModel;
+
+    public List<NetworkAttachment> getExistingNetworkAttachments() {
+        return existingNetworkAttachments;
+    }
 
     private List<NetworkAttachment> existingNetworkAttachments;
 
@@ -636,6 +642,25 @@
         networkMap.put(networkName, networkModel);
         return networkModel;
     }
+    private ReportedConfigurations reportedConfigurationByNetworkName(String 
networkName){
+        final NetworkAttachment networkAttachment = 
networkAttachmentByNetworkName(networkName);
+        ReportedConfigurations reportedConfigurations = 
networkAttachment.getReportedConfigurations();
+        return reportedConfigurations;
+    }
+
+    private NetworkAttachment networkAttachmentByNetworkName(final String 
networkName) {
+        if (networkName == null) {
+            return null;
+        }
+        NetworkAttachment networkAttachment =
+                Linq.firstOrDefault(getExistingNetworkAttachments(), new 
Linq.IPredicate<NetworkAttachment>() {
+                    @Override
+                    public boolean match(NetworkAttachment networkAttachment) {
+                        return 
networkName.equals(networkAttachment.getNetworkName());
+                    }
+                });
+        return networkAttachment;
+    }
 
     //TODO MM: weird.
     private boolean equals(NetworkItemModel<?> item1, NetworkItemModel<?> 
item2) {
@@ -678,7 +703,8 @@
     private void initNetworkModels() {
         Map<String, LogicalNetworkModel> networkModels = new HashMap<>();
         for (Network network : allNetworks) {
-            LogicalNetworkModel networkModel = new 
LogicalNetworkModel(network, this);
+            ReportedConfigurations reportedConfigurations = 
reportedConfigurationByNetworkName(network.getName());
+            LogicalNetworkModel networkModel = new 
LogicalNetworkModel(network, reportedConfigurations, this);
             networkModels.put(network.getName(), networkModel);
 
             if (networkModel.isManagement()) {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
index f694f32..d1e320c 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
@@ -5,8 +5,8 @@
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.NetworkBootProtocol;
 import org.ovirt.engine.core.common.businessentities.network.NetworkStatus;
+import 
org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
-import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails;
 import org.ovirt.engine.core.common.businessentities.network.Vlan;
 import org.ovirt.engine.ui.uicommonweb.models.hosts.DcNetworkParams;
 import org.ovirt.engine.ui.uicommonweb.models.hosts.HostSetupNetworksModel;
@@ -24,11 +24,19 @@
     private NetworkInterfaceModel attachedToNic;
     private NetworkInterfaceModel vlanNicModel;
     private Network network;
+    private final ReportedConfigurations reportedConfigurations;
 
     public LogicalNetworkModel(Network network, HostSetupNetworksModel 
setupModel) {
+        this(network, null, setupModel);
+    }
+
+    public LogicalNetworkModel(Network network,
+            ReportedConfigurations reportedConfigurations,
+            HostSetupNetworksModel setupModel) {
         super(setupModel);
         setNetwork(network);
         management = network.getCluster() != null && 
network.getCluster().isManagement();
+        this.reportedConfigurations = reportedConfigurations;
     }
 
     /**
@@ -189,7 +197,8 @@
     }
 
     public boolean isAttached() {
-        return attachedToNic != null;
+        return reportedConfigurations != null;
+        //return attachedToNic != null;
     }
 
     public boolean isAttachedViaLabel() {
@@ -225,22 +234,16 @@
     }
 
     public boolean isInSync() {
-        NetworkImplementationDetails details = 
getNetworkImplementationDetails();
-        return details != null ? details.isInSync() : true;
+        ReportedConfigurations reportedConfigurations = 
getReportedConfigurations();
+        return reportedConfigurations != null && 
reportedConfigurations.isNetworkInSync();
     }
 
     public boolean isManaged() {
-        NetworkImplementationDetails details = 
getNetworkImplementationDetails();
-        return details != null ? details.isManaged() : true;
+        return getReportedConfigurations() != null;
     }
 
-    public NetworkImplementationDetails getNetworkImplementationDetails() {
-        if (!isAttached()) {
-            return null;
-        }
-
-        VdsNetworkInterface nic = hasVlan() ? getVlanNicModel().getIface() : 
getAttachedToNic().getIface();
-        return nic.getNetworkImplementationDetails();
+    public ReportedConfigurations getReportedConfigurations() {
+        return reportedConfigurations;
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/ItemInfoPopup.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/ItemInfoPopup.java
index ef69e54..81fe765 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/ItemInfoPopup.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/ItemInfoPopup.java
@@ -1,11 +1,20 @@
 package org.ovirt.engine.ui.webadmin.section.main.view.popup.host.panels;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ovirt.engine.core.common.businessentities.network.HostNetworkQos;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.NetworkBootProtocol;
+import 
org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations;
+import 
org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations.ReportedConfiguration;
+import 
org.ovirt.engine.core.common.businessentities.network.ReportedConfigurations.Type;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.ui.common.widget.renderer.EnumRenderer;
+import org.ovirt.engine.ui.uicommonweb.Linq;
 import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
+import org.ovirt.engine.ui.uicommonweb.models.hosts.NetworkParameters;
 import 
org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel;
 import 
org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel;
 import 
org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel;
@@ -50,7 +59,8 @@
             
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.networkNotSyncImage()).getHTML());
     SafeHtml alertImage =
             
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.alertImage()).getHTML());
-    private static int defaultMtu = (Integer) 
AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigurationValues.DefaultMTU);
+    private static int defaultMtu = (Integer) 
AsyncDataProvider.getInstance().getConfigValuePreConverted(
+            ConfigurationValues.DefaultMTU);
 
     public ItemInfoPopup() {
         super(true);
@@ -103,7 +113,7 @@
             }
             // Not in sync
             if (!networkModel.isInSync()) {
-                addRow(templates.imageTextSetupNetwork(notInSyncImage, 
constants.networkNotInSync()));
+                addSyncDiff(networkModel);
             }
         }
 
@@ -149,6 +159,109 @@
         }
     }
 
+    /***
+     *
+     * @param networkModel must be managed
+     */
+    private void addSyncDiff(LogicalNetworkModel networkModel) {
+        addRow(templates.imageTextSetupNetwork(notInSyncImage, 
constants.networkNotInSync()));
+        List<ReportedConfiguration> reportedUnSyncConfigurationList = 
filterSyncProperties(networkModel);
+        Network network = networkModel.getNetwork();
+        HostNetworkQos hostNetworkQos = resolveNetworkQos(networkModel);
+        List<NetworkAttachmentDetails> networkAttachmentDetailsList =
+                resolveCorrelatedVdsInterfaceConfigurationValue(network,
+                        reportedUnSyncConfigurationList,
+                        hostNetworkQos);
+        for (NetworkAttachmentDetails networkAttachmentDetails : 
networkAttachmentDetailsList){
+            addRow(networkAttachmentDetails.getType(), 
networkAttachmentDetails.networkValue
+                    + "\\t" + 
networkAttachmentDetails.getIfaceValue());//$NON-NLS-1$
+        }
+    }
+
+    /***
+     * will filter out all sync properties
+     * @param networkModel must be managed
+     */
+    private List<ReportedConfiguration> 
filterSyncProperties(LogicalNetworkModel networkModel){
+        ReportedConfigurations reportedConfigurations = 
networkModel.getReportedConfigurations();
+        List<ReportedConfiguration> reportedConfigurationList = 
reportedConfigurations.getReportedConfigurationList();
+        List<ReportedConfiguration> output = (List) 
Linq.where(reportedConfigurationList,
+                new Linq.IPredicate<ReportedConfiguration>() {
+                    @Override
+                    public boolean match(ReportedConfiguration 
reportedConfiguration) {
+                        return !reportedConfiguration.isInSync();
+                    }
+                });
+        return output;
+    }
+    private final class NetworkAttachmentDetails {
+        public String getType() {
+            return type;
+        }
+
+        public String getIfaceValue() {
+            return ifaceValue;
+        }
+
+        public String getNetworkValue() {
+            return networkValue;
+        }
+
+        private final String type;
+        private final String ifaceValue;
+        private final String networkValue;
+
+        public NetworkAttachmentDetails(String type, String ifaceValue, String 
networkValue) {
+            this.type = type;
+            this.ifaceValue = ifaceValue;
+            this.networkValue = networkValue;
+        }
+    }
+
+    private List<NetworkAttachmentDetails> 
resolveCorrelatedVdsInterfaceConfigurationValue(Network network,
+            List<ReportedConfiguration> reportedConfigurationList,
+            HostNetworkQos networkQos) {
+        List<NetworkAttachmentDetails> output = new ArrayList<>();
+        Type type;
+        String networkValue;
+        NetworkAttachmentDetails networkAttachmentDetails;
+        for (ReportedConfiguration reportedConfiguration : 
reportedConfigurationList) {
+            type = reportedConfiguration.getType();
+            networkValue = resolveNetworkConfigValueByType(type, network, 
networkQos);
+            networkAttachmentDetails =
+                    new NetworkAttachmentDetails(type.getName(), 
reportedConfiguration.getValue(), networkValue);
+            output.add(networkAttachmentDetails);
+        }
+        return output;
+
+    }
+
+    private HostNetworkQos resolveNetworkQos(LogicalNetworkModel networkModel) 
{
+        final String networkName = networkModel.getName();
+        NetworkParameters netParams = 
networkModel.getSetupModel().getNetworkToLastDetachParams().get(networkName);
+        HostNetworkQos hostNetworkQos = netParams.getQos();
+        return hostNetworkQos;
+    }
+
+    private String resolveNetworkConfigValueByType(Type type, Network network, 
HostNetworkQos networkQos) {
+        switch (type) {
+        case MTU:
+            return Integer.toString(network.getMtu());
+        case BRIDGED:
+            return Boolean.toString(network.isVmNetwork());
+        case VLAN:
+            return Integer.toString(network.getVlanId());
+        case OUT_AVERAGE_LINK_SHARE:
+            return Integer.toString(networkQos.getOutAverageLinkshare());
+        case OUT_AVERAGE_UPPER_LIMIT:
+            return Integer.toString(networkQos.getOutAverageUpperlimit());
+        case OUT_AVERAGE_REAL_TIME:
+            return Integer.toString(networkQos.getOutAverageRealtime());
+        default:
+            return "";
+        }
+    }
+
     private void showNic(NetworkInterfaceModel nic) {
         contents.removeAllRows();
         VdsNetworkInterface entity = nic.getIface();


-- 
To view, visit https://gerrit.ovirt.org/42396
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I202527cce11cee02756c63ea338bbd888402381f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eliraz Levi <el...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to