Enable import group hacking rule

This change enables H305, H307 included in newly updated hacking 0.9
all violations are fixed.

H305, H307 will check if imports are grouped in stdlib, 3rd libs and
OpenStack components.

Change-Id: I612cae64982450a9be5207dbe26a2b52da49dac6
This commit is contained in:
Zhiteng Huang 2014-06-27 18:32:01 +08:00
parent 39f32683ef
commit e0dae50dc8
95 changed files with 120 additions and 111 deletions
bin
cinder
api
backup
brick
local_dev
remotefs
db/sqlalchemy
exception.pytest.py
tests
utils.py
volume/drivers
tox.ini

@ -25,11 +25,10 @@ import warnings
warnings.simplefilter('once', DeprecationWarning)
import eventlet
from oslo.config import cfg
eventlet.monkey_patch()
from oslo.config import cfg
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),

@ -17,9 +17,10 @@
"""Starter script for Cinder Volume."""
import eventlet
import os
import eventlet
if os.name == 'nt':
# eventlet monkey patching the os module causes subprocess.Popen to fail
# on Windows when using pipes due to missing non-blocking IO support.

@ -54,7 +54,6 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
from cinder import i18n
i18n.enable_lazy()
from cinder import context
from cinder import db
from cinder.i18n import _

@ -15,10 +15,10 @@
"""The hosts admin extension."""
from xml.parsers import expat
from oslo.config import cfg
import webob.exc
from xml.parsers import expat
from cinder.api import extensions
from cinder.api.openstack import wsgi

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import webob
from oslo import messaging
import webob
from cinder.api import extensions
from cinder.api.openstack import wsgi

@ -21,7 +21,6 @@ from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.views import transfers as transfer_view
from cinder.api import xmlutil
from cinder import exception
from cinder.i18n import _
from cinder.openstack.common import log as logging

@ -17,12 +17,12 @@
import inspect
import math
import time
from xml.dom import minidom
from xml.parsers import expat
from lxml import etree
import six
import webob
from xml.dom import minidom
from xml.parsers import expat
from cinder import exception
from cinder import i18n

@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import paste.urlmap
import re
import urllib2
import paste.urlmap
from cinder.api.openstack import wsgi
from cinder.openstack.common import log as logging

@ -14,13 +14,13 @@
# under the License.
import webob
from webob import exc
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
from cinder.i18n import _
from cinder import volume
from webob import exc
class Controller(wsgi.Controller):

@ -14,13 +14,13 @@
# under the License.
import webob
from webob import exc
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
from cinder.i18n import _
from cinder import volume
from webob import exc
class Controller(wsgi.Controller):

@ -16,6 +16,7 @@
"""The volumes api."""
import ast
import webob
from webob import exc

@ -14,13 +14,13 @@
# under the License.
import webob
from webob import exc
from cinder.api import common
from cinder.api.openstack import wsgi
from cinder import exception
from cinder.i18n import _
from cinder import volume
from webob import exc
class Controller(wsgi.Controller):

@ -17,6 +17,7 @@
import ast
import webob
from webob import exc

@ -19,7 +19,6 @@ Handles all requests relating to the volume backups service.
from eventlet import greenthread
from oslo.config import cfg
from cinder.backup import rpcapi as backup_rpcapi
@ -28,9 +27,8 @@ from cinder.db import base
from cinder import exception
from cinder.i18n import _
from cinder.openstack.common import log as logging
from cinder import utils
import cinder.policy
from cinder import utils
import cinder.volume
CONF = cfg.CONF

