Tomas Jelinek has uploaded a new change for review.

Change subject: userportal: disable host pinning in user portal (#849042)
......................................................................

userportal: disable host pinning in user portal (#849042)

https://bugzilla.redhat.com/849042

The behavior:
- new/edit VM and edit Template does not have the
  "Host" side tab visible
- when the host pinning is set in web admin and the
  VM or Template is edited in user portal, this values
  will be send as-is to the server
- if the host pinning will be set in the template,
  the new/edit VM dialog will ignore this settings

This patch also contains the following fixes:
1: changes the calling of admin query
   AsyncDataProvider.GetHostListByCluster by user
   query GetHostsByClusterId for edit template.
2: CPU pinning field was ignored in the edit VM dialog
   in userportal. It can not be edited directly by the
   user but it can not be ignored to be possible to
   send the same value to the server as it was set in
   web admin

Change-Id: Ie0737807a46845e8ad8ee27c91c6a782df7b3fd3
Signed-off-by: Tomas Jelinek <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalTemplateListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java
A 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/popup/template/TemplateNewPopupView.java
7 files changed, 102 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/7292/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
index 9810ceb..afb2a94 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
@@ -359,7 +359,7 @@
             return;
         }
 
-        UnitVmModel model = new UnitVmModel(new 
TemplateVmModelBehavior(template));
+        UnitVmModel model = new UnitVmModel(createBehavior(template));
         setWindow(model);
         
model.setTitle(ConstantsManager.getInstance().getConstants().editTemplateTitle());
         model.setHashName("edit_template"); //$NON-NLS-1$
@@ -380,6 +380,10 @@
         model.getCommands().add(command);
     }
 
+    protected TemplateVmModelBehavior createBehavior(VmTemplate template) {
+        return new TemplateVmModelBehavior(template);
+    }
+
     private void remove()
     {
         if (getWindow() != null)
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java
index 96d7ca0..31da67d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java
@@ -1313,6 +1313,9 @@
             gettempVm().setQuotaId(((Quota) 
model.getQuota().getSelectedItem()).getId());
         }
 
+        gettempVm().setCpuPinning((String) model.getCpuPinning()
+                .getEntity());
+
         VDS defaultHost = (VDS) model.getDefaultHost().getSelectedItem();
         if ((Boolean) model.getIsAutoAssign().getEntity())
         {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalTemplateListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalTemplateListModel.java
index 4116bcc..aa3479d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalTemplateListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalTemplateListModel.java
@@ -15,6 +15,8 @@
 import org.ovirt.engine.ui.uicommonweb.models.templates.TemplateListModel;
 import 
org.ovirt.engine.ui.uicommonweb.models.templates.UserPortalTemplateDiskListModel;
 import 
org.ovirt.engine.ui.uicommonweb.models.templates.UserPortalTemplateEventListModel;
+import org.ovirt.engine.ui.uicommonweb.models.vms.TemplateVmModelBehavior;
+import 
org.ovirt.engine.ui.uicommonweb.models.vms.UserPortalTemplateVmModelBehavior;
 
 public class UserPortalTemplateListModel extends TemplateListModel
 {
@@ -59,4 +61,9 @@
         list.add(new UserPortalTemplateEventListModel());
         list.add(new UserPortalPermissionListModel());
     }
+
+    @Override
+    protected TemplateVmModelBehavior createBehavior(VmTemplate template) {
+        return new UserPortalTemplateVmModelBehavior(template);
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java
index 452d12b..cc26fef 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalExistingVmModelBehavior.java
@@ -1,17 +1,20 @@
 package org.ovirt.engine.ui.uicommonweb.models.vms;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum;
 import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.storage_pool;
 import org.ovirt.engine.core.common.queries.GetHostsByClusterIdParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.NGuid;
 import org.ovirt.engine.ui.frontend.AsyncQuery;
 import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.INewAsyncCallback;
@@ -116,6 +119,23 @@
                 }, getModel().getHash()), vm.getvds_group_id());
     }
 
