Libor Spevak has uploaded a new change for review.

Change subject: webadmin: Show clusters with Virt service enabled only for VM
......................................................................

webadmin: Show clusters with Virt service enabled only for VM

The New VM/Edit VM dialogs should provide:
- just DC with at least one cluster with enabled Virt Service option
- and only clusters with enabled Virt Service option

Change-Id: Ifb63c7e2addf525bb527d94694a8dfc752d69154
Bug-Url: https://bugzilla.redhat.com/882928
Signed-off-by: Libor Spevak <lspe...@redhat.com>
---
M backend/manager/dbscripts/storages_sp.sql
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAOHibernateImpl.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
8 files changed, 68 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/11395/1

diff --git a/backend/manager/dbscripts/storages_sp.sql 
b/backend/manager/dbscripts/storages_sp.sql
index 1fe56ee..f7739f3 100644
--- a/backend/manager/dbscripts/storages_sp.sql
+++ b/backend/manager/dbscripts/storages_sp.sql
@@ -650,3 +650,10 @@
 END; $procedure$
 LANGUAGE plpgsql;
 
+CREATE OR REPLACE FUNCTION getstorage_pool_by_virt_service_cluster() RETURNS 
SETOF storage_pool
+   AS $procedure$
+BEGIN
+   RETURN QUERY SELECT SP.* FROM STORAGE_POOL SP
+   WHERE EXISTS (SELECT 1 FROM VDS_GROUPS VG WHERE VG.VIRT_SERVICE = TRUE AND 
VG.STORAGE_POOL_ID = SP.ID);
+END; $procedure$
+LANGUAGE plpgsql;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
index 231a2fe..884e74b 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
@@ -238,6 +238,7 @@
     GetExistingStorageDomainList,
     GetStorageDomainByIdAndStoragePoolId,
     GetStoragePoolsByStorageDomainId,
+    GetStoragePoolsByVirtService,
     GetStorageDomainListById,
     GetLunsByVgId,
     GetPermittedStorageDomainsByStoragePoolId(VdcQueryAuthType.User),
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAO.java
index c04d0ef..b9adecf 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAO.java
@@ -105,4 +105,11 @@
      */
     List<storage_pool> getDataCentersWithPermittedActionOnClusters(Guid 
userId, ActionGroup actionGroup);
 
+    /**
+     * Retrieves data centers with at least one cluster with virt service 
specified
+     *
+     * @return list of data centers
+     */
+    List<storage_pool> getDataCentersWithVirtServiceCluster();
+
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
index cd5ee77..1a1e9d1 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
@@ -381,4 +381,12 @@
                 mapper, parameterSource);
     }
 
+    @Override
+    public List<storage_pool> getDataCentersWithVirtServiceCluster() {
+        MapSqlParameterSource parameterSource = 
getCustomMapSqlParameterSource();
+        StoragePoolRawMapper mapper = new StoragePoolRawMapper();
+
+        return 
getCallsHandler().executeReadList("getstorage_pool_by_virt_service_cluster", 
mapper, parameterSource);
+    }
+
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAOHibernateImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAOHibernateImpl.java
index 5a5cb11..c95f136 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAOHibernateImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAOHibernateImpl.java
@@ -97,4 +97,11 @@
         // TODO Auto-generated method stub
         return null;
     }
+
+    @Override
+    public List<storage_pool> getDataCentersWithVirtServiceCluster() {
+        throw new NotImplementedException();
+    }
+
+
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 1b0e739..c58f00c 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -387,6 +387,25 @@
                 aQuery);
     }
 
+    public static void GetDataCenterListByVirtService(AsyncQuery aQuery) {
+        aQuery.converterCallback = new IAsyncConverter() {
+            @Override
+            public Object Convert(Object source, AsyncQuery _asyncQuery)
+            {
+                if (source == null)
+                {
+                    return new ArrayList<storage_pool>();
+                }
+                return source;
+            }
+        };
+        Frontend.RunQuery(VdcQueryType.GetStoragePoolsByVirtService,
+                new SearchParameters("DataCenter: sortby name", 
SearchType.StoragePool), //$NON-NLS-1$
+                aQuery);
+    }
+
+
+
     public static void GetMinimalVmMemSize(AsyncQuery aQuery) {
         aQuery.converterCallback = new IAsyncConverter() {
             @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
index bda6d5f..47c4841 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
@@ -93,7 +93,15 @@
                         UnitVmModel model = (UnitVmModel) array[1];
                         VM vm = ((ExistingVmModelBehavior) array[0]).vm;
                         ArrayList<VDSGroup> clusters = (ArrayList<VDSGroup>) 
returnValue;
-                        model.SetClusters(model, clusters, 
vm.getVdsGroupId().getValue());
+                        // show just clusters with virt service enabled
+                        ArrayList<VDSGroup> virtServiceClusters = new 
ArrayList<VDSGroup>();
+                        for(VDSGroup cluster : clusters) {
+                            if(cluster.supportsVirtService()) {
+                                virtServiceClusters.add(cluster);
+                            }
+                        }
+
+                        model.SetClusters(model, virtServiceClusters, 
vm.getVdsGroupId().getValue());
                         behavior.InitTemplate();
                         behavior.InitCdImage();
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
index 503ecca..22dc0b0 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java
@@ -27,7 +27,7 @@
     public void Initialize(SystemTreeItemModel systemTreeSelectedItem)
     {
         super.Initialize(systemTreeSelectedItem);
-        AsyncDataProvider.GetDataCenterList(new AsyncQuery(getModel(),
+        AsyncDataProvider.GetDataCenterListByVirtService(new 
AsyncQuery(getModel(),
                 new INewAsyncCallback() {
                     @Override
                     public void OnSuccess(Object target, Object returnValue) {
@@ -63,7 +63,15 @@
                         NewVmModelBehavior behavior = (NewVmModelBehavior) 
array[0];
                         UnitVmModel model = (UnitVmModel) array[1];
                         ArrayList<VDSGroup> clusters = (ArrayList<VDSGroup>) 
returnValue;
-                        model.SetClusters(model, clusters, null);
+                        // show just clusters with virt service enabled
+                        ArrayList<VDSGroup> virtServiceClusters = new 
ArrayList<VDSGroup>();
+                        for(VDSGroup cluster : clusters) {
+                            if(cluster.supportsVirtService()) {
+                                virtServiceClusters.add(cluster);
+                            }
+                        }
+
+                        model.SetClusters(model, virtServiceClusters, null);
                         behavior.InitTemplate();
                         behavior.InitCdImage();
 


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

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

Reply via email to