]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use oslo-incubator module units
authorEric Guo <eric.guo@easystack.cn>
Mon, 30 Dec 2013 11:36:49 +0000 (19:36 +0800)
committerChangBo Guo(gcb) <eric.guo@easystack.cn>
Sat, 21 Jun 2014 16:09:40 +0000 (00:09 +0800)
There is Cinder's version units module, that looks good. Considering
consistency with other projects like Nova, Glance, Cinder would be
better to use oslo-incubator's version.

Change-Id: I07e93e9d8a985df0f96c3e80de9c3f23bf6a0c1e

50 files changed:
cinder/backup/drivers/ceph.py
cinder/backup/drivers/swift.py
cinder/image/image_utils.py
cinder/openstack/common/units.py [moved from cinder/units.py with 63% similarity]
cinder/tests/test_coraid.py
cinder/tests/test_glusterfs.py
cinder/tests/test_gpfs.py
cinder/tests/test_hp3par.py
cinder/tests/test_hplefthand.py
cinder/tests/test_image_utils.py
cinder/tests/test_nexenta.py
cinder/tests/test_nfs.py
cinder/tests/test_rbd.py
cinder/tests/test_scality.py
cinder/tests/test_sheepdog.py
cinder/tests/test_solidfire.py
cinder/tests/test_storwize_svc.py
cinder/tests/test_vmware_vmdk.py
cinder/tests/test_vmware_volumeops.py
cinder/tests/test_volume.py
cinder/volume/drivers/coraid.py
cinder/volume/drivers/emc/emc_smis_common.py
cinder/volume/drivers/glusterfs.py
cinder/volume/drivers/hds/hnas_backend.py
cinder/volume/drivers/hds/iscsi.py
cinder/volume/drivers/hds/nfs.py
cinder/volume/drivers/huawei/rest_common.py
cinder/volume/drivers/ibm/gpfs.py
cinder/volume/drivers/ibm/ibmnas.py
cinder/volume/drivers/ibm/storwize_svc/__init__.py
cinder/volume/drivers/lvm.py
cinder/volume/drivers/netapp/eseries/iscsi.py
cinder/volume/drivers/netapp/iscsi.py
cinder/volume/drivers/netapp/nfs.py
cinder/volume/drivers/nexenta/nfs.py
cinder/volume/drivers/nexenta/utils.py
cinder/volume/drivers/nfs.py
cinder/volume/drivers/rbd.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py
cinder/volume/drivers/san/hp/hp_lefthand_rest_proxy.py
cinder/volume/drivers/scality.py
cinder/volume/drivers/sheepdog.py
cinder/volume/drivers/solidfire.py
cinder/volume/drivers/vmware/vmdk.py
cinder/volume/drivers/vmware/volumeops.py
cinder/volume/drivers/xenapi/lib.py
cinder/volume/flows/api/create_volume.py
cinder/volume/utils.py
openstack-common.conf

index a09d0b47767e4793a12af5a65df170954fc777f8..2d97d1dd79bc5d7fd9693a8e68530ad71d3e42a3 100644 (file)
@@ -55,7 +55,7 @@ from cinder.backup.driver import BackupDriver
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import strutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 import cinder.volume.drivers.rbd as rbd_driver
 
@@ -75,7 +75,7 @@ service_opts = [
                help='The Ceph user to connect with. Default here is to use '
                     'the same user as for Cinder volumes. If not using cephx '
                     'this should be set to None.'),