@ -15,12 +15,13 @@
"""Base class for all backup drivers."""
from oslo.config import cfg
from cinder.db import base
from cinder import exception
from cinder.i18n import _
from cinder.openstack.common import jsonutils
from cinder.openstack.common import log as logging
from oslo.config import cfg
service_opts = [
cfg.IntOpt('backup_metadata_version', default=1,

@ -42,13 +42,13 @@ was deemed the safest action to take. It is therefore recommended to always
restore to a new volume (default).
"""
import eventlet
import fcntl
import os
import re
import subprocess
import time
import eventlet
from oslo.config import cfg
from cinder.backup.driver import BackupDriver

@ -33,11 +33,12 @@
import hashlib
import json
import os
import six
import socket
import eventlet
from oslo.config import cfg
import six
from swiftclient import client as swift
from cinder.backup.driver import BackupDriver
from cinder import exception
@ -46,7 +47,6 @@ from cinder.openstack.common import excutils
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import units
from swiftclient import client as swift
LOG = logging.getLogger(__name__)

@ -17,11 +17,10 @@
LVM class for performing LVM operations.
"""
import itertools
import math
import re
import itertools
from cinder.brick import exception
from cinder.brick import executor
from cinder.i18n import _

@ -18,6 +18,7 @@
import hashlib
import os
import re
import six
from cinder.brick import exception

@ -12,10 +12,11 @@
import uuid
from cinder.openstack.common import log as logging
from migrate import ForeignKeyConstraint
from sqlalchemy import Integer, MetaData, String, Table
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)

@ -11,10 +11,11 @@
# under the License.
from cinder.openstack.common import log as logging
from sqlalchemy import Column
from sqlalchemy import MetaData, String, Table
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)

@ -14,11 +14,12 @@
import datetime
from cinder.i18n import _
from cinder.openstack.common import log as logging
from oslo.config import cfg
from sqlalchemy import MetaData, Table
from cinder.i18n import _
from cinder.openstack.common import log as logging
# Get default values via config. The defaults will either
# come from the default values set in the quota option
# configuration or via cinder.conf if the user has configured

@ -19,13 +19,12 @@
SQLAlchemy models for cinder data.
"""
from oslo.config import cfg
from oslo.db.sqlalchemy import models
from sqlalchemy import Column, Integer, String, Text, schema
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import ForeignKey, DateTime, Boolean
from sqlalchemy.orm import relationship, backref
from oslo.config import cfg
from oslo.db.sqlalchemy import models
from cinder.openstack.common import timeutils

@ -22,10 +22,10 @@ SHOULD include dedicated exception logging.
"""
import six
import sys
from oslo.config import cfg
import six
import webob.exc
from cinder.i18n import _

@ -21,13 +21,13 @@ inline callbacks.
"""
import logging
import os
import shutil
import tempfile
import uuid
import fixtures
import logging
import mox
from oslo.config import cfg
from oslo.messaging import conffixture as messaging_conffixture

@ -12,9 +12,9 @@
import ast
import tempfile
import webob
from oslo.config import cfg
import webob
from cinder.api.contrib import admin_actions
from cinder.brick.local_dev import lvm as brick_lvm

@ -18,9 +18,9 @@ Tests for Backup code.
"""
import json
import mock
from xml.dom import minidom
import mock
import webob
# needed for stubs to work

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from lxml import etree
from xml.dom import minidom
from lxml import etree
import webob
from cinder.api.contrib import qos_specs_manage

