Sergey Gotliv has uploaded a new change for review.

Change subject: engine: Introduce getConnectableStorageConnectionsByStorageType 
API
......................................................................

engine: Introduce getConnectableStorageConnectionsByStorageType API

This API allows to retrieve all connectable storage connections by
storage type. If storage type is not specified then this API returns
the same result as getAllConnectableStorageSeverConnection -  all
connectable storage connections.

Change-Id: I9cea901ff2707bb4caa52e8f8eff06d533d5ddb6
Signed-off-by: Sergey Gotliv <[email protected]>
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
M packaging/dbscripts/storages_san_sp.sql
4 files changed, 64 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/24681/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAO.java
index c122f0d..4f56acf 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAO.java
@@ -3,6 +3,7 @@
 import java.util.List;
 
 import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
+import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.compat.Guid;
 
 /**
@@ -56,6 +57,20 @@
     List<StorageServerConnections> 
getAllConnectableStorageSeverConnection(Guid pool);
 
     /**
+     * Retrieves all connections of Active/Unknown/InActive domains of the 
specified storage type
+     * in the specified storage pool. If storage type is not specified then 
all connections of the same
+     * domains are returned.
+     *
+     * @param pool
+     *            the storage pool
+     * @param storageType
+     *            the storage type
+     *
+     * @return the list of connections
+     */
+    List<StorageServerConnections> 
getConnectableStorageConnectionsByStorageType(Guid pool, StorageType 
storageType);
+
+    /**
      * Retrieves all connections for the specified volume group.
      *
      * @param group
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAODbFacadeImpl.java
index 392ae10..0c9f074 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageServerConnectionDAODbFacadeImpl.java
@@ -48,10 +48,17 @@
 
     @Override
     public List<StorageServerConnections> 
getAllConnectableStorageSeverConnection(Guid pool) {
-        return 
getCallsHandler().executeReadList("GetAllConnectableStorageSeverConnection",
+        return getConnectableStorageConnectionsByStorageType(pool, null);
+    }
+
+    @Override
+    public List<StorageServerConnections> 
getConnectableStorageConnectionsByStorageType(Guid pool,
+                                                                               
         StorageType storageType) {
+        return 
getCallsHandler().executeReadList("GetConnectableStorageConnectionsByStorageType",
                 mapper,
                 getCustomMapSqlParameterSource()
-                        .addValue("storage_pool_id", pool));
+                        .addValue("storage_pool_id", pool)
+                        .addValue("storage_type", (storageType != null) ? 
storageType.getValue() : null));
     }
 
     @Override
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
index 65a0ce7..0b4f671 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
@@ -91,13 +91,48 @@
      * Ensures that a set of records are returned.
      */
     @Test
-    public void testgetAllConnectableStorageSeverConnectionl() {
+    public void testGetAllConnectableStorageSeverConnections() {
         List<StorageServerConnections> result = 
dao.getAllConnectableStorageSeverConnection(EXISTING_STORAGE_POOL_ID);
 
         assertNotNull(result);
         assertFalse(result.isEmpty());
     }
 
+    @Test
+    public void testGetConnectableBlockStorageConnections() {
+        List<StorageServerConnections> conns =
+                
dao.getConnectableStorageConnectionsByStorageType(FixturesTool.STORAGE_POOL_RHEL6_ISCSI_OTHER,
 StorageType.ISCSI);
+
+        assertNotNull(conns);
+        assertEquals(2, conns.size());
+
+        for (StorageServerConnections conn : conns) {
+            assertEquals(StorageType.ISCSI, conn.getstorage_type());
+        }
+    }
+
+    @Test
+    public void testGetConnectableFileStorageConnectionsByStorageType() {
+        List<StorageServerConnections> conns =
+                
dao.getConnectableStorageConnectionsByStorageType(FixturesTool.STORAGE_POOL_NFS_2,
 StorageType.NFS);
+
+        assertNotNull(conns);
+        assertEquals(1, conns.size());
+
+        for (StorageServerConnections conn : conns) {
+            assertEquals(StorageType.NFS, conn.getstorage_type());
+        }
+    }
+
+    @Test
+    public void testGetConnectableStorageConnectionsByStorageType() {
+        List<StorageServerConnections> result =
+                
dao.getConnectableStorageConnectionsByStorageType(EXISTING_STORAGE_POOL_ID, 
null);
+
+        assertNotNull(result);
+        assertFalse(result.isEmpty());
+    }
+
     /**
      * Retrieves all connections for the given volume group.
      *
diff --git a/packaging/dbscripts/storages_san_sp.sql 
b/packaging/dbscripts/storages_san_sp.sql
index 3a6c7f3..2a2445d 100644
--- a/packaging/dbscripts/storages_san_sp.sql
+++ b/packaging/dbscripts/storages_san_sp.sql
@@ -534,11 +534,11 @@
 
 
 
-Create or replace FUNCTION 
GetAllConnectableStorageSeverConnection(v_storage_pool_id UUID)
+Create or replace FUNCTION 
GetConnectableStorageConnectionsByStorageType(v_storage_pool_id UUID, 
v_storage_type integer)
 RETURNS SETOF storage_server_connections STABLE
    AS $procedure$
 BEGIN
-RETURN QUERY SELECT distinct storage_server_connections.*
+RETURN QUERY SELECT * FROM (SELECT distinct storage_server_connections.*
    FROM
    LUN_storage_server_connection_map LUN_storage_server_connection_map
    INNER JOIN  LUNs ON LUN_storage_server_connection_map.LUN_id = LUNs.LUN_id
@@ -549,7 +549,8 @@
    SELECT distinct storage_server_connections.*
    FROM         storage_server_connections
    INNER JOIN  storage_domains ON storage_server_connections.id = 
storage_domains.storage
-   WHERE     (storage_domains.storage_pool_id = v_storage_pool_id and 
storage_domains.status in(0,3,4));
+   WHERE     (storage_domains.storage_pool_id = v_storage_pool_id and 
storage_domains.status in(0,3,4))
+   ) connections WHERE (v_storage_type is NULL or connections.storage_type = 
v_storage_type);
 END; $procedure$
 LANGUAGE plpgsql;
 


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

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

Reply via email to