Douglas Schilling Landgraf has uploaded a new change for review. Change subject: HostGeneralModel: improve "node has upgrade" logic ......................................................................
HostGeneralModel: improve "node has upgrade" logic This patch will add a validation to compare Node iso version against ISOs available in oVirt Engine. If ISOs on Engine are higher, then show to users that we have new upgrade available. Change-Id: I49c74d3d0d92c74848e0c175095610b6e6b5a88e Signed-off-by: Douglas Schilling Landgraf <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java 1 file changed, 27 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/89/16089/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java index 33d1551..7f2b472 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java @@ -2,6 +2,9 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; +import java.util.logging.Logger; + import org.ovirt.engine.core.common.VdcActionUtils; import org.ovirt.engine.core.common.action.UpdateVdsActionParameters; @@ -37,11 +40,14 @@ import org.ovirt.engine.ui.uicompat.UIMessages; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; +import com.google.gwt.i18n.client.DateTimeFormat; + @SuppressWarnings("unused") public class HostGeneralModel extends EntityModel { private static final UIConstants constants = ConstantsManager.getInstance().getConstants(); private static final UIMessages messages = ConstantsManager.getInstance().getMessages(); + private static final Logger logger = Logger.getLogger(HostGeneralModel.class.getName()); public static EventDefinition RequestEditEventDefinition; private Event privateRequestEditEvent; @@ -1025,11 +1031,7 @@ private void updateAlerts() { setHasAnyAlert(false); - - if (updateUpgradeAlert) { - setHasUpgradeAlert(false); - } - + setHasUpgradeAlert(false); setHasManualFenceAlert(false); setHasNoPowerManagementAlert(false); setHasReinstallAlertNonResponsive(false); @@ -1069,10 +1071,7 @@ setHasReinstallAlertMaintenance(true); } - // TODO: Need to come up with a logic to show the Upgrade action-item. - // Currently, this action-item will be shown for all oVirts assuming there are - // available oVirt ISOs that are returned by the backend's GetoVirtISOs query. - else if (getEntity().getVdsType() == VDSType.oVirtNode && updateUpgradeAlert) + else if (getEntity().getVdsType() == VDSType.oVirtNode) { AsyncDataProvider.getoVirtISOsList(new AsyncQuery(this, new INewAsyncCallback() { @@ -1084,7 +1083,25 @@ if (isos.size() > 0) { VDS vds = hostGeneralModel.getEntity(); - hostGeneralModel.setHasUpgradeAlert(true); + DateTimeFormat format = DateTimeFormat.getFormat("yyyyMMdd"); //$NON-NLS-1$ + String nodeInfo[] = vds.getHostOs().split("-"); //$NON-NLS-1$ + String formattedISOVersion; + for (RpmVersion iso: isos) { + try { + formattedISOVersion = String.valueOf(iso); + // Get last 8 chars which is the date. Example: 2.6.0.20130212 + formattedISOVersion = formattedISOVersion.substring(formattedISOVersion.length() - 8); + Date dateISO = format.parse(formattedISOVersion); + // Split by . nodeInfo[2] and get the first element. Example: 20120228.fc18 + Date dateNodeISO = format.parse(nodeInfo[2].split("\\.")[0].trim()); //$NON-NLS-1$ + if (dateISO.compareTo(dateNodeISO)>0) { + hostGeneralModel.setHasUpgradeAlert(true); + break; + } + } catch (IllegalArgumentException er) { + logger.info("IllegalArgumentException error: " + er); //$NON-NLS-1$ + } + } boolean executionAllowed = vds.getStatus() != VDSStatus.Up && vds.getStatus() != VDSStatus.Installing -- To view, visit http://gerrit.ovirt.org/16089 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I49c74d3d0d92c74848e0c175095610b6e6b5a88e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Douglas Schilling Landgraf <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