@ -14,6 +14,8 @@
# under the License.
from datetime import datetime
import webob.exc
from cinder.api.contrib import services
@ -25,7 +27,6 @@ from cinder.openstack.common import timeutils
from cinder import policy
from cinder import test
from cinder.tests.api import fakes
from datetime import datetime
fake_services_list = [{'binary': 'cinder-scheduler',

@ -16,9 +16,8 @@
# under the License.
from lxml import etree
import webob
import mock
import webob
from cinder.api.contrib import types_extra_specs
from cinder import exception

@ -14,6 +14,7 @@
# under the License.
import json
import webob
from cinder.api.contrib import volume_encryption_metadata

@ -13,7 +13,6 @@
# under the License.
import mock
import webob
from cinder import context

@ -14,6 +14,7 @@
# under the License.
import json
import webob
from cinder import context

@ -13,7 +13,6 @@
# under the License.
import mock
import webob
from cinder import context

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import gettext
from xml.dom import minidom
import gettext
import mock
from oslo.i18n import _lazy
import webob.dec

@ -11,6 +11,7 @@
# under the License.
import inspect
import webob
from cinder.api.openstack import wsgi

@ -18,10 +18,10 @@ Tests dealing with HTTP rate-limiting.
"""
import httplib
import six
from xml.dom import minidom
from lxml import etree
import six
import webob
from cinder.api.v1 import limits

@ -18,11 +18,11 @@ Tests dealing with HTTP rate-limiting.
"""
import httplib
from xml.dom import minidom
from lxml import etree
import six
import webob
from xml.dom import minidom
from cinder.api.v2 import limits
from cinder.api import views

@ -19,9 +19,10 @@ import os
import socket
import zlib
from cinder.openstack.common import log as logging
from swiftclient import client as swift
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)

@ -15,9 +15,10 @@
#
"""Fake HP client for testing 3PAR without installing the client."""
import mock
import sys
import mock
from cinder.tests import fake_hp_client_exceptions as hpexceptions
hp3par = mock.Mock()

@ -15,9 +15,10 @@
#
"""Fake HP client for testing LeftHand without installing the client."""
import mock
import sys
import mock
from cinder.tests import fake_hp_client_exceptions as hpexceptions
hplefthand = mock.Mock()

@ -14,7 +14,6 @@
import netaddr
import requests
import six.moves.urllib.parse as urlparse
from cinder.i18n import _

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import testtools
import time
import testtools
from cinder.openstack.common import log as logging
from cinder import service
from cinder.tests import fake_driver

@ -17,7 +17,6 @@ Tests For Capacity Weigher.
"""
import mock
from oslo.config import cfg
from cinder import context

@ -17,7 +17,6 @@ Tests For HostManager
"""
import mock
from oslo.config import cfg
from cinder import exception

@ -18,8 +18,8 @@ Unit Tests for cinder.scheduler.rpcapi
"""
import copy
import mock
import mock
from oslo.config import cfg
from cinder import context

@ -17,7 +17,6 @@ Tests For Volume Number Weigher.
"""
import mock
from oslo.config import cfg
from cinder import context

@ -17,9 +17,9 @@ Tests for Backup code.
"""
import mock
import tempfile
import mock
from oslo.config import cfg
from cinder import context

@ -16,12 +16,13 @@
import contextlib
import hashlib
import mock
import os
import six
import tempfile
import uuid
import mock
import six
from cinder.backup import driver
from cinder.backup.drivers import ceph
from cinder import context

@ -14,9 +14,10 @@
# under the License.
""" Tests for the backup service base driver. """
import mock
import uuid
import mock
from cinder.backup import driver
from cinder import context
from cinder import db

@ -12,10 +12,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import re
import mock
from cinder import exception
from cinder.openstack.common import processutils
from cinder import test

@ -16,12 +16,12 @@
import contextlib
import errno
import mock
import os
import tempfile
import time
import traceback
import mock
import mox as mox_lib
from mox import IgnoreArg
from mox import IsA

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import tempfile
import mock
from oslo.config import cfg
from cinder import context

@ -19,10 +19,11 @@
Self test for Hitachi Unified Storage (HUS) platform.
"""
import mox
import os
import tempfile
import mox
from cinder import test
from cinder.volume import configuration as conf
from cinder.volume.drivers.hds import hds

@ -23,11 +23,10 @@ import tempfile
import mock
from cinder.openstack.common import log as logging
from cinder import test
from cinder.volume import configuration as conf
from cinder.volume.drivers.hds import iscsi
from cinder.openstack.common import log as logging
LOG = logging.getLogger(__name__)
HNASCONF = """<?xml version="1.0" encoding="UTF-8" ?>

@ -22,7 +22,6 @@ from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder import test
from cinder.tests import fake_hp_3par_client as hp3parclient
from cinder.volume.drivers.san.hp import hp_3par_fc as hpfcdriver
from cinder.volume.drivers.san.hp import hp_3par_iscsi as hpdriver

@ -14,9 +14,10 @@
"""Unit tests for OpenStack Cinder HP MSA driver."""
import urllib2
import lxml.etree as etree
import mock
import urllib2
from cinder import exception
from cinder import test

@ -21,7 +21,6 @@ from cinder import exception
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder import test
from cinder.tests import fake_hp_lefthand_client as hplefthandclient
from cinder.volume.drivers.san.hp import hp_lefthand_iscsi
from cinder.volume.drivers.san.hp import hp_lefthand_rest_proxy

@ -19,14 +19,14 @@ Unit Tests for Huawei HVS volume drivers.
"""
import json
import mox
import os
import shutil
import tempfile
import time
from xml.dom.minidom import Document
import mox
from cinder import exception
from cinder import test
from cinder.volume import configuration as conf

@ -18,16 +18,16 @@
Unit Tests for Huawei T and Dorado volume drivers.
"""
import mox
import os
import shutil
import socket
import tempfile
import time
from xml.dom.minidom import Document
from xml.etree import ElementTree as ET
import mox
from cinder import context
from cinder import exception
from cinder import ssh_utils

@ -21,7 +21,6 @@ Tests for the IBM NAS family (SONAS, Storwize V7000 Unified).
"""
import mock
from oslo.config import cfg
from cinder import context

@ -16,10 +16,10 @@
"""Unit tests for image utils."""
import contextlib
import mock
import mox
import tempfile
import mock
import mox
from oslo.config import cfg
from cinder import context

@ -20,8 +20,8 @@ Tests for NetApp volume driver
import BaseHTTPServer
import httplib
from lxml import etree
from lxml import etree
import six
from cinder import exception

@ -17,8 +17,9 @@ Tests for NetApp e-series iscsi volume driver.
"""
import json
import mock
import re
import mock
import requests
from cinder import exception

@ -15,12 +15,13 @@
# under the License.
"""Unit tests for the NetApp-specific NFS driver module."""
import os
from lxml import etree
import mock
import mox
from mox import IgnoreArg
from mox import IsA
import os
from cinder import context
from cinder import exception

@ -18,9 +18,9 @@
import BaseHTTPServer
import copy
import httplib
from lxml import etree
from mox import IgnoreArg
import six
from cinder import exception

@ -14,7 +14,6 @@
# under the License.
import mock
from oslo.config import cfg
from cinder import exception

@ -14,9 +14,10 @@
# under the License.
import json
import mock
import urllib2
import mock
from cinder import exception
from cinder.openstack.common import processutils
from cinder.openstack.common import units

@ -17,10 +17,11 @@
import math
import mock
import os
import tempfile
import mock
from cinder import db
from cinder import exception
from cinder.i18n import _

@ -18,11 +18,12 @@
Tests for the IBM Storwize family and SVC volume driver.
"""
import mock
import random
import re
import time
import mock
from cinder import context
from cinder import exception
from cinder.i18n import _

@ -20,7 +20,6 @@ Tests for Volume Code.
import contextlib
import datetime
import mock
import os
import shutil
import socket
@ -28,6 +27,7 @@ from sys import platform
import tempfile
import eventlet
import mock
import mox
from oslo.config import cfg
from stevedore import extension

@ -15,10 +15,10 @@
"""Tests For miscellaneous util methods used with volume."""
import mock
import os
import re
import mock
from oslo.config import cfg
from cinder import context

@ -16,11 +16,11 @@
"""Unit tests for `cinder.wsgi`."""
import mock
import os.path
import tempfile
import urllib2
import mock
from oslo.config import cfg
from oslo.i18n import _lazy
import testtools

@ -16,9 +16,10 @@
Mock unit tests for the NetApp iSCSI driver
"""
import mock
import uuid
import mock
from cinder import test
import cinder.volume.drivers.netapp.api as ntapi
import cinder.volume.drivers.netapp.iscsi as ntap_iscsi

@ -22,15 +22,12 @@ import os
import shutil
import tempfile
import mox
from oslo.config import cfg
import mox
from cinder import test
from cinder.image import image_utils
from cinder.openstack.common import fileutils
from cinder import test
from cinder.tests.windows import db_fakes
from cinder.volume import configuration as conf
from cinder.volume.drivers.windows import constants

@ -20,9 +20,8 @@
"""Unit tests for brcd fc san lookup service."""
import mock
import paramiko
from oslo.config import cfg
import paramiko
from cinder import exception
from cinder.openstack.common import log as logging

@ -20,6 +20,7 @@
"""Unit tests for brcd fc zone client cli."""
import mock
from mock import patch
from cinder import exception
from cinder.openstack.common import log as logging
@ -28,7 +29,6 @@ from cinder import test
from cinder.zonemanager.drivers.brocade.brcd_fc_zone_client_cli \
import BrcdFCZoneClientCLI
import cinder.zonemanager.drivers.brocade.fc_zone_constants as ZoneConstant
from mock import patch
LOG = logging.getLogger(__name__)

@ -20,9 +20,8 @@
"""Unit tests for Brocade fc zone driver."""
import mock
import paramiko
from oslo.config import cfg
import paramiko
from cinder import exception
from cinder.i18n import _

@ -20,13 +20,13 @@
"""Unit tests for FC Zone Manager."""
import mock
from mock import Mock
from cinder import exception
from cinder import test
from cinder.volume import configuration as conf
from cinder.zonemanager.drivers.fc_zone_driver import FCZoneDriver
from cinder.zonemanager import fc_zone_manager
from mock import Mock
fabric_name = 'BRCD_FAB_3'
init_target_map = {'10008c7cff523b01': ['20240002ac000a50']}

@ -29,15 +29,15 @@ import shutil
import stat
import sys
import tempfile
from oslo.config import cfg
import six
from xml.dom import minidom
from xml.parsers import expat
from xml import sax
from xml.sax import expatreader
from xml.sax import saxutils
from oslo.config import cfg
import six
from cinder.brick.initiator import connector
from cinder import exception
from cinder.i18n import _

@ -21,9 +21,9 @@ It supports VNX and VMAX arrays.
"""
import time
from xml.dom.minidom import parseString
from oslo.config import cfg
from xml.dom.minidom import parseString
from cinder import exception
from cinder.i18n import _

@ -19,9 +19,10 @@
iSCSI Cinder Volume driver for Hitachi Unified Storage (HUS) platform.
"""
from oslo.config import cfg
from xml.etree import ElementTree as ETree
from oslo.config import cfg
from cinder import exception
from cinder.i18n import _
from cinder.openstack.common import excutils

@ -18,10 +18,11 @@
Hitachi Unified Storage (HUS-HNAS) platform. Backend operations.
"""
import re
from cinder.openstack.common import log as logging
from cinder.openstack.common import units
from cinder import utils
import re
LOG = logging.getLogger("cinder.volume.driver")

@ -18,9 +18,10 @@
iSCSI Cinder Volume driver for Hitachi Unified Storage (HUS-HNAS) platform.
"""
from oslo.config import cfg
from xml.etree import ElementTree as ETree
from oslo.config import cfg
from cinder import exception
from cinder.i18n import _
from cinder.openstack.common import excutils

@ -19,9 +19,9 @@ Volume driver for HDS HNAS NFS storage.
import os
import time
from xml.etree import ElementTree as ETree
from oslo.config import cfg
from xml.etree import ElementTree as ETree
from cinder import exception
from cinder.i18n import _

@ -21,7 +21,6 @@ import json
import time
import urllib2
import uuid
from xml.etree import ElementTree as ET
from cinder import context

@ -24,7 +24,6 @@ import re
import socket
import threading
import time
from xml.etree import ElementTree as ET
from cinder import context

@ -16,10 +16,10 @@
import random
import re
import six
import unicodedata
from eventlet import greenthread
import six
from cinder import context
from cinder import exception

@ -19,9 +19,10 @@ NetApp api for ONTAP and OnCommand DFM.
Contains classes required to issue api calls to ONTAP and OnCommand DFM.
"""
from lxml import etree
import urllib2
from lxml import etree
from cinder.i18n import _
from cinder.openstack.common import log as logging

@ -17,8 +17,8 @@ Client classes for web services.
"""
import json
import requests
import requests
import six.moves.urllib.parse as urlparse
from cinder import exception

@ -14,6 +14,7 @@
# under the License.
import errno
import six
from cinder import exception

@ -18,11 +18,11 @@ import io
import json
import math
import os
import six
import tempfile
import urllib
from oslo.config import cfg
import six
from cinder import exception
from cinder.i18n import _

@ -15,6 +15,8 @@
#
"""HP LeftHand SAN ISCSI REST Proxy."""
from oslo.config import cfg
from cinder import context
from cinder import exception
from cinder.i18n import _
@ -23,7 +25,6 @@ from cinder.openstack.common import units
from cinder.volume.driver import ISCSIDriver
from cinder.volume import utils
from cinder.volume import volume_types
from oslo.config import cfg
LOG = logging.getLogger(__name__)

@ -20,10 +20,10 @@ Collection of classes to handle image upload/download to/from Image service
"""
import httplib
import netaddr
import urllib
import urllib2
import netaddr
import six.moves.urllib.parse as urlparse
from cinder.i18n import _

@ -72,7 +72,7 @@ commands = {posargs}
# F841,H302,H305,H307,H405
ignore = E251,E265,H302,H305,H307,H402,H405,H803,H904
ignore = E251,E265,H302,H402,H405,H803,H904
builtins = _
exclude = .git,.venv,.tox,dist,tools,doc,common,*egg,build