]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove Brick's iscsi dependency on cinder
authorWalter A. Boring IV <walter.boring@hp.com>
Tue, 6 Aug 2013 23:22:24 +0000 (16:22 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Tue, 6 Aug 2013 23:22:24 +0000 (16:22 -0700)
This patch removes Brick's iscsi/iscsi.py's
dependence on cinder.  Brick can't contain
cinder dependencies as it will be used in nova.

Fixes Bug #1209012

Change-Id: I046b5a53baecce81ba184cb7f30ec450f4738dae

cinder/brick/iscsi/iscsi.py
cinder/tests/test_iscsi.py
cinder/volume/utils.py

index 0ac3ba272d8af3a7b8998b75094e4cfbbc41e259..118fe04e8bcaf9bcd8991ac3ac1f7629f1c20800 100644 (file)
@@ -23,6 +23,7 @@ Helper code for the iSCSI volume driver.
 import contextlib
 import os
 import re
+import stat
 
 from oslo.config import cfg
 
@@ -30,7 +31,6 @@ from cinder import exception
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils as putils
-from cinder.volume import utils as volume_utils
 
 
 LOG = logging.getLogger(__name__)
@@ -236,9 +236,13 @@ class IetAdm(TargetAdmin):
     def __init__(self, execute=putils.execute):
         super(IetAdm, self).__init__('ietadm', execute)
 
+    def _is_block(self, path):
+        mode = os.stat(path).st_mode
+        return stat.S_ISBLK(mode)
+
     def _iotype(self, path):
         if CONF.iscsi_iotype == 'auto':
-            return 'blockio' if volume_utils.is_block(path) else 'fileio'
+            return 'blockio' if self._is_block(path) else 'fileio'
         else:
             return CONF.iscsi_iotype
 
index 66a467767a4b2d8caa4cc3597b96a0d869f5b15f..d10354a725528fe0724825138827cfe52565841b 100644 (file)
@@ -165,7 +165,7 @@ class IetAdmAutoIOTestCase(test.TestCase, TargetAdminTestCase):
     def setUp(self):
         super(IetAdmAutoIOTestCase, self).setUp()
         TargetAdminTestCase.setUp(self)
-        self.stubs.Set(volume_utils, 'is_block', lambda _: True)
+        self.stubs.Set(iscsi.IetAdm, '_is_block', lambda a, b: True)
         self.flags(iscsi_helper='ietadm')
         self.flags(iscsi_iotype='auto')
         self.script_template = "\n".join([
index 5ace4c811d7d5e59305b4c0e2c1e155baa0de272..d29e7649114b0f0225b240818a667492391a7d1e 100644 (file)
@@ -142,11 +142,6 @@ def notify_about_snapshot_usage(context, snapshot, event_suffix,
                         notifier_api.INFO, usage_info)
 
 
-def is_block(path):
-    mode = os.stat(path).st_mode
-    return stat.S_ISBLK(mode)
-
-
 def _calculate_count(size_in_m):
     blocksize = CONF.volume_dd_blocksize
     # Check if volume_dd_blocksize is valid