Sergey Gotliv has uploaded a new change for review.

Change subject: engine: Split nfs and iscsi logic when creating storage 
connection
......................................................................

engine: Split nfs and iscsi logic when creating storage connection

Change-Id: Iba33ea1b40ef1eb9c74cad7b0531dc26e21c049a
Signed-off-by: Sergey Gotliv <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/ConnectStorageServerVDSCommand.java
1 file changed, 31 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/21971/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/ConnectStorageServerVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/ConnectStorageServerVDSCommand.java
index aa4cbd5..8d47141 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/ConnectStorageServerVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/ConnectStorageServerVDSCommand.java
@@ -67,33 +67,40 @@
         return result;
     }
 
-    public static Map<String, String> createStructFromConnection(final 
StorageServerConnections connection,
-                                                                 final 
StoragePool storagePool) {
+    protected static Map<String, String> createStructFromConnection(final 
StorageServerConnections connection,
+                                                                    final 
StoragePool storagePool) {
         // for information, see _connectionDict2ConnectionInfo in 
vdsm/storage/hsm.py
-        DefaultValueMap con = new DefaultValueMap();
-        con.put("id", connection.getid(), Guid.Empty.toString());
-        con.put("connection", connection.getconnection(), "");
-        con.put("portal", connection.getportal(), "");
-        con.put("port", connection.getport(), "");
-        con.put("iqn", connection.getiqn(), "");
-        con.put("user", connection.getuser_name(), "");
-        con.put("password", connection.getpassword(), "");
+        DefaultValueMap conParams = new DefaultValueMap();
+        conParams.put("id", connection.getid(), Guid.Empty.toString());
+        conParams.put("connection", connection.getconnection(), "");
 
-        // storage_pool can be null when discovering iscsi send targets or 
when connecting
-        // through vds which has no storage pool
-        if (storagePool == null || Config.<Boolean> 
GetValue(ConfigValues.AdvancedNFSOptionsEnabled,
-                storagePool.getcompatibility_version().getValue())) {
-            // For mnt_options, vfs_type, and protocol_version - if they are 
null
-            // or empty we should not send a key with an empty value
-            con.putIfNotEmpty("mnt_options", connection.getMountOptions());
-            con.putIfNotEmpty("vfs_type", connection.getVfsType());
-            if (connection.getNfsVersion() != null) {
-                con.put("protocol_version", 
connection.getNfsVersion().getValue());
-            }
-            con.putIfNotEmpty("timeout", connection.getNfsTimeo());
-            con.putIfNotEmpty("retrans", connection.getNfsRetrans());
+        switch (connection.getstorage_type()) {
+            case ISCSI:
+                conParams.put("portal", connection.getportal(), "");
+                conParams.put("port", connection.getport(), "");
+                conParams.put("iqn", connection.getiqn(), "");
+                conParams.put("user", connection.getuser_name(), "");
+                conParams.put("password", connection.getpassword(), "");
+                break;
+
+            case NFS:
+                // storage_pool can be null when discovering iscsi send 
targets or when connecting
+                // through vds which has no storage pool
+                if (storagePool == null || Config.<Boolean> 
GetValue(ConfigValues.AdvancedNFSOptionsEnabled,
+                        storagePool.getcompatibility_version().getValue())) {
+                    // For mnt_options, vfs_type, and protocol_version - if 
they are null
+                    // or empty we should not send a key with an empty value
+                    conParams.putIfNotEmpty("mnt_options", 
connection.getMountOptions());
+                    conParams.putIfNotEmpty("vfs_type", 
connection.getVfsType());
+                    if (connection.getNfsVersion() != null) {
+                        conParams.put("protocol_version", 
connection.getNfsVersion().getValue());
+                    }
+                    conParams.putIfNotEmpty("timeout", 
connection.getNfsTimeo());
+                    conParams.putIfNotEmpty("retrans", 
connection.getNfsRetrans());
+                }
+                break;
         }
-        return con;
+        return conParams;
     }
 
     private void logFailedStorageConnections(Map<String, String> returnValue) {


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

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

Reply via email to