Use module units for some drivers
Use module units instead of number for some drivers. Change-Id: I429590b6955f56d7ba9687b6898808a3f3bc3796
This commit is contained in:
parent
1094467f9b
commit
6b418fe7ee
|
@ -30,6 +30,7 @@ from xml.dom.minidom import parseString
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
|
from cinder import units
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ class EMCSMISCommon():
|
||||||
"""Creates a EMC(VMAX/VNX) volume."""
|
"""Creates a EMC(VMAX/VNX) volume."""
|
||||||
|
|
||||||
LOG.debug(_('Entering create_volume.'))
|
LOG.debug(_('Entering create_volume.'))
|
||||||
volumesize = int(volume['size']) * 1073741824
|
volumesize = int(volume['size']) * units.GiB
|
||||||
volumename = volume['name']
|
volumename = volume['name']
|
||||||
|
|
||||||
LOG.info(_('Create Volume: %(volume)s Size: %(size)lu')
|
LOG.info(_('Create Volume: %(volume)s Size: %(size)lu')
|
||||||
|
|
|
@ -30,6 +30,7 @@ from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
|
from cinder import units
|
||||||
from cinder.volume.drivers import nfs
|
from cinder.volume.drivers import nfs
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -991,7 +992,7 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
|
||||||
greatest_share = glusterfs_share
|
greatest_share = glusterfs_share
|
||||||
greatest_size = capacity
|
greatest_size = capacity
|
||||||
|
|
||||||
if volume_size_for * 1024 * 1024 * 1024 > greatest_size:
|
if volume_size_for * units.GiB > greatest_size:
|
||||||
raise exception.GlusterfsNoSuitableShareFound(
|
raise exception.GlusterfsNoSuitableShareFound(
|
||||||
volume_size=volume_size_for)
|
volume_size=volume_size_for)
|
||||||
return greatest_share
|
return greatest_share
|
||||||
|
|
|
@ -457,9 +457,9 @@ class RBDDriver(driver.VolumeDriver):
|
||||||
def create_volume(self, volume):
|
def create_volume(self, volume):
|
||||||
"""Creates a logical volume."""
|
"""Creates a logical volume."""
|
||||||
if int(volume['size']) == 0:
|
if int(volume['size']) == 0:
|
||||||
size = 100 * 1024 ** 2
|
size = 100 * units.MiB
|
||||||
else:
|
else:
|
||||||
size = int(volume['size']) * 1024 ** 3
|
size = int(volume['size']) * units.GiB
|
||||||
|
|
||||||
LOG.debug(_("creating volume '%s'") % (volume['name']))
|
LOG.debug(_("creating volume '%s'") % (volume['name']))
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ from oslo.config import cfg
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
from cinder.openstack.common import log as logging
|
from cinder.openstack.common import log as logging
|
||||||
|
from cinder import units
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,8 +108,8 @@ class ScalityDriver(driver.VolumeDriver):
|
||||||
|
|
||||||
def _size_bytes(self, size_in_g):
|
def _size_bytes(self, size_in_g):
|
||||||
if int(size_in_g) == 0:
|
if int(size_in_g) == 0:
|
||||||
return 100 * 1024 * 1024
|
return 100 * units.MiB
|
||||||
return int(size_in_g) * 1024 * 1024 * 1024
|
return int(size_in_g) * units.GiB
|
||||||
|
|
||||||
def _create_file(self, path, size):
|
def _create_file(self, path, size):
|
||||||
with open(path, "ab") as f:
|
with open(path, "ab") as f:
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from cinder.volume.drivers.xenapi import tools
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
from cinder import units
|
||||||
|
from cinder.volume.drivers.xenapi import tools
|
||||||
|
|
||||||
|
|
||||||
class XenAPIException(Exception):
|
class XenAPIException(Exception):
|
||||||
def __init__(self, original_exception):
|
def __init__(self, original_exception):
|
||||||
|
@ -258,7 +260,7 @@ class CompoundOperations(object):
|
||||||
|
|
||||||
|
|
||||||
def to_bytes(size_in_gigs):
|
def to_bytes(size_in_gigs):
|
||||||
return size_in_gigs * 1024 * 1024 * 1024
|
return size_in_gigs * units.GiB
|
||||||
|
|
||||||
|
|
||||||
class NFSOperationsMixIn(CompoundOperations):
|
class NFSOperationsMixIn(CompoundOperations):
|
||||||
|
|
Loading…
Reference in New Issue