From 9cb2af6bc96c795fbe0929d68a802012a8267cf8 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Tue, 6 Aug 2013 16:22:24 -0700 Subject: [PATCH] Remove Brick's iscsi dependency on cinder 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 | 8 ++++++-- cinder/tests/test_iscsi.py | 2 +- cinder/volume/utils.py | 5 ----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cinder/brick/iscsi/iscsi.py b/cinder/brick/iscsi/iscsi.py index 0ac3ba272..118fe04e8 100644 --- a/cinder/brick/iscsi/iscsi.py +++ b/cinder/brick/iscsi/iscsi.py @@ -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 diff --git a/cinder/tests/test_iscsi.py b/cinder/tests/test_iscsi.py index 66a467767..d10354a72 100644 --- a/cinder/tests/test_iscsi.py +++ b/cinder/tests/test_iscsi.py @@ -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([ diff --git a/cinder/volume/utils.py b/cinder/volume/utils.py index 5ace4c811..d29e76491 100644 --- a/cinder/volume/utils.py +++ b/cinder/volume/utils.py @@ -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 -- 2.45.2