Saggi Mizrahi has uploaded a new change for review.

Change subject: Revert ab9e8123: The NFSConnection ctor should not accept non 
numeric values
......................................................................

Revert ab9e8123: The NFSConnection ctor should not accept non numeric values

Because the string sending is a bug in the engine it should be handled
by the backward compatibility layer in HSM.

Also importing storage_exception is a sin

Change-Id: Ic060e2985d853e5228a52c6d245cf2338f9e24e8
Signed-off-by: Saggi Mizrahi <[email protected]>
---
M vdsm/storage/hsm.py
M vdsm/storage/storageServer.py
2 files changed, 16 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/8575/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 6329389..03a9092 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -140,6 +140,16 @@
     return iface
 
 def _connectionDict2ConnectionInfo(conTypeId, conDict):
+    def getIntParam(optDict, key, default):
+        try:
+            res = optDict.get(key, default)
+            if res is None:
+                return res
+
+            return int(res)
+        except ValueError:
+            raise se.InvalidParameterException(key, res)
+
     typeName = CON_TYPE_ID_2_CON_TYPE[conTypeId]
     if typeName == 'localfs':
         params = storageServer.LocaFsConnectionParameters(
@@ -147,9 +157,9 @@
     elif typeName == 'nfs':
         params = storageServer.NfsConnectionParameters(
                 conDict.get('connection', None),
-                conDict.get('retrans', None),
-                conDict.get('timeout', None),
-                conDict.get('protocol_version', 3))
+                getIntParam(conDict, 'retrans', None),
+                getIntParam(conDict, 'timeout', None),
+                getIntParam(conDict, 'protocol_version', 3))
     elif typeName == 'posixfs':
         params = storageServer.PosixFsConnectionParameters(
                 conDict.get('connection', None),
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 269b8eb..a0b5e0c 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -29,7 +29,6 @@
 from collections import namedtuple
 import misc
 from functools import partial
-import storage_exception as se
 
 import mount
 import fileSD
@@ -97,12 +96,6 @@
     conType = d['type']
     params = _TYPE_NT_MAPPING[conType](d.get('params', {}))
     return ConnectionInfo(conType, params)
-
-def _addIntegerOption(options, key, value):
-    try:
-        options.append("%s=%d" % (key, int(value)))
-    except ValueError:
-        raise se.InvalidParameterException(key, value)
 
 class ExampleConnection(object):
     """Do not inherit from this object it is just to show and document the
@@ -256,10 +249,10 @@
         self._timeout = timeout
         self._version = version
         self._retrans = retrans
-        _addIntegerOption(options, "timeo", timeout)
-        _addIntegerOption(options, "retrans", retrans)
+        options.append("timeo=%d" % timeout)
+        options.append("retrans=%d" % retrans)
         if version:
-            _addIntegerOption(options, "vers", version)
+            options.append("vers=%d" % version)
 
         self._mountCon = MountConnection(export, "nfs", ",".join(options))
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic060e2985d853e5228a52c6d245cf2338f9e24e8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to