]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix pep8 and pylint violation in Nexenta volume driver
authorVictor Rodionov <vito.ordaz@gmail.com>
Thu, 1 Aug 2013 13:30:54 +0000 (17:30 +0400)
committerVictor Rodionov <vito.ordaz@gmail.com>
Fri, 2 Aug 2013 00:53:12 +0000 (04:53 +0400)
Change-Id: Iec7f37ddd0f3850cb84e1cafe223b8f503a3629c

.gitignore
.mailmap
cinder/volume/drivers/nexenta/volume.py

index 2ee553b912b1ebdb1d70337eb7b7787b34282265..c83306c74ff8c0db9e6cc07e65bb3d31bbb367a6 100644 (file)
@@ -9,6 +9,7 @@
 .testrepository
 .tox
 .venv
+.idea
 AUTHORS
 Authors
 build/*
@@ -29,4 +30,4 @@ tools/pylint_exceptions
 tags
 # Files created by Sphinx build
 doc/build
-.autogenerated
\ No newline at end of file
+.autogenerated
index 408a670b5e4eedc95e7153d767ce8a1ba5d4afdd..d447c4ca4220492ea1038ec6632f271d3bab5220 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -79,3 +79,4 @@
 <nsokolov@griddynamics.com> <nsokolov@griddynamics.net>
 <troy.toman@rackspace.com> <ttcl@mac.com>
 <zulcss@ubuntu.com> <chuck.short@canonical.com>
+<victor.rodionov@nexenta.com> <vito.ordaz@gmail.com>
index d181361860992c018abd9182cebd0fa8a97a87bd..d5dc6bdfedb92142bb09c9f46f9e4ede78534e58 100644 (file)
@@ -26,6 +26,7 @@ from oslo.config import cfg
 
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder import units
 from cinder.volume import driver
 from cinder.volume.drivers import nexenta
 from cinder.volume.drivers.nexenta import jsonrpc
@@ -33,7 +34,7 @@ from cinder.volume.drivers.nexenta import jsonrpc
 VERSION = '1.0'
 LOG = logging.getLogger(__name__)
 
-nexenta_opts = [
+NEXENTA_OPTS = [
     cfg.StrOpt('nexenta_host',
                default='',
                help='IP address of Nexenta SA'),
@@ -71,7 +72,7 @@ nexenta_opts = [
 ]
 
 CONF = cfg.CONF
-CONF.register_opts(nexenta_opts)
+CONF.register_opts(NEXENTA_OPTS)
 
 
 class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
@@ -79,6 +80,9 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
 
     def __init__(self, *args, **kwargs):
         super(NexentaDriver, self).__init__(*args, **kwargs)
+        self.nms = None
+        if self.configuration:
+            self.configuration.append_config_values(NEXENTA_OPTS)
 
     def do_setup(self, context):
         protocol = CONF.nexenta_rest_protocol
@@ -300,9 +304,6 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
         # info he had regarding Nexenta Capabilities, ideally it would
         # be great if somebody from Nexenta looked this over at some point
 
-        KB = 1024
-        MB = KB ** 2
-
         LOG.debug(_("Updating volume stats"))
         data = {}
         backend_name = self.__class__.__name__
@@ -321,18 +322,18 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
         free_amount = float(stats['available'][:-1])
 
         if total_unit == "T":
-                total_amount = total_amount * KB
+            total_amount *= units.KiB
         elif total_unit == "M":
-                total_amount = total_amount / KB
+            total_amount /= units.KiB
         elif total_unit == "B":
-                total_amount = total_amount / MB
+            total_amount /= units.MiB
 
         if free_unit == "T":
-                free_amount = free_amount * KB
+            free_amount *= units.KiB
         elif free_unit == "M":
-                free_amount = free_amount / KB
+            free_amount /= units.KiB
         elif free_unit == "B":
-                free_amount = free_amount / MB
+            free_amount /= units.MiB
 
         data['total_capacity_gb'] = total_amount
         data['free_capacity_gb'] = free_amount