Yaniv Bronhaim has uploaded a new change for review.

Change subject: webadmin: host-deploy: Modifying Reinstall Host popup view
......................................................................

webadmin: host-deploy: Modifying Reinstall Host popup view

1. Adding password or publicKey fields for authentication.
2. Adding ssh fingerprint field.

Change-Id: Ic33775720914908399492038f8ebf0d2a9b4524c
Signed-off-by: Yaniv Bronhaim <ybron...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/InstallModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.ui.xml
5 files changed, 216 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/90/16690/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 cbbad65..f96d1b8 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
@@ -820,7 +820,7 @@
         model.setTitle(constants.installHostTitle());
         model.setHashName("install_host"); //$NON-NLS-1$
         model.getOVirtISO().setIsAvailable(false);
-        model.getRootPassword().setIsAvailable(false);
+
         model.getOverrideIpTables().setIsAvailable(false);
 
         model.getHostVersion().setEntity(getEntity().getHostOs());
@@ -854,8 +854,8 @@
                     }),
                     getEntity().getId());
         } else {
-            model.getRootPassword().setIsAvailable(true);
-            model.getRootPassword().setIsChangable(true);
+            model.getUserPassword().setIsAvailable(true);
+            model.getUserPassword().setIsChangable(true);
 
             Version v3 = new Version(3, 0);
             boolean isLessThan3 = 
getEntity().getVdsGroupCompatibilityVersion().compareTo(v3) < 0;
@@ -906,11 +906,12 @@
         UpdateVdsActionParameters param = new UpdateVdsActionParameters();
         param.setvds(getEntity());
         param.setVdsId(getEntity().getId());
-        param.setPassword((String) model.getRootPassword().getEntity());
+        param.setPassword((String) model.getUserPassword().getEntity());
         param.setIsReinstallOrUpgrade(true);
         param.setInstallVds(true);
         param.setoVirtIsoFile(isOVirt ? ((RpmVersion) 
model.getOVirtISO().getSelectedItem()).getRpmName() : null);
         param.setOverrideFirewall((Boolean) 
model.getOverrideIpTables().getEntity());
+        param.setAuthMethod(model.getAuthenticationMethod());
 
         AsyncDataProvider.getClusterById(new AsyncQuery(param, new 
INewAsyncCallback() {
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
index dad03ae..fd057c4 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java
@@ -888,6 +888,7 @@
             parameters.setPassword(""); //$NON-NLS-1$
             parameters.setInstallVds(false);
             parameters.setRebootAfterInstallation(isVirt) ;
+            parameters.setAuthMethod(model.getAuthenticationMethod());
 
             if (!oldClusterId.equals(newClusterId))
             {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/InstallModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/InstallModel.java
index a3508f5..e4fa111 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/InstallModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/InstallModel.java
@@ -1,22 +1,30 @@
 package org.ovirt.engine.ui.uicommonweb.models.hosts;
 
+import 
org.ovirt.engine.core.common.action.VdsOperationActionParameters.AuthenticationMethod;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.INewAsyncCallback;
+import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
 import org.ovirt.engine.ui.uicommonweb.models.ListModel;
 import org.ovirt.engine.ui.uicommonweb.models.Model;
 import org.ovirt.engine.ui.uicommonweb.validation.IValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation;
+import org.ovirt.engine.ui.uicompat.ConstantsManager;
+import org.ovirt.engine.ui.uicompat.UIConstants;
 
 @SuppressWarnings("unused")
 public class InstallModel extends Model {
 
-    private EntityModel privateRootPassword;
+    private static final UIConstants constants = 
ConstantsManager.getInstance().getConstants();
 
-    public EntityModel getRootPassword() {
-        return privateRootPassword;
+    private EntityModel privateUserPassword;
+
+    public EntityModel getUserPassword() {
+        return privateUserPassword;
     }
 
-    private void setRootPassword(EntityModel value) {
-        privateRootPassword = value;
+    private void setUserPassword(EntityModel value) {
+        privateUserPassword = value;
     }
 
     private ListModel privateOVirtISO;
@@ -49,25 +57,84 @@
         hostVersion = value;
     }
 
+    private EntityModel privateUserName;
+
+    public EntityModel getUserName()
+    {
+        return privateUserName;
+    }
+
+    private void setUserName(EntityModel value)
+    {
+        privateUserName = value;
+    }
+
+    private EntityModel privatePublicKey;
+
+    public EntityModel getPublicKey()
+    {
+        return privatePublicKey;
+    }
+
+    private void setPublicKey(EntityModel value)
+    {
+        privatePublicKey = value;
+    }
+
+    private AuthenticationMethod hostAuthenticationMethod;
+
+    public void setAuthenticationMethod(AuthenticationMethod value) {
+        hostAuthenticationMethod = value;
+    }
+
+    public AuthenticationMethod getAuthenticationMethod() {
+        return hostAuthenticationMethod;
+    }
+
     public InstallModel() {
-        setRootPassword(new EntityModel());
+        setUserPassword(new EntityModel());
         setOVirtISO(new ListModel());
         setHostVersion(new EntityModel());
 
         setOverrideIpTables(new EntityModel());
         getOverrideIpTables().setEntity(false);
+        setUserName(new EntityModel());
+        getUserName().setEntity(constants.defaultUserName());
+        getUserName().setIsChangable(false);
+        setPublicKey(new EntityModel());
+        getPublicKey().setEntity(constants.empty());
+        fetchPublicKey();
     }
 
     public boolean validate(boolean isOVirt) {
         getOVirtISO().setIsValid(true);
-        getRootPassword().setIsValid(true);
+        getUserPassword().setIsValid(true);
 
         if (isOVirt) {
             getOVirtISO().validateSelectedItem(new IValidation[] { new 
NotEmptyValidation() });
         } else {
-            getRootPassword().validateEntity(new IValidation[] { new 
NotEmptyValidation() });
+            if (getAuthenticationMethod() == AuthenticationMethod.Password) {
+                getUserPassword().validateEntity(new IValidation[] { new 
NotEmptyValidation() });
+            }
         }
 
-        return getRootPassword().getIsValid() && getOVirtISO().getIsValid();
+        return getUserPassword().getIsValid() && getOVirtISO().getIsValid();
+    }
+
+    public void fetchPublicKey() {
+        AsyncQuery aQuery = new AsyncQuery();
+        aQuery.setModel(this);
+        aQuery.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object result)
+            {
+                String pk = (String) result;
+                if (pk != null && pk.length() > 0)
+                {
+                    getPublicKey().setEntity(result);
+                }
+            }
+        };
+        AsyncDataProvider.getHostPublicKey(aQuery);
     }
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.java
index 7475695..87c61bc 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.java
@@ -1,24 +1,35 @@
 package org.ovirt.engine.ui.webadmin.section.main.view.popup.host;
 
+import 
org.ovirt.engine.core.common.action.VdsOperationActionParameters.AuthenticationMethod;
 import org.ovirt.engine.core.compat.RpmVersion;
+import org.ovirt.engine.ui.common.idhandler.WithElementId;
 import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView;
 import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel;
 import org.ovirt.engine.ui.common.widget.editor.EntityModelCheckBoxEditor;
 import org.ovirt.engine.ui.common.widget.editor.EntityModelLabelEditor;
 import org.ovirt.engine.ui.common.widget.editor.EntityModelPasswordBoxEditor;
+import org.ovirt.engine.ui.common.widget.editor.EntityModelTextAreaLabelEditor;
+import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxEditor;
 import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor;
 import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer;
 import org.ovirt.engine.ui.uicommonweb.models.hosts.InstallModel;
 import org.ovirt.engine.ui.webadmin.ApplicationConstants;
 import org.ovirt.engine.ui.webadmin.ApplicationResources;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.HostInstallPopupPresenterWidget;
+import 
org.ovirt.engine.ui.webadmin.section.main.view.popup.host.HostPopupView.Style;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Style.Visibility;
 import com.google.gwt.editor.client.SimpleBeanEditorDriver;
+import com.google.gwt.editor.client.Editor.Path;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
 import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.resources.client.CssResource;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.RadioButton;
 import com.google.inject.Inject;
 
 /**
@@ -38,7 +49,10 @@
     }
 
     @UiField
-    @Path(value = "rootPassword.entity")
+    Style style;
+
+    @UiField
+    @Path(value = "userPassword.entity")
     EntityModelPasswordBoxEditor passwordEditor;
 
     @UiField
@@ -51,10 +65,35 @@
 
     @UiField
     @Path(value = "OverrideIpTables.entity")
+    @WithElementId("overrideIpTables")
     EntityModelCheckBoxEditor overrideIpTablesEditor;
 
     @UiField
     Label message;
+
+    @UiField
+    @Ignore
+    Label authLabel;
+
+    @UiField(provided = true)
+    @Ignore
+    @WithElementId("rbPublicKey")
+    public RadioButton rbPublicKey;
+
+    @UiField(provided = true)
+    @Ignore
+    @WithElementId("rbPassword")
+    public RadioButton rbPassword;
+
+    @UiField
+    @Path(value = "userName.entity")
+    @WithElementId("userName")
+    EntityModelTextBoxEditor userNameEditor;
+
+    @UiField(provided = true)
+    @Path(value = "publicKey.entity")
+    @WithElementId("publicKey")
+    EntityModelTextAreaLabelEditor publicKeyEditor;
 
     private final Driver driver = GWT.create(Driver.class);
 
@@ -64,6 +103,7 @@
         initListBoxEditors();
         initWidget(ViewUiBinder.uiBinder.createAndBindUi(this));
         localize(constants);
+        addStyles();
         driver.initialize(this);
     }
 
@@ -78,20 +118,55 @@
                 return version.getRpmName();
             }
         });
+        rbPassword = new RadioButton("1"); //$NON-NLS-1$
+        rbPublicKey = new RadioButton("1"); //$NON-NLS-1$
+        publicKeyEditor = new EntityModelTextAreaLabelEditor(true, true);
     }
 
     void localize(ApplicationConstants constants) {
-        passwordEditor.setLabel(constants.hostInstallPasswordLabel());
         hostVersionEditor.setLabel(constants.hostInstallHostVersionLabel());
         isoEditor.setLabel(constants.hostInstallIsoLabel());
         
overrideIpTablesEditor.setLabel(constants.hostInstallOverrideIpTablesLabel());
+        authLabel.setText(constants.hostPopupAuthLabel());
+        userNameEditor.setLabel(constants.hostPopupUsernameLabel());
     }
 
     @Override
     public void edit(final InstallModel model) {
         driver.edit(model);
+
+        rbPassword.setValue(true);
+        displayPassPkWindow(true);
+        model.setAuthenticationMethod(AuthenticationMethod.Password);
+
+        rbPassword.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
+            @Override
+            public void onValueChange(ValueChangeEvent<Boolean> event) {
+                model.setAuthenticationMethod(AuthenticationMethod.Password);
+                displayPassPkWindow(true);
+            }
+        });
+
+        rbPublicKey.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
+            @Override
+            public void onValueChange(ValueChangeEvent<Boolean> event) {
+                model.setAuthenticationMethod(AuthenticationMethod.PublicKey);
+                displayPassPkWindow(false);
+            }
+        });
+        // TODO: until we allow using different username
+        userNameEditor.setEnabled(false);
     }
 
+    private void displayPassPkWindow(boolean isPasswordVisible) {
+        if (isPasswordVisible) {
+            
passwordEditor.getElement().getStyle().setVisibility(Visibility.VISIBLE);
+            
publicKeyEditor.getElement().getStyle().setVisibility(Visibility.HIDDEN);
+        } else {
+            
passwordEditor.getElement().getStyle().setVisibility(Visibility.HIDDEN);
+            
publicKeyEditor.getElement().getStyle().setVisibility(Visibility.VISIBLE);
+        }
+    }
     @Override
     public InstallModel flush() {
         return driver.flush();
@@ -109,4 +184,11 @@
         }
     }
 
+    interface Style extends CssResource {
+        String overrideIpStyle();
+    }
+
+    private void addStyles() {
+        
overrideIpTablesEditor.addContentWidgetStyleName(style.overrideIpStyle());
+    }
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.ui.xml
index dd7dc56..1bed52d 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostInstallPopupView.ui.xml
@@ -8,25 +8,68 @@
         xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog"
         xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor">
 
-    <ui:style>
-
+    <ui:with field='constants' 
type='org.ovirt.engine.ui.common.CommonApplicationConstants'/>
+    <ui:style 
type="org.ovirt.engine.ui.webadmin.section.main.view.popup.host.HostInstallPopupView.Style">
         .errorMessageLabel {
             color: #CD2127;
             margin-top: 10px;
             margin-left: 5px;
         }
 
+        .headerAuthLabel {
+            font-weight: bold;
+            margin-top: 10px;
+        }
+
+        .headerFp {
+            margin: 5px;
+            margin-bottom: 5px;
+        }
+
+        .pkStyle {
+            resize: none;
+        }
+
+        .radioButton {
+            margin-right: 2px;
+        }
+
+        .fetchLink {
+            margin: 3px;
+            font-size: 15pt;
+            width: 450px;
+        }
+
+        .content {
+            width: 100%;
+        }
+
+        .overrideIpStyle {
+            width: 200px;
+        }
+
     </ui:style>
 
-    <d:SimpleDialogPanel width="500px" height="180px">
+    <d:SimpleDialogPanel width="500px" height="260px">
         <d:content>
-            <g:FlowPanel>
-                <e:EntityModelPasswordBoxEditor ui:field="passwordEditor"/>
+            <g:VerticalPanel width="100%" addStyleNames="{style.content}">
+                <g:Label ui:field="authLabel" 
addStyleNames="{style.headerAuthLabel}"/>
+                <e:EntityModelTextBoxEditor ui:field="userNameEditor"/>
+                <g:HorizontalPanel width="100%" verticalAlignment="middle">
+                    <g:RadioButton ui:field="rbPassword" />
+                    <g:Label text="{constants.hostPasswordLabel}" />
+                    <e:EntityModelPasswordBoxEditor ui:field="passwordEditor" 
/>
+                </g:HorizontalPanel>
+                <g:HorizontalPanel width="100%" verticalAlignment="middle">
+                    <g:RadioButton ui:field="rbPublicKey" 
addStyleNames="{style.radioButton}" />
+                    <g:Label text="{constants.hostPublicKeyLable}" />
+                    <e:EntityModelTextAreaLabelEditor 
ui:field="publicKeyEditor" addStyleNames="{style.pkStyle}" />
+                </g:HorizontalPanel>
+                <e:EntityModelCheckBoxEditor 
ui:field="overrideIpTablesEditor"/>
                 <e:EntityModelLabelEditor ui:field="hostVersionEditor"/>
                 <e:ListModelListBoxEditor ui:field="isoEditor"/>
-                <e:EntityModelCheckBoxEditor 
ui:field="overrideIpTablesEditor"/>
                 <g:Label ui:field="message" 
addStyleNames="{style.errorMessageLabel}"/>
-            </g:FlowPanel>
+            </g:VerticalPanel>
         </d:content>
     </d:SimpleDialogPanel>
 


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

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

Reply via email to