+    /**
+     * Fills the default host according to the selected host set in webadmin. 
Since this value can be set only in
+     * webadmin and can be set also to host, which is not visible to the user 
in userportal, this fakes the VDS value in
+     * a way, that the rest of the code can use it normally and send it back 
to the server as-is (like Null Object
+     * Pattern).
+     */
+    @Override
+    protected void doChangeDefautlHost(NGuid hostGuid) {
+        if (hostGuid != null) {
+            VDS vds = new VDS();
+            vds.setId(hostGuid.getValue());
+            getModel().getDefaultHost().setItems(Arrays.asList(vds));
+        }
+
+        super.doChangeDefautlHost(hostGuid);
+    }
+
     @Override
     protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) {
         Frontend.RunQuery(
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java
index 1f3a6e9..965284c 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalNewVmModelBehavior.java
@@ -6,6 +6,7 @@
 import java.util.List;
 
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
+import org.ovirt.engine.core.common.businessentities.MigrationSupport;
 import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum;
 import org.ovirt.engine.core.common.businessentities.StoragePoolStatus;
 import org.ovirt.engine.core.common.businessentities.StorageType;
@@ -164,6 +165,20 @@
         UpdateIsDisksAvailable();
     }
 
+    /**
+     * Disabled to change this in userportal
+     */
+    @Override
+    protected void updateHostPinning(MigrationSupport migrationSupport) {
+    }
+
+    /**
+     * Disabled to change this in userportal
+     */
+    @Override
+    protected void doChangeDefautlHost(NGuid hostGuid) {
+    }
+
     @Override
     protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) {
         Frontend.RunQuery(
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java
new file mode 100644
index 0000000..3f37d0a
--- /dev/null
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalTemplateVmModelBehavior.java
@@ -0,0 +1,45 @@
+package org.ovirt.engine.ui.uicommonweb.models.vms;
+
+import java.util.Arrays;
+
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSGroup;
+import org.ovirt.engine.core.common.businessentities.VmTemplate;
+import org.ovirt.engine.core.common.queries.GetHostsByClusterIdParameters;
+import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.compat.NGuid;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.Frontend;
+
+public class UserPortalTemplateVmModelBehavior extends TemplateVmModelBehavior 
{
+
+    public UserPortalTemplateVmModelBehavior(VmTemplate template) {
+        super(template);
+    }
+
+    /**
+     * Fills the default host according to the selected host set in webadmin. 
Since this value can be set only in
+     * webadmin and can be set also to host, which is not visible to the user 
in userportal, this fakes the VDS value in
+     * a way, that the rest of the code can use it normally and send it back 
to the server as-is (like Null Object
+     * Pattern).
+     */
+    @Override
+    protected void doChangeDefautlHost(NGuid hostGuid) {
+        if (hostGuid != null) {
+            VDS vds = new VDS();
+            vds.setId(hostGuid.getValue());
+            getModel().getDefaultHost().setItems(Arrays.asList(vds));
+        }
+
+        super.doChangeDefautlHost(hostGuid);
+    }
+
+    @Override
+    protected void getHostListByCluster(VDSGroup cluster, AsyncQuery query) {
+        Frontend.RunQuery(
+                VdcQueryType.GetHostsByClusterId,
+                new GetHostsByClusterIdParameters(cluster.getId()),
+                query
+                );
+    }
+}
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/popup/template/TemplateNewPopupView.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/popup/template/TemplateNewPopupView.java
index ea94975..57282c3 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/popup/template/TemplateNewPopupView.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/section/main/view/popup/template/TemplateNewPopupView.java
@@ -3,6 +3,7 @@
 import org.ovirt.engine.ui.common.idhandler.ElementIdHandler;
 import org.ovirt.engine.ui.common.view.popup.AbstractVmPopupView;
 import 
org.ovirt.engine.ui.common.widget.uicommon.popup.template.TemplateNewPopupWidget;
+import org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel;
 import org.ovirt.engine.ui.userportal.ApplicationConstants;
 import org.ovirt.engine.ui.userportal.ApplicationResources;
 import 
org.ovirt.engine.ui.userportal.section.main.presenter.popup.template.TemplateNewPopupPresenterWidget;
@@ -19,7 +20,12 @@
 
     @Inject
     public TemplateNewPopupView(EventBus eventBus, ApplicationResources 
resources, ApplicationConstants constants) {
-        super(eventBus, resources, new TemplateNewPopupWidget(constants));
+        super(eventBus, resources, new TemplateNewPopupWidget(constants) {
+            @Override
+            protected void setupHostTabAvailability(UnitVmModel model) {
+                hostTab.setVisible(false);
+            }
+        });
         ViewIdHandler.idHandler.generateAndSetIds(this);
     }
 


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

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

Reply via email to