-    cfg.IntOpt('backup_ceph_chunk_size', default=(units.MiB * 128),
+    cfg.IntOpt('backup_ceph_chunk_size', default=(units.Mi * 128),
                help='The chunk size, in bytes, that a backup is broken into '
                     'before transfer to the Ceph object store.'),
     cfg.StrOpt('backup_ceph_pool', default='backups',
@@ -814,7 +814,7 @@ class CephBackupDriver(BackupDriver):
             errmsg = _("Need non-zero volume size")
             raise exception.InvalidParameterValue(errmsg)
 
-        return int(volume['size']) * units.GiB
+        return int(volume['size']) * units.Gi
 
     def _backup_metadata(self, backup):
         """Backup volume metadata.
@@ -1097,7 +1097,7 @@ class CephBackupDriver(BackupDriver):
         volume_name = volume['name']
         backup_id = backup['id']
         backup_volume_id = backup['volume_id']
-        length = int(volume['size']) * units.GiB
+        length = int(volume['size']) * units.Gi
 
         base_name = self._get_backup_base_name(backup['volume_id'],
                                                diff_format=True)
index 31221342a61a564c3a65008bf12b86447d1bf4fe..8eb83f574d84f0d8da28c306c375d9b04e530bd8 100644 (file)
@@ -43,7 +43,7 @@ from cinder.backup.driver import BackupDriver
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
-from cinder import units
+from cinder.openstack.common import units
 from swiftclient import client as swift
 
 
@@ -231,7 +231,7 @@ class SwiftBackupDriver(BackupDriver):
         backup['service_metadata'] = object_prefix
         self.db.backup_update(self.context, backup_id, {'service_metadata':
                                                         object_prefix})
-        volume_size_bytes = volume['size'] * units.GiB
+        volume_size_bytes = volume['size'] * units.Gi
         availability_zone = self.az
         LOG.debug('starting backup of volume: %(volume_id)s to swift,'
                   ' volume size: %(volume_size_bytes)d, swift object names'
index 4e7de692e7cb4c3c5239fa3c22179d90f656829b..b2b750ab509361c069176844736a876f0e8606b2 100644 (file)
@@ -35,7 +35,7 @@ from cinder.openstack.common import fileutils
 from cinder.openstack.common import imageutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume import utils as volume_utils
 
@@ -182,7 +182,7 @@ def fetch_to_volume_format(context, image_service,
             return
 
         data = qemu_img_info(tmp)
-        virt_size = data.virtual_size / units.GiB
+        virt_size = data.virtual_size / units.Gi
 
         # NOTE(xqueralt): If the image virtual size doesn't fit in the
         # requested volume there is no point on resizing it because it will
similarity index 63%
rename from cinder/units.py
rename to cinder/openstack/common/units.py
index 23e92a336ea862170bea00911153fc9e47027766..84b518ca8de65e1be9e9817cbd18451f25087421 100644 (file)
@@ -1,4 +1,5 @@
-#    Copyright 2011 OpenStack Foundation
+# Copyright 2013 IBM Corp
+# All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 #    License for the specific language governing permissions and limitations
 #    under the License.
+
 """
-A module where we define some basic units for use across Cinder.
+Unit constants
 """
 
-KiB = 1024
-MiB = KiB * 1024
-GiB = MiB * 1024
-TiB = GiB * 1024
+#Binary unit constants.
+Ki = 1024
+Mi = 1024 ** 2
+Gi = 1024 ** 3
+Ti = 1024 ** 4
+Pi = 1024 ** 5
+Ei = 1024 ** 6
+Zi = 1024 ** 7
+Yi = 1024 ** 8
+
+#Decimal unit constants.
+k = 1000
+M = 1000 ** 2
+G = 1000 ** 3
+T = 1000 ** 4
+P = 1000 ** 5
+E = 1000 ** 6
+Z = 1000 ** 7
+Y = 1000 ** 8
index ff85d58ecfb07447a90414e059c8bd2910a1fa0f..f93a232581f1cf8aee97741da9a56ba242af989b 100644 (file)
@@ -24,8 +24,8 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import jsonutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder import utils
 from cinder.volume import configuration as conf
 from cinder.volume.drivers import coraid
@@ -37,7 +37,7 @@ LOG = logging.getLogger(__name__)
 
 
 def to_coraid_kb(gb):
-    return math.ceil(float(gb) * units.GiB / 1000)
+    return math.ceil(float(gb) * units.Gi / 1000)
 
 
 def coraid_volume_size(gb):
index 82ed0321c2301480ea18f6415dfea4d89bcbb92a..046fda4485c2f2d399686fe6f5bb93df300a14f0 100644 (file)
@@ -33,8 +33,8 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import imageutils
 from cinder.openstack.common import processutils as putils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder import utils
 from cinder.volume import configuration as conf
 from cinder.volume import driver as base_driver
@@ -473,9 +473,9 @@ class GlusterFsDriverTestCase(test.TestCase):
 
         mox.StubOutWithMock(drv, '_get_available_capacity')
         drv._get_available_capacity(self.TEST_EXPORT1).\
-            AndReturn((2 * units.GiB, 5 * units.GiB))
+            AndReturn((2 * units.Gi, 5 * units.Gi))
         drv._get_available_capacity(self.TEST_EXPORT2).\
-            AndReturn((3 * units.GiB, 10 * units.GiB))
+            AndReturn((3 * units.Gi, 10 * units.Gi))
 
         mox.ReplayAll()
 
@@ -494,9 +494,9 @@ class GlusterFsDriverTestCase(test.TestCase):
 
         mox.StubOutWithMock(drv, '_get_available_capacity')
         drv._get_available_capacity(self.TEST_EXPORT1).\
-            AndReturn((0, 5 * units.GiB))
+            AndReturn((0, 5 * units.Gi))
         drv._get_available_capacity(self.TEST_EXPORT2).\
-            AndReturn((0, 10 * units.GiB))
+            AndReturn((0, 10 * units.Gi))
 
         mox.ReplayAll()
 
@@ -577,7 +577,7 @@ class GlusterFsDriverTestCase(test.TestCase):
 
         drv._execute('qemu-img', 'create', '-f', 'qcow2',
                      '-o', 'preallocation=metadata', path,
-                     str(volume['size'] * units.GiB),
+                     str(volume['size'] * units.Gi),
                      run_as_root=True)
 
         drv._execute('chmod', 'ugo+rw', path, run_as_root=True)
index 460ec30487f57021d7fd90ed05b0246bef79b141..8637be815e128e52537a3b172a1bc2a204e1c1f8 100644 (file)
@@ -23,8 +23,8 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder import utils
 from cinder.volume import configuration as conf
 from cinder.volume.drivers.ibm import gpfs
@@ -750,7 +750,7 @@ class GPFSDriverTestCase(test.TestCase):
                                          mock_rw_permission,
                                          mock_gpfs_redirect,
                                          mock_resize_volume_file):
-        mock_resize_volume_file.return_value = 5 * units.GiB
+        mock_resize_volume_file.return_value = 5 * units.Gi
         volume = {}
         volume['size'] = 1000
         self.assertEqual(self.driver.create_volume_from_snapshot(volume, ''),
@@ -765,7 +765,7 @@ class GPFSDriverTestCase(test.TestCase):
                                   mock_create_gpfs_clone,
                                   mock_rw_permission,
                                   mock_resize_volume_file):
-        mock_resize_volume_file.return_value = 5 * units.GiB
+        mock_resize_volume_file.return_value = 5 * units.Gi
         volume = {}
         volume['size'] = 1000
         self.assertEqual(self.driver.create_cloned_volume(volume, ''),
@@ -955,7 +955,7 @@ class GPFSDriverTestCase(test.TestCase):
         self.assertEqual(None, self.driver.terminate_connection('', ''))
 
     def test_get_volume_stats(self):
-        fake_avail = 80 * units.GiB
+        fake_avail = 80 * units.Gi
         fake_size = 2 * fake_avail
         with mock.patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver.'
                         '_get_available_capacity',
@@ -1384,14 +1384,14 @@ class GPFSDriverTestCase(test.TestCase):
         data = FakeQemuImgInfo()
         data.file_format = 'qcow2'
         data.backing_file = None
-        data.virtual_size = 1 * units.GiB
+        data.virtual_size = 1 * units.Gi
         return data
 
     def _fake_qemu_raw_image_info(self, path):
         data = FakeQemuImgInfo()
         data.file_format = 'raw'
         data.backing_file = None
-        data.virtual_size = 1 * units.GiB
+        data.virtual_size = 1 * units.Gi
         return data
 
     def _fake_retype_arguments(self):
index 561945d5581d5d9937023c284abfb60c49437bd2..6f33950acad7f0fa0c66a00f2cd2b85c28860907 100644 (file)
@@ -20,8 +20,8 @@ import mock
 from cinder import context
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 
 from cinder.tests import fake_hp_3par_client as hp3parclient
 from cinder.volume.drivers.san.hp import hp_3par_fc as hpfcdriver
@@ -772,7 +772,7 @@ class HP3PARBaseDriver(object):
         old_size = self.volume['size']
         new_size = old_size + grow_size
         self.driver.extend_volume(self.volume, str(new_size))
-        growth_size_mib = grow_size * units.KiB
+        growth_size_mib = grow_size * units.Ki
 
         expected = [
             mock.call.growVolume(self.VOLUME_3PAR_NAME, growth_size_mib)]
index bf7b83eef3bfe1ac8e356089b6bed97fd9058e86..e9ef3f55a7124d336a29b5507947679ed2d72a08 100644 (file)
@@ -19,8 +19,8 @@ import mock
 from cinder import context
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 
 from cinder.tests import fake_hp_lefthand_client as hplefthandclient
 from cinder.volume.drivers.san.hp import hp_lefthand_iscsi
@@ -672,8 +672,8 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
         _mock_client.return_value.getClusterByName.return_value = {
             'id': 1, 'virtualIPAddresses': [{'ipV4Address': '10.0.1.6'}]}
         _mock_client.return_value.getCluster.return_value = {
-            'spaceTotal': units.GiB * 500,
-            'spaceAvailable': units.GiB * 250}
+            'spaceTotal': units.Gi * 500,
+            'spaceAvailable': units.Gi * 250}
         self.driver = hp_lefthand_iscsi.HPLeftHandISCSIDriver(
             configuration=config)
         self.driver.do_setup(None)
@@ -699,7 +699,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
             mock.call.createVolume(
                 'fakevolume',
                 1,
-                units.GiB,
+                units.Gi,
                 {'isThinProvisioned': True, 'clusterName': 'CloudCluster1'})]
 
         mock_client.assert_has_calls(expected)
@@ -737,7 +737,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
             mock.call.createVolume(
                 'fakevolume',
                 1,
-                units.GiB,
+                units.Gi,
                 {'isThinProvisioned': False, 'clusterName': 'CloudCluster1'})]
 
         mock_client.assert_has_calls(expected)
@@ -785,7 +785,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
 
         expected = self.driver_startup_call_stack + [
             mock.call.getVolumeByName('fakevolume'),
-            mock.call.modifyVolume(1, {'size': 2 * units.GiB})]
+            mock.call.modifyVolume(1, {'size': 2 * units.Gi})]
 
         # validate call chain
         mock_client.assert_has_calls(expected)
@@ -1372,7 +1372,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
             mock.call.createVolume(
                 'fakevolume',
                 1,
-                units.GiB,
+                units.Gi,
                 {'isThinProvisioned': True, 'clusterName': 'CloudCluster1'})]
 
         mock_client.assert_has_calls(expected)
@@ -1403,7 +1403,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
             mock.call.createVolume(
                 'fakevolume',
                 1,
-                units.GiB,
+                units.Gi,
                 {'isThinProvisioned': True,
                  'clusterName': 'CloudCluster1',
                  'isAdaptiveOptimizationEnabled': False})]
index 03c4dcb400a56b421f1ceb8094e746774d4a5102..d1fe46bfb571bb3f1175272fd1f553632c037166 100644 (file)
@@ -23,8 +23,8 @@ from cinder import context
 from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import processutils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder import utils
 
 
@@ -37,7 +37,7 @@ class FakeImageService:
         data.write(self._imagedata.get(image_id, ''))
 
     def show(self, context, image_id):
-        return {'size': 2 * units.GiB,
+        return {'size': 2 * units.Gi,
                 'disk_format': 'qcow2',
                 'container_format': 'bare'}
 
index 35982521c037bc474508d86eb194b8cc38b21785..b4468454cf8bf706680daa78c49079280451ec0f 100644 (file)
@@ -24,8 +24,8 @@ import mox as mox_lib
 
 from cinder import context
 from cinder import db
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder.volume import configuration as conf
 from cinder.volume.drivers import nexenta
 from cinder.volume.drivers.nexenta import iscsi
@@ -660,9 +660,9 @@ class TestNexentaNfsDriver(test.TestCase):
         self.mox.ReplayAll()
         total, free, allocated = self.drv._get_capacity_info(self.TEST_EXPORT1)
 
-        self.assertEqual(total, 3 * units.GiB)
-        self.assertEqual(free, units.GiB)
-        self.assertEqual(allocated, 2 * units.GiB)
+        self.assertEqual(total, 3 * units.Gi)
+        self.assertEqual(free, units.Gi)
+        self.assertEqual(allocated, 2 * units.Gi)
 
     def test_get_share_datasets(self):
         self.drv.share2nms = {self.TEST_EXPORT1: self.nms_mock}
@@ -748,8 +748,8 @@ class TestNexentaUtils(test.TestCase):
             ('1023b', 1023),
             ('0B', 0),
             # Test other units
-            ('1M', units.MiB),
-            ('1.0M', units.MiB),
+            ('1M', units.Mi),
+            ('1.0M', units.Mi),
         )
 
         for value, result in values_to_test:
@@ -761,9 +761,9 @@ class TestNexentaUtils(test.TestCase):
     def test_str2gib_size(self):
         self.assertEqual(utils.str2gib_size('1024M'), 1)
         self.assertEqual(utils.str2gib_size('300M'),
-                         300 * units.MiB // units.GiB)
+                         300 * units.Mi // units.Gi)
         self.assertEqual(utils.str2gib_size('1.2T'),
-                         1.2 * units.TiB // units.GiB)
+                         1.2 * units.Ti // units.Gi)
         self.assertRaises(ValueError, utils.str2gib_size, 'A')
 
     def test_parse_nms_url(self):
index f59a2017ef0ecf5480cfb65619f56704c9d8d73c..d9c9961863652ed91a0d964c43312511e1de424e 100644 (file)
@@ -28,8 +28,8 @@ from oslo.config import cfg
 from cinder import context
 from cinder import exception
 from cinder.image import image_utils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder.volume import configuration as conf
 from cinder.volume.drivers import nfs
 
@@ -87,7 +87,7 @@ class RemoteFsDriverTestCase(test.TestCase):
         mox.StubOutWithMock(drv, '_execute')
         drv._execute('qemu-img', 'create', '-f', 'qcow2',
                      '-o', 'preallocation=metadata', '/path',
-                     '%s' % str(file_size * units.GiB), run_as_root=True)
+                     '%s' % str(file_size * units.Gi), run_as_root=True)
 
         mox.ReplayAll()
 
@@ -183,7 +183,7 @@ class NfsDriverTestCase(test.TestCase):
 
         mox.StubOutWithMock(image_utils, 'qemu_img_info')
         data = mox_lib.MockAnything()
-        data.virtual_size = 1 * units.GiB
+        data.virtual_size = 1 * units.Gi
         image_utils.qemu_img_info(TEST_IMG_SOURCE).AndReturn(data)
 
         mox.ReplayAll()
@@ -412,17 +412,17 @@ class NfsDriverTestCase(test.TestCase):
 
         mox.StubOutWithMock(drv, '_get_capacity_info')
         drv._get_capacity_info(self.TEST_NFS_EXPORT1).\
-            AndReturn((5 * units.GiB, 2 * units.GiB,
-                       2 * units.GiB))
+            AndReturn((5 * units.Gi, 2 * units.Gi,
+                       2 * units.Gi))
         drv._get_capacity_info(self.TEST_NFS_EXPORT1).\
-            AndReturn((5 * units.GiB, 2 * units.GiB,
-                       2 * units.GiB))
+            AndReturn((5 * units.Gi, 2 * units.Gi,
+                       2 * units.Gi))
         drv._get_capacity_info(self.TEST_NFS_EXPORT2).\
-            AndReturn((10 * units.GiB, 3 * units.GiB,
-                       1 * units.GiB))
+            AndReturn((10 * units.Gi, 3 * units.Gi,
+                       1 * units.Gi))
         drv._get_capacity_info(self.TEST_NFS_EXPORT2).\
-            AndReturn((10 * units.GiB, 3 * units.GiB,
-                       1 * units.GiB))
+            AndReturn((10 * units.Gi, 3 * units.Gi,
+                       1 * units.Gi))
 
         mox.ReplayAll()
 
@@ -440,10 +440,10 @@ class NfsDriverTestCase(test.TestCase):
 
         mox.StubOutWithMock(drv, '_get_capacity_info')
         drv._get_capacity_info(self.TEST_NFS_EXPORT1).\
-            AndReturn((5 * units.GiB, 0, 5 * units.GiB))
+            AndReturn((5 * units.Gi, 0, 5 * units.Gi))
         drv._get_capacity_info(self.TEST_NFS_EXPORT2).\
-            AndReturn((10 * units.GiB, 0,
-                       10 * units.GiB))
+            AndReturn((10 * units.Gi, 0,
+                       10 * units.Gi))
 
         mox.ReplayAll()
 
@@ -612,11 +612,11 @@ class NfsDriverTestCase(test.TestCase):
         drv._ensure_shares_mounted()
 
         drv._get_capacity_info(self.TEST_NFS_EXPORT1).\
-            AndReturn((10 * units.GiB, 2 * units.GiB,
-                       2 * units.GiB))
+            AndReturn((10 * units.Gi, 2 * units.Gi,
+                       2 * units.Gi))
         drv._get_capacity_info(self.TEST_NFS_EXPORT2).\
-            AndReturn((20 * units.GiB, 3 * units.GiB,
-                       3 * units.GiB))
+            AndReturn((20 * units.Gi, 3 * units.Gi,
+                       3 * units.Gi))
 
         mox.ReplayAll()
 
@@ -637,9 +637,9 @@ class NfsDriverTestCase(test.TestCase):
                                                    requested_volume_size)
 
     def test_is_share_eligible(self):
-        total_size = 100.0 * units.GiB
-        total_available = 90.0 * units.GiB
-        total_allocated = 10.0 * units.GiB
+        total_size = 100.0 * units.Gi
+        total_available = 90.0 * units.Gi
+        total_allocated = 10.0 * units.Gi
         requested_volume_size = 1  # GiB
 
         self.assertTrue(self._check_is_share_eligible(total_size,
@@ -648,9 +648,9 @@ class NfsDriverTestCase(test.TestCase):
                                                       requested_volume_size))
 
     def test_is_share_eligible_above_used_ratio(self):
-        total_size = 100.0 * units.GiB
-        total_available = 4.0 * units.GiB
-        total_allocated = 96.0 * units.GiB
+        total_size = 100.0 * units.Gi
+        total_available = 4.0 * units.Gi
+        total_allocated = 96.0 * units.Gi
         requested_volume_size = 1  # GiB
 
         # Check used > used_ratio statement entered
@@ -660,9 +660,9 @@ class NfsDriverTestCase(test.TestCase):
                                                        requested_volume_size))
 
     def test_is_share_eligible_above_oversub_ratio(self):
-        total_size = 100.0 * units.GiB
-        total_available = 10.0 * units.GiB
-        total_allocated = 90.0 * units.GiB
+        total_size = 100.0 * units.Gi
+        total_available = 10.0 * units.Gi
+        total_allocated = 90.0 * units.Gi
         requested_volume_size = 10  # GiB
 
         # Check apparent_available <= requested_volume_size statement entered
@@ -672,9 +672,9 @@ class NfsDriverTestCase(test.TestCase):
                                                        requested_volume_size))
 
     def test_is_share_eligible_reserved_space_above_oversub_ratio(self):
-        total_size = 100.0 * units.GiB
-        total_available = 10.0 * units.GiB
-        total_allocated = 100.0 * units.GiB
+        total_size = 100.0 * units.Gi
+        total_available = 10.0 * units.Gi
+        total_allocated = 100.0 * units.Gi
         requested_volume_size = 1  # GiB
 
         # Check total_allocated / total_size >= oversub_ratio
@@ -738,7 +738,7 @@ class NfsDriverTestCase(test.TestCase):
         path = 'fake/path'
         size = 2
         data = mock.MagicMock()
-        data.virtual_size = size * units.GiB
+        data.virtual_size = size * units.Gi
 
         with mock.patch.object(image_utils, 'qemu_img_info',
                                return_value=data):
@@ -750,7 +750,7 @@ class NfsDriverTestCase(test.TestCase):
         path = 'fake/path'
         size = 2
         data = mock.MagicMock()
-        data.virtual_size = (size + 1) * units.GiB
+        data.virtual_size = (size + 1) * units.Gi
 
         with mock.patch.object(image_utils, 'qemu_img_info',
                                return_value=data):
index 906e6ce3c1f104b079c8d9318a3be1181a79dd30..5e9cedadaf69e453cc25bedc04aeaf06e43930b0 100644 (file)
@@ -26,10 +26,10 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
+from cinder.openstack.common import units
 from cinder import test
 from cinder.tests.image import fake as fake_image
 from cinder.tests.test_volume import DriverTestCase
-from cinder import units
 from cinder.volume import configuration as conf
 import cinder.volume.drivers.rbd as driver
 from cinder.volume.flows.manager import create_volume
@@ -173,10 +173,10 @@ class RBDTestCase(test.TestCase):
 
             self.driver.create_volume(self.volume)
 
-            chunk_size = self.cfg.rbd_store_chunk_size * units.MiB
+            chunk_size = self.cfg.rbd_store_chunk_size * units.Mi
             order = int(math.log(chunk_size, 2))
             args = [client.ioctx, str(self.volume_name),
-                    self.volume_size * units.GiB, order]
+                    self.volume_size * units.Gi, order]
             kwargs = {'old_format': False,
                       'features': self.mock_rbd.RBD_FEATURE_LAYERING}
             self.mock_rbd.RBD.create.assert_called_once_with(*args, **kwargs)
@@ -196,10 +196,10 @@ class RBDTestCase(test.TestCase):
 
             self.driver.create_volume(self.volume)
 
-            chunk_size = self.cfg.rbd_store_chunk_size * units.MiB
+            chunk_size = self.cfg.rbd_store_chunk_size * units.Mi
             order = int(math.log(chunk_size, 2))
             args = [client.ioctx, str(self.volume_name),
-                    self.volume_size * units.GiB, order]
+                    self.volume_size * units.Gi, order]
             kwargs = {'old_format': True,
                       'features': 0}
             self.mock_rbd.RBD.create.assert_called_once_with(*args, **kwargs)
@@ -667,7 +667,7 @@ class RBDTestCase(test.TestCase):
                     'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
 
         self.mox.StubOutWithMock(self.driver, '_resize')
-        size = int(fake_size) * units.GiB
+        size = int(fake_size) * units.Gi
         self.driver._resize(fake_vol, size=size)
 
         self.mox.ReplayAll()
index 7f028e17f850ce9b42cd5bfc4cdc8385ec8b57ad..8c2c5455223edbf9bc7dc7bd2fd480e9216de99d 100644 (file)
@@ -26,8 +26,8 @@ import mox as mox_lib
 from cinder import context
 from cinder import exception
 from cinder.image import image_utils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder import utils
 from cinder.volume.drivers import scality
 
@@ -181,7 +181,7 @@ class ScalityDriverTestCase(test.TestCase):
                                       self.TEST_VOLNAME))
         self.assertTrue(os.path.isfile(self.TEST_VOLPATH))
         self.assertEqual(os.stat(self.TEST_VOLPATH).st_size,
-                         100 * units.MiB)
+                         100 * units.Mi)
 
     def test_delete_volume(self):
         """Expected behaviour for delete_volume."""
index 3f8e93b76231715ed701d6581d200d9f1195191e..d19aad63de2f3e7e63676f1a3fa82d4c884db12f 100644 (file)
@@ -21,8 +21,8 @@ import tempfile
 
 from cinder.image import image_utils
 from cinder.openstack.common import processutils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder.volume.drivers.sheepdog import SheepdogDriver
 
 
@@ -69,8 +69,8 @@ class SheepdogTestCase(test.TestCase):
             vendor_name='Open Source',
             dirver_version=self.driver.VERSION,
             storage_protocol='sheepdog',
-            total_capacity_gb=float(107287605248) / units.GiB,
-            free_capacity_gb=float(107287605248 - 3623897354) / units.GiB,
+            total_capacity_gb=float(107287605248) / units.Gi,
+            free_capacity_gb=float(107287605248 - 3623897354) / units.Gi,
             reserved_percentage=0,
             QoS_support=False)
         actual = self.driver.get_volume_stats(True)
@@ -134,7 +134,7 @@ class SheepdogTestCase(test.TestCase):
                     'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
 
         self.mox.StubOutWithMock(self.driver, '_resize')
-        size = int(fake_size) * units.GiB
+        size = int(fake_size) * units.Gi
         self.driver._resize(fake_vol, size=size)
 
         self.mox.ReplayAll()
index 87bbd2edc770f8d882f641284e2e7874bfeb50f3..fb462f9a67d315bd5732274efc9281101e78835f 100644 (file)
@@ -20,8 +20,8 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder.volume import configuration as conf
 from cinder.volume.drivers.solidfire import SolidFireDriver
 from cinder.volume import qos_specs
@@ -121,7 +121,7 @@ class SolidFireVolumeTestCase(test.TestCase):
                              'name': test_name,
                              'accountID': 25,
                              'sliceCount': 1,
-                             'totalSize': 1 * units.GiB,
+                             'totalSize': 1 * units.Gi,
                              'enable512e': True,
                              'access': "readWrite",
                              'status': "active",
index 7ca0276e1664b4e03d94e495460815c93d98e43f..91021242c158e3f16d185f3ac3befadbf3d8c69c 100644 (file)
@@ -29,9 +29,9 @@ from cinder.openstack.common import excutils
 from cinder.openstack.common import importutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
+from cinder.openstack.common import units
 from cinder import test
 from cinder.tests import utils as testutils
-from cinder import units
 from cinder import utils
 from cinder.volume import configuration as conf
 from cinder.volume.drivers.ibm import storwize_svc
@@ -627,7 +627,7 @@ port_speed!N/A
             return self._errors['CMMVC5753E']
 
         curr_size = int(self._volumes_list[vol_name]['capacity'])
-        addition = size * units.GiB
+        addition = size * units.Gi
         self._volumes_list[vol_name]['capacity'] = str(curr_size + addition)
         return ('', '')
 
@@ -1765,7 +1765,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
 
         # Make sure volume attributes are as they should be
         attributes = self.driver._helpers.get_vdisk_attributes(volume['name'])
-        attr_size = float(attributes['capacity']) / units.GiB  # bytes to GB
+        attr_size = float(attributes['capacity']) / units.Gi  # bytes to GB
         self.assertEqual(attr_size, float(volume['size']))
         pool = self.driver.configuration.local_conf.storwize_svc_volpool_name
         self.assertEqual(attributes['mdisk_grp_name'], pool)
@@ -2230,7 +2230,8 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         volume = self._create_volume()
         self.driver.extend_volume(volume, '13')
         attrs = self.driver._helpers.get_vdisk_attributes(volume['name'])
-        vol_size = int(attrs['capacity']) / units.GiB
+        vol_size = int(attrs['capacity']) / units.Gi
+
         self.assertAlmostEqual(vol_size, 13)
 
         snap = self._generate_vol_info(volume['name'], volume['id'])
index b8cb47825022cec17d3d2cb075f8ca61168a1c55..200ebbf1fc071be07968e565a7416ae4abdd9402 100644 (file)
@@ -25,8 +25,8 @@ import mox
 
 from cinder import exception
 from cinder.image import glance
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder.volume import configuration
 from cinder.volume.drivers.vmware import api
 from cinder.volume.drivers.vmware import error_util
@@ -494,7 +494,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         volumeops.get_dc.assert_called_once_with(rp)
         volumeops.get_vmfolder.assert_called_once_with(mock.sentinel.dc)
         driver._get_storage_profile.assert_called_once_with(volume)
-        size = volume['size'] * units.GiB
+        size = volume['size'] * units.Gi
         driver._select_datastore_summary.assert_called_once_with(size, dss)
 
     def test_get_disk_type(self):
@@ -533,7 +533,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         backing = FakeMor('VirtualMachine', 'my_back')
         m.StubOutWithMock(self._volumeops, 'create_backing')
         self._volumeops.create_backing(volume['name'],
-                                       volume['size'] * units.MiB,
+                                       volume['size'] * units.Mi,
                                        mox.IgnoreArg(), folder,
                                        resource_pool, host,
                                        mox.IgnoreArg(),
@@ -957,7 +957,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         fake_context = mock.sentinel.context
         fake_image_id = 'image-id'
         fake_image_meta = {'disk_format': 'vmdk',
-                           'size': 2 * units.GiB,
+                           'size': 2 * units.Gi,
                            'properties': {'vmware_disktype': 'preallocated'}}
         image_service = mock.Mock(glance.GlanceImageService)
         fake_size = 3
@@ -1051,8 +1051,8 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         fake_context = mock.Mock()
         fake_backing = mock.sentinel.backing
         fake_image_id = 'image-id'
-        size = 5 * units.GiB
-        size_gb = float(size) / units.GiB
+        size = 5 * units.Gi
+        size_gb = float(size) / units.Gi
         fake_volume_size = 1 + size_gb
         fake_image_meta = {'disk_format': 'vmdk', 'size': size,
                            'properties': {'vmware_disktype':
@@ -1189,7 +1189,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         volume = FakeObject()
         volume['name'] = vol_name
         size_gb = 5
-        size = size_gb * units.GiB
+        size = size_gb * units.Gi
         volume['size'] = size_gb
         volume['project_id'] = project_id
         volume['instance_uuid'] = None
@@ -1851,7 +1851,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
                                                         self.VOLUME_FOLDER)
         driver._get_storage_profile.assert_called_once_with(volume)
         driver._filter_ds_by_profile.assert_called_once_with(dss, profile)
-        size = volume['size'] * units.GiB
+        size = volume['size'] * units.Gi
         driver._select_datastore_summary.assert_called_once_with(size,
                                                                  filtered_dss)
 
index 5c761ecb4cc8384751a6877926599f796b1c23ab..d3dade714c29df6a9c7c580db3c384a335a3360f 100644 (file)
@@ -19,8 +19,8 @@ Test suite for VMware VMDK driver volumeops module.
 
 import mock
 
+from cinder.openstack.common import units
 from cinder import test
-from cinder import units
 from cinder.volume.drivers.vmware import error_util
 from cinder.volume.drivers.vmware import vim_util
 from cinder.volume.drivers.vmware import volumeops
@@ -801,7 +801,7 @@ class VolumeOpsTestCase(test.TestCase):
         invoke_api.return_value = task
         disk_mgr = self.session.vim.service_content.virtualDiskManager
         fake_size = 5
-        fake_size_in_kb = fake_size * units.MiB
+        fake_size_in_kb = fake_size * units.Mi
         fake_name = 'fake_volume_0000000001'
         fake_dc = mock.sentinel.datacenter
         self.vops.extend_virtual_disk(fake_size,
index bc9218feb1f268151c0b38afb286aac348f434e7..6b53c5d6004197f67ad3f46e133d0210885b9b18 100644 (file)
@@ -44,6 +44,7 @@ from cinder.openstack.common import fileutils
 from cinder.openstack.common import importutils
 from cinder.openstack.common import jsonutils
 from cinder.openstack.common import timeutils
+from cinder.openstack.common import units
 import cinder.policy
 from cinder import quota
 from cinder import test
@@ -53,7 +54,6 @@ from cinder.tests import fake_notifier
 from cinder.tests.image import fake as fake_image
 from cinder.tests.keymgr import fake as fake_keymgr
 from cinder.tests import utils as tests_utils
-from cinder import units
 from cinder import utils
 import cinder.volume
 from cinder.volume import configuration as conf
@@ -83,7 +83,7 @@ class FakeImageService:
         pass
 
     def show(self, context, image_id):
-        return {'size': 2 * units.GiB,
+        return {'size': 2 * units.Gi,
                 'disk_format': 'raw',
                 'container_format': 'bare',
                 'status': 'active'}
@@ -2066,7 +2066,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         """Verify that an image which is too big will fail correctly."""
         class _ModifiedFakeImageService(FakeImageService):
             def show(self, context, image_id):
-                return {'size': 2 * units.GiB + 1,
+                return {'size': 2 * units.Gi + 1,
                         'disk_format': 'raw',
                         'container_format': 'bare',
                         'status': 'active'}
@@ -2083,7 +2083,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         """Verify volumes smaller than image minDisk will cause an error."""
         class _ModifiedFakeImageService(FakeImageService):
             def show(self, context, image_id):
-                return {'size': 2 * units.GiB,
+                return {'size': 2 * units.Gi,
                         'disk_format': 'raw',
                         'container_format': 'bare',
                         'min_disk': 5,
@@ -2101,7 +2101,7 @@ class VolumeTestCase(BaseVolumeTestCase):
         """Verify create volume from image will cause an error."""
         class _ModifiedFakeImageService(FakeImageService):
             def show(self, context, image_id):
-                return {'size': 2 * units.GiB,
+                return {'size': 2 * units.Gi,
                         'disk_format': 'raw',
                         'container_format': 'bare',
                         'min_disk': 5,
index 1abab76ae075e09a9e9b9b54dc9c22f89379ed14..6ee1be08826e6e03463268546e89e269fb173658 100644 (file)
@@ -33,7 +33,7 @@ from cinder import exception
 from cinder.openstack.common import jsonutils
 from cinder.openstack.common import lockutils
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import driver
 from cinder.volume import volume_types
 
@@ -140,7 +140,7 @@ class CoraidRESTClient(object):
 
 
 def to_coraid_kb(gb):
-    return math.ceil(float(gb) * units.GiB / 1000)
+    return math.ceil(float(gb) * units.Gi / 1000)
 
 
 def coraid_volume_size(gb):
index 368986dae5c057f414fb0e20885477222d19adb7..d457d8a6446904b785dc5668193c29a3ea83cf98 100644 (file)
@@ -27,7 +27,7 @@ from xml.dom.minidom import parseString
 
 from cinder import exception
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import volume_types
 
 LOG = logging.getLogger(__name__)
@@ -80,7 +80,7 @@ class EMCSMISCommon():
     def create_volume(self, volume):
         """Creates a EMC(VMAX/VNX) volume."""
         LOG.debug('Entering create_volume.')
-        volumesize = int(volume['size']) * units.GiB
+        volumesize = int(volume['size']) * units.Gi
         volumename = volume['name']
 
         LOG.info(_('Create Volume: %(volume)s  Size: %(size)lu')
@@ -954,7 +954,7 @@ class EMCSMISCommon():
     def extend_volume(self, volume, new_size):
         """Extends an existing  volume."""
         LOG.debug('Entering extend_volume.')
-        volumesize = int(new_size) * units.GiB
+        volumesize = int(new_size) * units.Gi
         volumename = volume['name']
 
         LOG.info(_('Extend Volume: %(volume)s  New size: %(size)lu')
index a9b2f2c3757c6493678ea187f4a27b33971e9417..c9ff07892f072681971a4088be450c1c3b25348d 100644 (file)
@@ -31,7 +31,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume.drivers import nfs
 
@@ -1104,7 +1104,7 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
                 greatest_share = glusterfs_share
                 greatest_size = capacity
 
-        if volume_size_for * units.GiB > greatest_size:
+        if volume_size_for * units.Gi > greatest_size:
             raise exception.GlusterfsNoSuitableShareFound(
                 volume_size=volume_size_for)
         return greatest_share
index c28c3f650b03bf9a2910589456c444127a1c6e23..802b3b8737e5654399d8d86881006aa6ed071183 100644 (file)
@@ -19,7 +19,7 @@ Hitachi Unified Storage (HUS-HNAS) platform. Backend operations.
 """
 
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 import re
 
@@ -116,13 +116,13 @@ class HnasBackend():
                     (inf[0], inf[1], inf[2], inf[3], inf[5], inf[7])
                 (availunit, usedunit) = (inf[4], inf[6])
                 if usedunit == 'GB':
-                    usedmultiplier = units.KiB
+                    usedmultiplier = units.Ki
                 else:
-                    usedmultiplier = units.MiB
+                    usedmultiplier = units.Mi
                 if availunit == 'GB':
-                    availmultiplier = units.KiB
+                    availmultiplier = units.Ki
                 else:
-                    availmultiplier = units.MiB
+                    availmultiplier = units.Mi
                 m = re.match("\((\d+)\%\)", perstr)
                 if m:
                     percent = m.group(1)
index c41ffa2f31b83d97fab1a934c5b77926f5bee24a..2908c842408a08bdd035215859c082f846b5a381 100644 (file)
@@ -24,7 +24,7 @@ from xml.etree import ElementTree as ETree
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume import driver
 from cinder.volume.drivers.hds.hnas_backend import HnasBackend
@@ -286,7 +286,7 @@ class HDSISCSIDriver(driver.ISCSIDriver):
             if 'HDP' in line:
                 (hdp, size, _ign, used) = line.split()[1:5]  # in MB
                 LOG.debug("stats: looking for: %s", hdp)
-                if int(hdp) >= units.KiB:        # HNAS fsid
+                if int(hdp) >= units.Ki:        # HNAS fsid
                     hdp = line.split()[11]
                 if hdp in self.config['hdp'].keys():
                     total_cap += int(size)
@@ -295,9 +295,9 @@ class HDSISCSIDriver(driver.ISCSIDriver):
         LOG.info("stats: total: %d used: %d" % (total_cap, total_used))
 
         hnas_stat = {}
-        hnas_stat['total_capacity_gb'] = int(total_cap / units.KiB)  # in GB
+        hnas_stat['total_capacity_gb'] = int(total_cap / units.Ki)  # in GB
         hnas_stat['free_capacity_gb'] = \
-            int((total_cap - total_used) / units.KiB)
+            int((total_cap - total_used) / units.Ki)
         be_name = self.configuration.safe_get('volume_backend_name')
         hnas_stat["volume_backend_name"] = be_name or 'HDSISCSIDriver'
         hnas_stat["vendor_name"] = 'HDS'
@@ -321,8 +321,8 @@ class HDSISCSIDriver(driver.ISCSIDriver):
         for line in out.split('\n'):
             if 'HDP' in line:
                 inf = line.split()
-                if int(inf[1]) >= units.KiB:
-                    # HDP fsids start at units.KiB (1024)
+                if int(inf[1]) >= units.Ki:
+                    # HDP fsids start at units.Ki (1024)
                     hdp_list.append(inf[11])
                 else:
                     # HDP pools are 2-digits max
@@ -434,7 +434,7 @@ class HDSISCSIDriver(driver.ISCSIDriver):
                                   self.config['username'],
                                   self.config['password'],
                                   hdp,
-                                  '%s' % (int(volume['size']) * units.KiB),
+                                  '%s' % (int(volume['size']) * units.Ki),
                                   volume['name'])
 
         LOG.info(_("create_volume: create_lu returns %s") % out)
@@ -458,7 +458,7 @@ class HDSISCSIDriver(driver.ISCSIDriver):
             raise exception.VolumeBackendAPIException(data=msg)
         service = self._get_service(dst)
         (_ip, _ipp, _ctl, _port, hdp, target, secret) = service
-        size = int(src['size']) * units.KiB
+        size = int(src['size']) * units.Ki
         source_vol = self._id_to_vol(src['id'])
         (arid, slun) = _loc_info(source_vol['provider_location'])['id_lu']
         out = self.bend.create_dup(self.config['hnas_cmd'],
@@ -491,7 +491,7 @@ class HDSISCSIDriver(driver.ISCSIDriver):
                              self.config['username'],
                              self.config['password'],
                              hdp, lun,
-                             '%s' % (new_size * units.KiB),
+                             '%s' % (new_size * units.Ki),
                              volume['name'])
 
         LOG.info(_("LUN %(lun)s extended to %(size)s GB.")
@@ -615,7 +615,7 @@ class HDSISCSIDriver(driver.ISCSIDriver):
         :param snapshot: dictionary snapshot reference
         """
 
-        size = int(snapshot['volume_size']) * units.KiB
+        size = int(snapshot['volume_size']) * units.Ki
         (arid, slun) = _loc_info(snapshot['provider_location'])['id_lu']
         service = self._get_service(volume)
         (_ip, _ipp, _ctl, _port, hdp, target, secret) = service
@@ -640,7 +640,7 @@ class HDSISCSIDriver(driver.ISCSIDriver):
         source_vol = self._id_to_vol(snapshot['volume_id'])
         service = self._get_service(source_vol)
         (_ip, _ipp, _ctl, _port, hdp, target, secret) = service
-        size = int(snapshot['volume_size']) * units.KiB
+        size = int(snapshot['volume_size']) * units.Ki
         (arid, slun) = _loc_info(source_vol['provider_location'])['id_lu']
         out = self.bend.create_dup(self.config['hnas_cmd'],
                                    self.config['mgmt_ip0'],
index c16b88520801e52ad4f7ac623eac0788e2ec02c9..4002d35694ae77d823d56e96dee7ebff29afbc64 100644 (file)
@@ -28,7 +28,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume.drivers.hds.hnas_backend import HnasBackend
 from cinder.volume.drivers import nfs
 
@@ -226,7 +226,7 @@ class HDSNFSDriver(nfs.NfsDriver):
         """Checks if file size at path is equal to size."""
 
         data = image_utils.qemu_img_info(path)
-        virt_size = data.virtual_size / units.GiB
+        virt_size = data.virtual_size / units.Gi
 
         if virt_size == size:
             return True
index 49085506787800924208a66f665b9c616dd95500..32949bbb4a65cec6e5b8cf27f8531111ee6f24ef 100644 (file)
@@ -28,7 +28,7 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume.drivers.huawei import huawei_utils
 from cinder.volume import volume_types
@@ -220,9 +220,9 @@ class HVSCommon():
         calculates volume size with sectors, which is 512 bytes.
         """
 
-        volume_size = units.GiB / 512  # 1G
+        volume_size = units.Gi / 512  # 1G
         if int(volume['size']) != 0:
-            volume_size = int(volume['size']) * units.GiB / 512
+            volume_size = int(volume['size']) * units.Gi / 512
 
         return volume_size
 
@@ -1290,7 +1290,7 @@ class HVSCommon():
         lun_id = self._get_volume_by_name(name)
         if lun_id:
             url = self.url + "/lun/expand"
-            capacity = int(new_size) * units.GiB / 512
+            capacity = int(new_size) * units.Gi / 512
             data = json.dumps({"TYPE": "11",
                                "ID": lun_id,
                                "CAPACITY": capacity})
index 7f4a60bd7fedfb7277e7a1ea761a0c7e7a494f5d..b8c625976c3567259b941a84698f7b83856a5a35 100644 (file)
@@ -28,7 +28,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume import driver
 
@@ -432,7 +432,7 @@ class GPFSDriver(driver.VolumeDriver):
         """Preallocate file blocks by writing zeros."""
 
         block_size_mb = 1
-        block_count = size * units.GiB / (block_size_mb * units.MiB)
+        block_count = size * units.Gi / (block_size_mb * units.Mi)
 
         self._execute('dd', 'if=/dev/zero', 'of=%s' % path,
                       'bs=%dM' % block_size_mb,
@@ -514,7 +514,7 @@ class GPFSDriver(driver.VolumeDriver):
         self._set_rw_permission(volume_path)
         self._gpfs_redirect(volume_path)
         virt_size = self._resize_volume_file(volume, volume['size'])
-        return {'size': math.ceil(virt_size / units.GiB)}
+        return {'size': math.ceil(virt_size / units.Gi)}
 
     def create_cloned_volume(self, volume, src_vref):
         """Create a GPFS volume from another volume."""
@@ -524,7 +524,7 @@ class GPFSDriver(driver.VolumeDriver):
         self._create_gpfs_clone(src, dest)
         self._set_rw_permission(dest)
         virt_size = self._resize_volume_file(volume, volume['size'])
-        return {'size': math.ceil(virt_size / units.GiB)}
+        return {'size': math.ceil(virt_size / units.Gi)}
 
     def _delete_gpfs_file(self, fchild):
         """Delete a GPFS file and cleanup clone children."""
@@ -688,8 +688,8 @@ class GPFSDriver(driver.VolumeDriver):
         data["storage_protocol"] = 'file'
         free, capacity = self._get_available_capacity(self.configuration.
                                                       gpfs_mount_point_base)
-        data['total_capacity_gb'] = math.ceil(capacity / units.GiB)
-        data['free_capacity_gb'] = math.ceil(free / units.GiB)
+        data['total_capacity_gb'] = math.ceil(capacity / units.Gi)
+        data['free_capacity_gb'] = math.ceil(free / units.Gi)
         data['reserved_percentage'] = 0
         data['QoS_support'] = False
         data['storage_pool'] = self._storage_pool
index b9e9ad38cefba3d7b4a61af43409a52f8fb8769b..56f71c96954b21bf32096a99e309c853c94f90c4 100644 (file)
@@ -36,7 +36,7 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume.drivers import nfs
 from cinder.volume.drivers.nfs import nas_opts
@@ -126,8 +126,8 @@ class IBMNAS_NFSDriver(nfs.NfsDriver, san.SanDriver):
             global_capacity += capacity
             global_free += free
 
-        data['total_capacity_gb'] = global_capacity / float(units.GiB)
-        data['free_capacity_gb'] = global_free / float(units.GiB)
+        data['total_capacity_gb'] = global_capacity / float(units.Gi)
+        data['free_capacity_gb'] = global_free / float(units.Gi)
         data['reserved_percentage'] = 0
         data['QoS_support'] = False
         self._stats = data
index 0c9c9119bb991ca2d23e9572cd218360165cd8ee..def370117607093bcc6577d99357ac5e9bf59088 100644 (file)
@@ -42,7 +42,7 @@ from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import loopingcall
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume.drivers.ibm.storwize_svc import helpers as storwize_helpers
 from cinder.volume.drivers.san import san
@@ -853,7 +853,7 @@ class StorwizeSVCDriver(san.SanDriver):
             raise exception.ManageExistingInvalidReference(existing_ref=ref,
                                                            reason=reason)
 
-        return int(math.ceil(float(vdisk['capacity']) / units.GiB))
+        return int(math.ceil(float(vdisk['capacity']) / units.Gi))
 
     def get_volume_stats(self, refresh=False):
         """Get volume stats.
@@ -895,9 +895,9 @@ class StorwizeSVCDriver(san.SanDriver):
             raise exception.VolumeBackendAPIException(data=exception_message)
 
         data['total_capacity_gb'] = (float(attributes['capacity']) /
-                                     units.GiB)
+                                     units.Gi)
         data['free_capacity_gb'] = (float(attributes['free_capacity']) /
-                                    units.GiB)
+                                    units.Gi)
         data['easytier_support'] = attributes['easy_tier'] in ['on', 'auto']
         data['compression_support'] = self._state['compression_enabled']
         data['location_info'] = ('StorwizeSVCDriver:%(sys_id)s:%(pool)s' %
index 7e5018bd69b0724cd4c155ac45af449f3018cb7e..e3f539c10820ce2e564c40d276ed3d6343b0a7f6 100644 (file)
@@ -31,7 +31,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume import driver
 from cinder.volume import utils as volutils
@@ -163,7 +163,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
 
         # clear_volume expects sizes in MiB, we store integer GiB
         # be sure to convert before passing in
-        vol_sz_in_meg = size_in_g * units.KiB
+        vol_sz_in_meg = size_in_g * units.Ki
 
         volutils.clear_volume(
             vol_sz_in_meg, dev_path,
@@ -210,7 +210,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
         # be sure to convert before passing in
         volutils.copy_volume(self.local_path(snapshot),
                              self.local_path(volume),
-                             snapshot['volume_size'] * units.KiB,
+                             snapshot['volume_size'] * units.Ki,
                              self.configuration.volume_dd_blocksize,
                              execute=self._execute)
 
@@ -304,7 +304,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
             volutils.copy_volume(
                 self.local_path(temp_snapshot),
                 self.local_path(volume),
-                src_vref['size'] * units.KiB,
+                src_vref['size'] * units.Ki,
                 self.configuration.volume_dd_blocksize,
                 execute=self._execute)
         finally:
index e0a9c41d5c45d3ca72f01a3e0785e6f5c1a519f2..3f9621ae9a29df2f82c6d52990064d6f95341ca2 100644 (file)
@@ -25,7 +25,7 @@ from oslo.config import cfg
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils as cinder_utils
 from cinder.volume import driver
 from cinder.volume.drivers.netapp.eseries import client
@@ -306,7 +306,7 @@ class Driver(driver.ISCSIDriver):
 
     def _get_sorted_avl_storage_pools(self, size_gb):
         """Returns storage pools sorted on available capacity."""
-        size = size_gb * units.GiB
+        size = size_gb * units.Gi
         pools = self._client.list_storage_pools()
         sorted_pools = sorted(pools, key=lambda x:
                               (int(x.get('totalRaidedSpace', 0))
@@ -350,7 +350,7 @@ class Driver(driver.ISCSIDriver):
         LOG.debug("Creating snap vol for group %s", group['label'])
         image = self._get_cached_snap_grp_image(snapshot_id)
         label = utils.convert_uuid_to_es_fmt(uuid.uuid4())
-        capacity = int(image['pitCapacity']) / units.GiB
+        capacity = int(image['pitCapacity']) / units.Gi
         storage_pools = self._get_sorted_avl_storage_pools(capacity)
         s_id = storage_pools[0]['volumeGroupRef']
         return self._client.create_snapshot_volume(image['pitRef'], label,
@@ -423,7 +423,7 @@ class Driver(driver.ISCSIDriver):
         snap_grp, snap_image = None, None
         snapshot_name = utils.convert_uuid_to_es_fmt(snapshot['id'])
         vol = self._get_volume(snapshot['volume_id'])
-        vol_size_gb = int(vol['totalSizeInBytes']) / units.GiB
+        vol_size_gb = int(vol['totalSizeInBytes']) / units.Gi
         pools = self._get_sorted_avl_storage_pools(vol_size_gb)
         try:
             snap_grp = self._client.create_snapshot_group(
@@ -646,8 +646,8 @@ class Driver(driver.ISCSIDriver):
             if pool['volumeGroupRef'] in self._objects['disk_pool_refs']:
                 tot_bytes = tot_bytes + int(pool.get('totalRaidedSpace', 0))
                 used_bytes = used_bytes + int(pool.get('usedSpace', 0))
-        self._stats['free_capacity_gb'] = (tot_bytes - used_bytes) / units.GiB
-        self._stats['total_capacity_gb'] = tot_bytes / units.GiB
+        self._stats['free_capacity_gb'] = (tot_bytes - used_bytes) / units.Gi
+        self._stats['total_capacity_gb'] = tot_bytes / units.Gi
 
     def extend_volume(self, volume, new_size):
         """Extend an existing volume to the new size."""
index 67d77fe45ac6520425750118c9c4f9203ee1f5b6..2011fe171d0401f230aa9e419f6953da2995cb71 100644 (file)
@@ -30,7 +30,7 @@ from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume import driver
 from cinder.volume.drivers.netapp.api import NaApiError
@@ -577,7 +577,7 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
         name = volume['name']
         path = self.lun_table[name].metadata['Path']
         curr_size_bytes = str(self.lun_table[name].size)
-        new_size_bytes = str(int(new_size) * units.GiB)
+        new_size_bytes = str(int(new_size) * units.Gi)
         # Reused by clone scenarios.
         # Hence comparing the stored size.
         if curr_size_bytes != new_size_bytes:
@@ -1103,9 +1103,9 @@ class NetAppDirectCmodeISCSIDriver(NetAppDirectISCSIDriver):
             if self.ssc_vols['all']:
                 vol_max = max(self.ssc_vols['all'])
                 data['total_capacity_gb'] =\
-                    int(vol_max.space['size_total_bytes']) / units.GiB
+                    int(vol_max.space['size_total_bytes']) / units.Gi
                 data['free_capacity_gb'] =\
-                    int(vol_max.space['size_avl_bytes']) / units.GiB
+                    int(vol_max.space['size_avl_bytes']) / units.Gi
             else:
                 data['total_capacity_gb'] = 0
                 data['free_capacity_gb'] = 0
@@ -1539,8 +1539,8 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
                 avl_size = vol.get_child_content('size-available')
                 if avl_size:
                     free_bytes = free_bytes + int(avl_size)
-        self.total_gb = total_bytes / units.GiB
-        self.free_gb = free_bytes / units.GiB
+        self.total_gb = total_bytes / units.Gi
+        self.free_gb = free_bytes / units.Gi
 
     def delete_volume(self, volume):
         """Driver entry point for destroying existing volumes."""
index 63ded6e791e6fddbd29453805b95ffc379758e95..41622a370c9ba944abd74d6ab83716b5907d438b 100644 (file)
@@ -30,7 +30,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume.drivers.netapp.api import NaApiError
 from cinder.volume.drivers.netapp.api import NaElement
@@ -493,7 +493,7 @@ class NetAppNFSDriver(nfs.NfsDriver):
     def _is_file_size_equal(self, path, size):
         """Checks if file size at path is equal to size."""
         data = image_utils.qemu_img_info(path)
-        virt_size = data.virtual_size / units.GiB
+        virt_size = data.virtual_size / units.Gi
         if virt_size == size:
             return True
         else:
@@ -969,9 +969,9 @@ class NetAppDirectCmodeNfsDriver (NetAppDirectNfsDriver):
             if self.ssc_vols['all']:
                 vol_max = max(self.ssc_vols['all'])
                 data['total_capacity_gb'] =\
-                    int(vol_max.space['size_total_bytes']) / units.GiB
+                    int(vol_max.space['size_total_bytes']) / units.Gi
                 data['free_capacity_gb'] =\
-                    int(vol_max.space['size_avl_bytes']) / units.GiB
+                    int(vol_max.space['size_avl_bytes']) / units.Gi
             else:
                 data['total_capacity_gb'] = 0
                 data['free_capacity_gb'] = 0
index 3bf70468569fb74957d1b3bf681c497aa347bf62..2d2f1bbc3bf7554d21d3251ef425cb6376e79c58 100644 (file)
@@ -29,7 +29,7 @@ from cinder import context
 from cinder import db
 from cinder import exception
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume.drivers import nexenta
 from cinder.volume.drivers.nexenta import jsonrpc
 from cinder.volume.drivers.nexenta import options
@@ -294,7 +294,7 @@ class NexentaNfsDriver(nfs.NfsDriver):  # pylint: disable=R0921
         :param size: size of file
         """
         block_size_mb = 1
-        block_count = size * units.GiB / (block_size_mb * units.MiB)
+        block_count = size * units.Gi / (block_size_mb * units.Mi)
 
         LOG.info(_('Creating regular file: %s.'
                    'This may take some time.') % path)
index 42ebe1bee0734093557ad50b50aeb96b1672519c..6b371af3fe6fff23105f5ca06f982b8faa11d7d4 100644 (file)
@@ -25,7 +25,7 @@ import re
 
 import six.moves.urllib.parse as urlparse
 
-from cinder import units
+from cinder.openstack.common import units
 
 
 def str2size(s, scale=1024):
@@ -59,7 +59,7 @@ def str2size(s, scale=1024):
 def str2gib_size(s):
     """Covert size-string to size in gigabytes."""
     size_in_bytes = str2size(s)
-    return size_in_bytes / units.GiB
+    return size_in_bytes / units.Gi
 
 
 def get_rrmgr_cmd(src, dst, compression=None, tcp_buf_size=None,
index 7b59615040c83695fa67486a6b884c1cc239d36f..14992a129eab91096e08dd7a22f65fae4fc384a7 100644 (file)
@@ -24,7 +24,7 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils as putils
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume import driver
 
@@ -229,7 +229,7 @@ class RemoteFsDriver(driver.VolumeDriver):
         """
 
         block_size_mb = 1
-        block_count = size * units.GiB / (block_size_mb * units.MiB)
+        block_count = size * units.Gi / (block_size_mb * units.Mi)
 
         self._execute('dd', 'if=/dev/zero', 'of=%s' % path,
                       'bs=%dM' % block_size_mb,
@@ -241,7 +241,7 @@ class RemoteFsDriver(driver.VolumeDriver):
 
         self._execute('qemu-img', 'create', '-f', 'qcow2',
                       '-o', 'preallocation=metadata',
-                      path, str(size_gb * units.GiB),
+                      path, str(size_gb * units.Gi),
                       run_as_root=True)
 
     def _set_rw_permissions_for_all(self, path):
@@ -275,7 +275,7 @@ class RemoteFsDriver(driver.VolumeDriver):
         image_utils.resize_image(self.local_path(volume), volume['size'])
 
         data = image_utils.qemu_img_info(self.local_path(volume))
-        virt_size = data.virtual_size / units.GiB
+        virt_size = data.virtual_size / units.Gi
         if virt_size != volume['size']:
             raise exception.ImageUnacceptable(
                 image_id=image_id,
@@ -360,8 +360,8 @@ class RemoteFsDriver(driver.VolumeDriver):
             global_capacity += capacity
             global_free += free
 
-        data['total_capacity_gb'] = global_capacity / float(units.GiB)
-        data['free_capacity_gb'] = global_free / float(units.GiB)
+        data['total_capacity_gb'] = global_capacity / float(units.Gi)
+        data['free_capacity_gb'] = global_free / float(units.Gi)
         data['reserved_percentage'] = 0
         data['QoS_support'] = False
         self._stats = data
@@ -521,7 +521,7 @@ class NfsDriver(RemoteFsDriver):
 
         used_ratio = self.configuration.nfs_used_ratio
         oversub_ratio = self.configuration.nfs_oversub_ratio
-        requested_volume_size = volume_size_in_gib * units.GiB
+        requested_volume_size = volume_size_in_gib * units.Gi
 
         total_size, total_available, total_allocated = \
             self._get_capacity_info(nfs_share)
@@ -590,5 +590,5 @@ class NfsDriver(RemoteFsDriver):
     def _is_file_size_equal(self, path, size):
         """Checks if file size at path is equal to size."""
         data = image_utils.qemu_img_info(path)
-        virt_size = data.virtual_size / units.GiB
+        virt_size = data.virtual_size / units.Gi
         return virt_size == size
index ea2bd9387738b6f157cf11cfa07cbc3ba32ad592..3ab6be12e5b19fcb9083b9a0d976d7e6360e4910 100644 (file)
@@ -28,7 +28,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import strutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import driver
 
 try:
@@ -346,8 +346,8 @@ class RBDDriver(driver.VolumeDriver):
         try:
             with RADOSClient(self) as client:
                 new_stats = client.cluster.get_cluster_stats()
-            stats['total_capacity_gb'] = new_stats['kb'] / units.MiB
-            stats['free_capacity_gb'] = new_stats['kb_avail'] / units.MiB
+            stats['total_capacity_gb'] = new_stats['kb'] / units.Mi
+            stats['free_capacity_gb'] = new_stats['kb_avail'] / units.Mi
         except self.rados.Error:
             # just log and return unknown capacities
             LOG.exception(_('error refreshing volume stats'))
@@ -468,15 +468,15 @@ class RBDDriver(driver.VolumeDriver):
     def create_volume(self, volume):
         """Creates a logical volume."""
         if int(volume['size']) == 0:
-            size = 100 * units.MiB
+            size = 100 * units.Mi
         else:
-            size = int(volume['size']) * units.GiB
+            size = int(volume['size']) * units.Gi
 
         LOG.debug("creating volume '%s'" % (volume['name']))
 
         old_format = True
         features = 0
-        chunk_size = CONF.rbd_store_chunk_size * units.MiB
+        chunk_size = CONF.rbd_store_chunk_size * units.Mi
         order = int(math.log(chunk_size, 2))
         if self._supports_layering():
             old_format = False
@@ -512,7 +512,7 @@ class RBDDriver(driver.VolumeDriver):
     def _resize(self, volume, **kwargs):
         size = kwargs.get('size', None)
         if not size:
-            size = int(volume['size']) * units.GiB
+            size = int(volume['size']) * units.Gi
 
         with RBDVolumeProxy(self, volume['name']) as vol:
             vol.resize(size)
@@ -786,7 +786,7 @@ class RBDDriver(driver.VolumeDriver):
 
             self.delete_volume(volume)
 
-            chunk_size = CONF.rbd_store_chunk_size * units.MiB
+            chunk_size = CONF.rbd_store_chunk_size * units.Mi
             order = int(math.log(chunk_size, 2))
             # keep using the command line import instead of librbd since it
             # detects zeroes to preserve sparseness in the image
@@ -848,7 +848,7 @@ class RBDDriver(driver.VolumeDriver):
         old_size = volume['size']
 
         try:
-            size = int(new_size) * units.GiB
+            size = int(new_size) * units.Gi
             self._resize(volume, size=size)
         except Exception:
             msg = _('Failed to Extend Volume '
index e6a0d40acfd6469ca1cbb1e05453c19b4bc65499..4c06fad38bef7f5589aeecd17244e9b2b64e430d 100644 (file)
@@ -54,7 +54,7 @@ from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import loopingcall
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import qos_specs
 from cinder.volume import volume_types
 
@@ -264,7 +264,7 @@ class HP3PARCommon(object):
                   " by %(diff)s GB." %
                   {'vol': volume_name, 'old': old_size, 'new': new_size,
                    'diff': growth_size})
-        growth_size_mib = growth_size * units.KiB
+        growth_size_mib = growth_size * units.Ki
         self._extend_volume(volume, volume_name, growth_size_mib)
 
     def _extend_volume(self, volume, volume_name, growth_size_mib,
@@ -637,13 +637,13 @@ class HP3PARCommon(object):
             if min_io is None:
                 qosRule['ioMinGoal'] = int(max_io)
         if min_bw:
-            qosRule['bwMinGoalKB'] = int(min_bw) * units.KiB
+            qosRule['bwMinGoalKB'] = int(min_bw) * units.Ki
             if max_bw is None:
-                qosRule['bwMaxLimitKB'] = int(min_bw) * units.KiB
+                qosRule['bwMaxLimitKB'] = int(min_bw) * units.Ki
         if max_bw:
-            qosRule['bwMaxLimitKB'] = int(max_bw) * units.KiB
+            qosRule['bwMaxLimitKB'] = int(max_bw) * units.Ki
             if min_bw is None:
-                qosRule['bwMinGoalKB'] = int(max_bw) * units.KiB
+                qosRule['bwMinGoalKB'] = int(max_bw) * units.Ki
         if latency:
             qosRule['latencyGoal'] = int(latency)
         if priority:
@@ -1002,7 +1002,7 @@ class HP3PARCommon(object):
                     LOG.debug('Converting to base volume type: %s.' %
                               volume['id'])
                     self._convert_to_base_volume(volume)
-                    growth_size_mib = growth_size * units.GiB / units.MiB
+                    growth_size_mib = growth_size * units.Gi / units.Mi
                     LOG.debug('Growing volume: %(id)s by %(size)s GiB.' %
                               {'id': volume['id'], 'size': growth_size})
                     self.client.growVolume(volume_name, growth_size_mib)
index 7049f0c7184e5225d39a3cb9d630fd0d4978e841..22fe2170b1efa5a82b39d89ce33514b9b485d993 100644 (file)
@@ -25,7 +25,7 @@ from lxml import etree
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume.drivers.san.san import SanISCSIDriver
 
 
@@ -438,7 +438,7 @@ class HPLeftHandCLIQProxy(SanISCSIDriver):
         cluster_node = result_xml.find("response/cluster")
         total_capacity = cluster_node.attrib.get("spaceTotal")
         free_capacity = cluster_node.attrib.get("unprovisionedSpace")
-        GB = units.GiB
+        GB = units.Gi
 
         data['total_capacity_gb'] = int(total_capacity) / GB
         data['free_capacity_gb'] = int(free_capacity) / GB
index 8dbdaf9686420236ec44c3d6ed2ac63b7dbf74e8..1203b4b4450c56f60baea049aa8b890288811d6f 100644 (file)
@@ -18,7 +18,7 @@
 from cinder import context
 from cinder import exception
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder import utils
 from cinder.volume.driver import ISCSIDriver
 from cinder.volume import volume_types
@@ -168,7 +168,7 @@ class HPLeftHandRESTProxy(ISCSIDriver):
 
             volume_info = self.client.createVolume(
                 volume['name'], self.cluster_id,
-                volume['size'] * units.GiB,
+                volume['size'] * units.Gi,
                 optional)
 
             return self._update_provider(volume_info)
@@ -191,7 +191,7 @@ class HPLeftHandRESTProxy(ISCSIDriver):
             volume_info = self.client.getVolumeByName(volume['name'])
 
             # convert GB to bytes
-            options = {'size': int(new_size) * units.GiB}
+            options = {'size': int(new_size) * units.Gi}
             self.client.modifyVolume(volume_info['id'], options)
         except Exception as ex:
             raise exception.VolumeBackendAPIException(ex)
@@ -249,8 +249,8 @@ class HPLeftHandRESTProxy(ISCSIDriver):
         free_capacity = cluster_info['spaceAvailable']
 
         # convert to GB
-        data['total_capacity_gb'] = int(total_capacity) / units.GiB
-        data['free_capacity_gb'] = int(free_capacity) / units.GiB
+        data['total_capacity_gb'] = int(total_capacity) / units.Gi
+        data['free_capacity_gb'] = int(free_capacity) / units.Gi
 
         self.device_stats = data
 
index 4343654f72cc624a3f6211b0b4577c962a4e13cf..cb9597e265a409365392afe869c7b0e8f6fc50f0 100644 (file)
@@ -27,7 +27,7 @@ import six.moves.urllib.parse as urlparse
 from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import driver
 
 
@@ -108,8 +108,8 @@ class ScalityDriver(driver.VolumeDriver):
 
     def _size_bytes(self, size_in_g):
         if int(size_in_g) == 0:
-            return 100 * units.MiB
-        return int(size_in_g) * units.GiB
+            return 100 * units.Mi
+        return int(size_in_g) * units.Gi
 
     def _create_file(self, path, size):
         with open(path, "ab") as f:
index 170995c96be2f245e245a74180e13ed32fe9a3e9..6b647af7889919386fb9e95c31d93b962e84dac7 100644 (file)
@@ -28,7 +28,7 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import driver
 
 
@@ -90,7 +90,7 @@ class SheepdogDriver(driver.VolumeDriver):
 
     def _resize(self, volume, size=None):
         if not size:
-            size = int(volume['size']) * units.GiB
+            size = int(volume['size']) * units.Gi
 
         self._try_execute('collie', 'vdi', 'resize',
                           volume['name'], size)
@@ -172,8 +172,8 @@ class SheepdogDriver(driver.VolumeDriver):
             m = self.stats_pattern.match(stdout)
             total = float(m.group(1))
             used = float(m.group(2))
-            stats['total_capacity_gb'] = total / units.GiB
-            stats['free_capacity_gb'] = (total - used) / units.GiB
+            stats['total_capacity_gb'] = total / units.Gi
+            stats['free_capacity_gb'] = (total - used) / units.Gi
         except processutils.ProcessExecutionError:
             LOG.exception(_('error refreshing volume stats'))
 
@@ -189,7 +189,7 @@ class SheepdogDriver(driver.VolumeDriver):
         old_size = volume['size']
 
         try:
-            size = int(new_size) * units.GiB
+            size = int(new_size) * units.Gi
             self._resize(volume, size=size)
         except Exception:
             msg = _('Failed to Extend Volume '
index 782c62801a2475f0ef65f8b4c03ffd8ce2d61385..123ae9f53657d90c1a76f97fbee031da30cbf32b 100644 (file)
@@ -28,7 +28,7 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume.drivers.san.san import SanISCSIDriver
 from cinder.volume import qos_specs
 from cinder.volume import volume_types
@@ -356,7 +356,7 @@ class SolidFireDriver(SanISCSIDriver):
 
         params = {'volumeID': int(sf_vol['volumeID']),
                   'name': 'UUID-%s' % v_ref['id'],
-                  'newSize': int(new_size * units.GiB),
+                  'newSize': int(new_size * units.Gi),
                   'newAccountID': sfaccount['accountID']}
         data = self._issue_api_request('CloneVolume', params)
 
@@ -521,7 +521,7 @@ class SolidFireDriver(SanISCSIDriver):
         params = {'name': 'UUID-%s' % volume['id'],
                   'accountID': None,
                   'sliceCount': slice_count,
-                  'totalSize': int(volume['size'] * units.GiB),
+                  'totalSize': int(volume['size'] * units.Gi),
                   'enable512e': self.configuration.sf_emulate_512,
                   'attributes': attributes,
                   'qos': qos}
@@ -647,7 +647,7 @@ class SolidFireDriver(SanISCSIDriver):
 
         params = {
             'volumeID': sf_vol['volumeID'],
-            'totalSize': int(new_size * units.GiB)
+            'totalSize': int(new_size * units.Gi)
         }
         data = self._issue_api_request('ModifyVolume',
                                        params, version='5.0')
@@ -682,9 +682,9 @@ class SolidFireDriver(SanISCSIDriver):
         data["storage_protocol"] = 'iSCSI'
 
         data['total_capacity_gb'] =\
-            float(results['maxProvisionedSpace'] / units.GiB)
+            float(results['maxProvisionedSpace'] / units.Gi)
 
-        data['free_capacity_gb'] = float(free_capacity / units.GiB)
+        data['free_capacity_gb'] = float(free_capacity / units.Gi)
         data['reserved_percentage'] = self.configuration.reserved_percentage
         data['QoS_support'] = True
         data['compression_percent'] =\
index 1e0cd1a0392b917c18f321896dfff83e4ff98b72..cc1cc315124cbe60b93eebecfd47798784f10412 100644 (file)
@@ -30,7 +30,7 @@ from oslo.config import cfg
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume import driver
 from cinder.volume.drivers.vmware import api
 from cinder.volume.drivers.vmware import error_util
@@ -408,7 +408,7 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
                        "volume since policy based placement is "
                        "disabled."), storage_profile)
 
-        size_bytes = volume['size'] * units.GiB
+        size_bytes = volume['size'] * units.Gi
         datastore_summary = self._select_datastore_summary(size_bytes,
                                                            datastores)
         return (folder, datastore_summary)
@@ -440,7 +440,7 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
                                                         resource_pool,
                                                         datastores)
         disk_type = VMwareEsxVmdkDriver._get_disk_type(volume)
-        size_kb = volume['size'] * units.MiB
+        size_kb = volume['size'] * units.Mi
         storage_profile = self._get_storage_profile(volume)
         profileId = None
         if self._storage_policy_enabled and storage_profile:
@@ -814,7 +814,7 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
         "streamOptimized"
         """
         # Set volume size in GB from image metadata
-        volume['size'] = float(image_size) / units.GiB
+        volume['size'] = float(image_size) / units.Gi
         # First create empty backing in the inventory
         backing = self._create_backing_in_inventory(volume)
 
@@ -1000,7 +1000,7 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
         # image size. If the volume_size_in_gb is greater, meaning the
         # user specifies a larger volume, we need to extend/resize the vmdk
         # virtual disk to the capacity specified by the user.
-        if volume_size_in_gb * units.GiB > image_size_in_bytes:
+        if volume_size_in_gb * units.Gi > image_size_in_bytes:
             self._extend_vmdk_virtual_disk(volume['name'], volume_size_in_gb)
 
     def copy_volume_to_image(self, context, volume, image_service, image_meta):
@@ -1045,7 +1045,7 @@ class VMwareEsxVmdkDriver(driver.VolumeDriver):
                                    host=host_ip,
                                    vm=backing,
                                    vmdk_file_path=vmdk_file_path,
-                                   vmdk_size=volume['size'] * units.GiB,
+                                   vmdk_size=volume['size'] * units.Gi,
                                    image_name=image_meta['name'],
                                    image_version=1)
         LOG.info(_("Done copying volume %(vol)s to a new image %(img)s") %
index 96e10cb56c47c5c2e24b5c14f2f28290b737a4e0..94d34b39b9e806290f3329f1aafafbf5b7f9a95d 100644 (file)
@@ -18,7 +18,7 @@ Implements operations on volumes residing on VMware datastores.
 """
 
 from cinder.openstack.common import log as logging
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume.drivers.vmware import error_util
 from cinder.volume.drivers.vmware import vim_util
 
@@ -335,7 +335,7 @@ class VMwareVolumeOps(object):
 
         # VMWare API needs the capacity unit to be in KB, so convert the
         # capacity unit from GB to KB.
-        size_in_kb = requested_size_in_gb * units.MiB
+        size_in_kb = requested_size_in_gb * units.Mi
         task = self._session.invoke_api(self._session.vim,
                                         "ExtendVirtualDisk_Task",
                                         diskMgr,
index b5ea2fb84ed882dd409af50c1de5e78949653cbb..a827d5d842cffc07054fde3b816bcca6518ee090 100644 (file)
@@ -18,7 +18,7 @@ import contextlib
 import os
 import pickle
 
-from cinder import units
+from cinder.openstack.common import units
 from cinder.volume.drivers.xenapi import tools
 
 
@@ -258,7 +258,7 @@ class CompoundOperations(object):
 
 
 def to_bytes(size_in_gigs):
-    return size_in_gigs * units.GiB
+    return size_in_gigs * units.Gi
 
 
 class NFSOperationsMixIn(CompoundOperations):
index 8da6032300e190e41839e1a1023967c817b66f7f..b294d2d06d04b081c25cf2b805375643dd0e132d 100644 (file)
@@ -20,9 +20,9 @@ from cinder import exception
 from cinder import flow_utils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
+from cinder.openstack.common import units
 from cinder import policy
 from cinder import quota
-from cinder import units
 from cinder import utils
 from cinder.volume.flows import common
 from cinder.volume import volume_types
@@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
 
 ACTION = 'volume:create'
 CONF = cfg.CONF
-GB = units.GiB
+GB = units.Gi
 QUOTAS = quota.QUOTAS
 
 # Only in these 'sources' status can we attempt to create a volume from a
index 0ca7b68b577599590a13255ca73a6e8782bd3b12..1253db3a780d37e4ed419acfe071d7a4891ba5bd 100644 (file)
@@ -24,8 +24,8 @@ from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils
 from cinder.openstack.common import strutils
+from cinder.openstack.common import units
 from cinder import rpc
-from cinder import units
 from cinder import utils
 
 
@@ -123,7 +123,7 @@ def _calculate_count(size_in_m, blocksize):
         blocksize = CONF.volume_dd_blocksize
         bs = strutils.string_to_bytes('%sB' % blocksize)
 
-    count = math.ceil(size_in_m * units.MiB / bs)
+    count = math.ceil(size_in_m * units.Mi / bs)
 
     return blocksize, int(count)
 
index a82b3c3ce608e735691d2924c46aa864fc2af3d4..757557baed2815767925867ce9b230337815f192 100644 (file)
@@ -30,6 +30,7 @@ module=service
 module=sslutils
 module=strutils
 module=timeutils
+module=units
 module=uuidutils
 module=versionutils