]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util.disk do not modify self instance of Size objects
authorAlfredo Deza <adeza@redhat.com>
Wed, 8 Aug 2018 16:54:23 +0000 (12:54 -0400)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 29 Aug 2018 18:31:55 +0000 (13:31 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 00dba2e83ad80cd41b6b29efa642e2da826c2124)

src/ceph-volume/ceph_volume/util/disk.py

index 70eb8d52864633a2cbbf147b8c5fea88d2aba2ab..fcefb28102ac1eac16c3b542ebe7139bcdbd6de3 100644 (file)
@@ -484,31 +484,31 @@ class Size(object):
 
     def __add__(self, other):
         if isinstance(other, Size):
-            self._b = self._b + other._b
-            return self
+            _b = self._b + other._b
+            return Size(b=_b)
         raise TypeError('Cannot add "Size" object with int')
 
     def __sub__(self, other):
         if isinstance(other, Size):
-            self._b = self._b - other._b
-            return self
+            _b = self._b - other._b
+            return Size(b=_b)
         raise TypeError('Cannot subtract "Size" object from int')
 
     def __mul__(self, other):
         if isinstance(other, Size):
             raise TypeError('Cannot multiply with "Size" object')
-        self._b = self._b * other
-        return self
+        _b = self._b * other
+        return Size(b=_b)
 
     def __truediv__(self, other):
         if isinstance(other, Size):
-            raise TypeError('Cannot divide by "Size" object')
+            return self._b / other._b
         self._b = self._b / other
         return self
 
     def __div__(self, other):
         if isinstance(other, Size):
-            raise TypeError('Cannot divide by "Size" object')
+            return self._b / other._b
         self._b = self._b / other
         return self