summaryrefslogtreecommitdiff
path: root/ironic/common
diff options
context:
space:
mode:
authorSam Betts <sam@code-smash.net>2015-05-28 16:54:36 +0100
committerSam Betts <sam@code-smash.net>2015-06-04 12:56:51 +0100
commit8c07c4fda3e6a86a40aa00759652b99acbd73331 (patch)
tree7b68cc4850f42b8ce290a260ab22cc603b8010ee /ironic/common
parent83746b90092a813b82d4e0135c4e6a2f8a5bd52c (diff)
downloadironic-8c07c4fda3e6a86a40aa00759652b99acbd73331.tar.gz
Enforce flake8 E123/6/7/8 in ironic
This patch enforces the rules E123, E126, E127, and E128 in the ironic code base: E123 - closing bracket does not match indentation of opening bracket’s line E126 - continuation line over-indented for hanging indent E127 - continuation line over-indented for visual indent E128 - continuation line under-indented for visual indent This fixes any parts of the current code which fails these rules and removes these rules from the tox.ini flake8 ignore list. Change-Id: Ia96582b5e9abc088d6c1694afc93c59be4a4065c Closes-Bug: 1421522
Diffstat (limited to 'ironic/common')
-rw-r--r--ironic/common/config_generator/generator.py4
-rw-r--r--ironic/common/disk_partitioner.py4
-rw-r--r--ironic/common/driver_factory.py34
-rw-r--r--ironic/common/fsm.py4
-rw-r--r--ironic/common/glance_service/base_image_service.py12
-rw-r--r--ironic/common/hash_ring.py6
-rw-r--r--ironic/common/image_service.py12
-rw-r--r--ironic/common/images.py51
-rw-r--r--ironic/common/keystone.py18
-rw-r--r--ironic/common/pxe_utils.py2
-rw-r--r--ironic/common/service.py6
-rw-r--r--ironic/common/states.py12
-rw-r--r--ironic/common/swift.py2
-rw-r--r--ironic/common/utils.py8
14 files changed, 91 insertions, 84 deletions
diff --git a/ironic/common/config_generator/generator.py b/ironic/common/config_generator/generator.py
index bb971e29d..a2189030d 100644
--- a/ironic/common/config_generator/generator.py
+++ b/ironic/common/config_generator/generator.py
@@ -299,7 +299,7 @@ def _print_type(opt_type, opt_name, opt_default):
if opt_type == STROPT:
assert(isinstance(opt_default, six.string_types))
print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
- opt_default)))
+ opt_default)))
elif opt_type == BOOLOPT:
assert(isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, str(opt_default).lower()))
@@ -316,7 +316,7 @@ def _print_type(opt_type, opt_name, opt_default):
elif opt_type == DICTOPT:
assert(isinstance(opt_default, dict))
opt_default_strlist = [str(key) + ':' + str(value)
- for (key, value) in opt_default.items()]
+ for (key, value) in opt_default.items()]
print('#%s=%s' % (opt_name, ','.join(opt_default_strlist)))
elif opt_type == MULTISTROPT:
assert(isinstance(opt_default, list))
diff --git a/ironic/common/disk_partitioner.py b/ironic/common/disk_partitioner.py
index f522971dd..25d5e83a5 100644
--- a/ironic/common/disk_partitioner.py
+++ b/ironic/common/disk_partitioner.py
@@ -157,8 +157,8 @@ class DiskPartitioner(object):
max_retries = CONF.disk_partitioner.check_device_max_retries
timer = loopingcall.FixedIntervalLoopingCall(
- self._wait_for_disk_to_become_available,
- retries, max_retries, pids, fuser_err)
+ self._wait_for_disk_to_become_available,
+ retries, max_retries, pids, fuser_err)
timer.start(interval=interval).wait()
if retries[0] > max_retries:
diff --git a/ironic/common/driver_factory.py b/ironic/common/driver_factory.py
index 89bb03fe8..cc6439750 100644
--- a/ironic/common/driver_factory.py
+++ b/ironic/common/driver_factory.py
@@ -25,17 +25,17 @@ from ironic.common.i18n import _LI
LOG = log.getLogger(__name__)
driver_opts = [
- cfg.ListOpt('enabled_drivers',
- default=['pxe_ipmitool'],
- help='Specify the list of drivers to load during service '
- 'initialization. Missing drivers, or drivers which '
- 'fail to initialize, will prevent the conductor '
- 'service from starting. The option default is a '
- 'recommended set of production-oriented drivers. A '
- 'complete list of drivers present on your system may '
- 'be found by enumerating the "ironic.drivers" '
- 'entrypoint. An example may be found in the '
- 'developer documentation online.'),
+ cfg.ListOpt('enabled_drivers',
+ default=['pxe_ipmitool'],
+ help='Specify the list of drivers to load during service '
+ 'initialization. Missing drivers, or drivers which '
+ 'fail to initialize, will prevent the conductor '
+ 'service from starting. The option default is a '
+ 'recommended set of production-oriented drivers. A '
+ 'complete list of drivers present on your system may '
+ 'be found by enumerating the "ironic.drivers" '
+ 'entrypoint. An example may be found in the '
+ 'developer documentation online.'),
]
CONF = cfg.CONF
@@ -119,11 +119,11 @@ class DriverFactory(object):
return ext.name in CONF.enabled_drivers
cls._extension_manager = (
- dispatch.NameDispatchExtensionManager(
- 'ironic.drivers',
- _check_func,
- invoke_on_load=True,
- on_load_failure_callback=_catch_driver_not_found))
+ dispatch.NameDispatchExtensionManager(
+ 'ironic.drivers',
+ _check_func,
+ invoke_on_load=True,
+ on_load_failure_callback=_catch_driver_not_found))
# NOTE(deva): if we were unable to load any configured driver, perhaps
# because it is not present on the system, raise an error.
@@ -136,7 +136,7 @@ class DriverFactory(object):
raise exception.DriverNotFound(driver_name=names)
LOG.info(_LI("Loaded the following drivers: %s"),
- cls._extension_manager.names())
+ cls._extension_manager.names())
@property
def names(self):
diff --git a/ironic/common/fsm.py b/ironic/common/fsm.py
index e293306dc..2beb58bcb 100644
--- a/ironic/common/fsm.py
+++ b/ironic/common/fsm.py
@@ -74,7 +74,7 @@ class FSM(object):
return self._states[self._current.name]['terminal']
def add_state(self, state, on_enter=None, on_exit=None,
- target=None, terminal=None, stable=False):
+ target=None, terminal=None, stable=False):
"""Adds a given state to the state machine.
The on_enter and on_exit callbacks, if provided will be expected to
@@ -100,7 +100,7 @@ class FSM(object):
raise ValueError(_("On exit callback must be callable"))
if target is not None and target not in self._states:
raise excp.InvalidState(_("Target state '%s' does not exist")
- % target)
+ % target)
if target is not None and not self._states[target]['stable']:
raise excp.InvalidState(
_("Target state '%s' is not a 'stable' state") % target)
diff --git a/ironic/common/glance_service/base_image_service.py b/ironic/common/glance_service/base_image_service.py
index 8a09d3dee..ec0aee0bf 100644
--- a/ironic/common/glance_service/base_image_service.py
+++ b/ironic/common/glance_service/base_image_service.py
@@ -127,13 +127,13 @@ class BaseImageService(object):
host = self.glance_host
port = self.glance_port
error_msg = _LE("Error contacting glance server "
- "'%(host)s:%(port)s' for '%(method)s', attempt"
- " %(attempt)s of %(num_attempts)s failed.")
+ "'%(host)s:%(port)s' for '%(method)s', attempt"
+ " %(attempt)s of %(num_attempts)s failed.")
LOG.exception(error_msg, {'host': host,
- 'port': port,
- 'num_attempts': num_attempts,
- 'attempt': attempt,
- 'method': method})
+ 'port': port,
+ 'num_attempts': num_attempts,
+ 'attempt': attempt,
+ 'method': method})
if attempt == num_attempts:
raise exception.GlanceConnectionFailed(host=host,
port=port,
diff --git a/ironic/common/hash_ring.py b/ironic/common/hash_ring.py
index b95bba103..2602ddcfb 100644
--- a/ironic/common/hash_ring.py
+++ b/ironic/common/hash_ring.py
@@ -83,7 +83,7 @@ class HashRing(object):
self.replicas = replicas if replicas <= len(hosts) else len(hosts)
except TypeError:
raise exception.Invalid(
- _("Invalid hosts supplied when building HashRing."))
+ _("Invalid hosts supplied when building HashRing."))
self._host_hashes = {}
for host in hosts:
@@ -114,7 +114,7 @@ class HashRing(object):
return position if position < len(self._partitions) else 0
except TypeError:
raise exception.Invalid(
- _("Invalid data supplied to HashRing.get_hosts."))
+ _("Invalid data supplied to HashRing.get_hosts."))
def get_hosts(self, data, ignore_hosts=None):
"""Get the list of hosts which the supplied data maps onto.
@@ -197,4 +197,4 @@ class HashRingManager(object):
return self.ring[driver_name]
except KeyError:
raise exception.DriverNotFound(
- _("The driver '%s' is unknown.") % driver_name)
+ _("The driver '%s' is unknown.") % driver_name)
diff --git a/ironic/common/image_service.py b/ironic/common/image_service.py
index 9086beb83..d7a963051 100644
--- a/ironic/common/image_service.py
+++ b/ironic/common/image_service.py
@@ -137,7 +137,8 @@ class HttpImageService(BaseImageService):
try:
response = requests.head(image_href)
if response.status_code != 200:
- raise exception.ImageRefValidationFailed(image_href=image_href,
+ raise exception.ImageRefValidationFailed(
+ image_href=image_href,
reason=_("Got HTTP code %s instead of 200 in response to "
"HEAD request.") % response.status_code)
except requests.RequestException as e:
@@ -159,7 +160,8 @@ class HttpImageService(BaseImageService):
try:
response = requests.get(image_href, stream=True)
if response.status_code != 200:
- raise exception.ImageRefValidationFailed(image_href=image_href,
+ raise exception.ImageRefValidationFailed(
+ image_href=image_href,
reason=_("Got HTTP code %s instead of 200 in response to "
"GET request.") % response.status_code)
with response.raw as input_img:
@@ -181,7 +183,8 @@ class HttpImageService(BaseImageService):
response = self.validate_href(image_href)
image_size = response.headers.get('Content-Length')
if image_size is None:
- raise exception.ImageRefValidationFailed(image_href=image_href,
+ raise exception.ImageRefValidationFailed(
+ image_href=image_href,
reason=_("Cannot determine image size as there is no "
"Content-Length header specified in response "
"to HEAD request."))
@@ -204,7 +207,8 @@ class FileImageService(BaseImageService):
"""
image_path = urlparse.urlparse(image_href).path
if not os.path.isfile(image_path):
- raise exception.ImageRefValidationFailed(image_href=image_href,
+ raise exception.ImageRefValidationFailed(
+ image_href=image_href,
reason=_("Specified image file not found."))
return image_path
diff --git a/ironic/common/images.py b/ironic/common/images.py
index 57f65ac7b..542fd98f5 100644
--- a/ironic/common/images.py
+++ b/ironic/common/images.py
@@ -45,14 +45,14 @@ image_opts = [
help='If True, convert backing images to "raw" disk image '
'format.'),
cfg.StrOpt('isolinux_bin',
- default='/usr/lib/syslinux/isolinux.bin',
- help='Path to isolinux binary file.'),
+ default='/usr/lib/syslinux/isolinux.bin',
+ help='Path to isolinux binary file.'),
cfg.StrOpt('isolinux_config_template',
- default=paths.basedir_def('common/isolinux_config.template'),
- help='Template file for isolinux configuration file.'),
+ default=paths.basedir_def('common/isolinux_config.template'),
+ help='Template file for isolinux configuration file.'),
cfg.StrOpt('grub_config_template',
- default=paths.basedir_def('common/grub_conf.template'),
- help='Template file for grub configuration file.'),
+ default=paths.basedir_def('common/grub_conf.template'),
+ help='Template file for grub configuration file.'),
]
@@ -141,7 +141,7 @@ def create_vfat_image(output_file, files_info=None, parameters=None,
if parameters:
parameters_file = os.path.join(tmpdir, parameters_file)
params_list = ['%(key)s=%(val)s' % {'key': k, 'val': v}
- for k, v in parameters.items()]
+ for k, v in parameters.items()]
file_contents = '\n'.join(params_list)
utils.write_to_file(parameters_file, file_contents)
@@ -209,10 +209,10 @@ def create_isolinux_image_for_bios(output_file, kernel, ramdisk,
with utils.tempdir() as tmpdir:
files_info = {
- kernel: 'vmlinuz',
- ramdisk: 'initrd',
- CONF.isolinux_bin: ISOLINUX_BIN,
- }
+ kernel: 'vmlinuz',
+ ramdisk: 'initrd',
+ CONF.isolinux_bin: ISOLINUX_BIN,
+ }
try:
_create_root_fs(tmpdir, files_info)
except (OSError, IOError) as e:
@@ -264,10 +264,10 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk,
with utils.tempdir() as tmpdir:
files_info = {
- kernel: 'vmlinuz',
- ramdisk: 'initrd',
- CONF.isolinux_bin: ISOLINUX_BIN,
- }
+ kernel: 'vmlinuz',
+ ramdisk: 'initrd',
+ CONF.isolinux_bin: ISOLINUX_BIN,
+ }
# Open the deploy iso used to initiate deploy and copy the
# efiboot.img i.e. boot loader to the current temporary
@@ -335,7 +335,7 @@ def fetch(context, image_href, path, image_service=None, force_raw=False):
# checked before we got here.
if not image_service:
image_service = service.get_image_service(image_href,
- context=context)
+ context=context)
LOG.debug("Using %(image_service)s to download image %(image_href)s." %
{'image_service': image_service.__class__,
'image_href': image_href})
@@ -355,29 +355,30 @@ def image_to_raw(image_href, path, path_tmp):
fmt = data.file_format
if fmt is None:
raise exception.ImageUnacceptable(
- reason=_("'qemu-img info' parsing failed."),
- image_id=image_href)
+ reason=_("'qemu-img info' parsing failed."),
+ image_id=image_href)
backing_file = data.backing_file
if backing_file is not None:
- raise exception.ImageUnacceptable(image_id=image_href,
+ raise exception.ImageUnacceptable(
+ image_id=image_href,
reason=_("fmt=%(fmt)s backed by: %(backing_file)s") %
- {'fmt': fmt,
- 'backing_file': backing_file})
+ {'fmt': fmt, 'backing_file': backing_file})
if fmt != "raw":
staged = "%s.converted" % path
LOG.debug("%(image)s was %(format)s, converting to raw" %
- {'image': image_href, 'format': fmt})
+ {'image': image_href, 'format': fmt})
with fileutils.remove_path_on_error(staged):
convert_image(path_tmp, staged, 'raw')
os.unlink(path_tmp)
data = qemu_img_info(staged)
if data.file_format != "raw":
- raise exception.ImageConvertFailed(image_id=image_href,
- reason=_("Converted to raw, but format is now %s") %
- data.file_format)
+ raise exception.ImageConvertFailed(
+ image_id=image_href,
+ reason=_("Converted to raw, but format is "
+ "now %s") % data.file_format)
os.rename(staged, path)
else:
diff --git a/ironic/common/keystone.py b/ironic/common/keystone.py
index 48144d94c..a05d46e3d 100644
--- a/ironic/common/keystone.py
+++ b/ironic/common/keystone.py
@@ -64,11 +64,12 @@ def _get_ksclient(token=None):
if token:
return client.Client(token=token, auth_url=auth_url)
else:
- return client.Client(username=CONF.keystone_authtoken.admin_user,
- password=CONF.keystone_authtoken.admin_password,
- tenant_name=CONF.keystone_authtoken.admin_tenant_name,
- region_name=CONF.keystone.region_name,
- auth_url=auth_url)
+ return client.Client(
+ username=CONF.keystone_authtoken.admin_user,
+ password=CONF.keystone_authtoken.admin_password,
+ tenant_name=CONF.keystone_authtoken.admin_tenant_name,
+ region_name=CONF.keystone.region_name,
+ auth_url=auth_url)
except ksexception.Unauthorized:
raise exception.KeystoneUnauthorized()
except ksexception.AuthorizationFailure as err:
@@ -111,9 +112,10 @@ def get_service_url(service_type='baremetal', endpoint_type='internal'):
'loaded'))
try:
- endpoint = ksclient.service_catalog.url_for(service_type=service_type,
- endpoint_type=endpoint_type,
- region_name=CONF.keystone.region_name)
+ endpoint = ksclient.service_catalog.url_for(
+ service_type=service_type,
+ endpoint_type=endpoint_type,
+ region_name=CONF.keystone.region_name)
except ksexception.EndpointNotFound:
raise exception.CatalogNotFound(service_type=service_type,
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 7895ac887..458547890 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -115,7 +115,7 @@ def _link_ip_address_pxe_configs(task):
ip_address_path = _get_pxe_ip_address_path(port_ip_address)
utils.unlink_without_raise(ip_address_path)
utils.create_link_without_raise(pxe_config_file_path,
- ip_address_path)
+ ip_address_path)
def _get_pxe_mac_path(mac, delimiter=None):
diff --git a/ironic/common/service.py b/ironic/common/service.py
index b3d3a64b7..9530cc643 100644
--- a/ironic/common/service.py
+++ b/ironic/common/service.py
@@ -74,9 +74,9 @@ class RPCService(service.Service):
self.handle_signal()
self.manager.init_host()
self.tg.add_dynamic_timer(
- self.manager.periodic_tasks,
- periodic_interval_max=cfg.CONF.periodic_interval,
- context=admin_context)
+ self.manager.periodic_tasks,
+ periodic_interval_max=cfg.CONF.periodic_interval,
+ context=admin_context)
LOG.info(_LI('Created RPC server for service %(service)s on host '
'%(host)s.'),
diff --git a/ironic/common/states.py b/ironic/common/states.py
index 6c7e40e0c..2da2c8f05 100644
--- a/ironic/common/states.py
+++ b/ironic/common/states.py
@@ -40,11 +40,11 @@ LOG = logging.getLogger(__name__)
# TODO(deva): add add'l state mappings here
VERBS = {
- 'active': 'deploy',
- 'deleted': 'delete',
- 'manage': 'manage',
- 'provide': 'provide',
- 'inspect': 'inspect',
+ 'active': 'deploy',
+ 'deleted': 'delete',
+ 'manage': 'manage',
+ 'provide': 'provide',
+ 'inspect': 'inspect',
}
""" Mapping of state-changing events that are PUT to the REST API
@@ -175,7 +175,7 @@ REBOOT = 'rebooting'
def on_exit(old_state, event):
"""Used to log when a state is exited."""
LOG.debug("Exiting old state '%s' in response to event '%s'",
- old_state, event)
+ old_state, event)
def on_enter(new_state, event):
diff --git a/ironic/common/swift.py b/ironic/common/swift.py
index 1f9e4410b..f0316248f 100644
--- a/ironic/common/swift.py
+++ b/ironic/common/swift.py
@@ -30,7 +30,7 @@ swift_opts = [
default=2,
help='Maximum number of times to retry a Swift request, '
'before failing.')
- ]
+]
CONF = cfg.CONF
diff --git a/ironic/common/utils.py b/ironic/common/utils.py
index 970e6d24a..4f8bb18ea 100644
--- a/ironic/common/utils.py
+++ b/ironic/common/utils.py
@@ -446,7 +446,7 @@ def unlink_without_raise(path):
return
else:
LOG.warn(_LW("Failed to unlink %(path)s, error: %(e)s"),
- {'path': path, 'e': e})
+ {'path': path, 'e': e})
def rmtree_without_raise(path):
@@ -455,7 +455,7 @@ def rmtree_without_raise(path):
shutil.rmtree(path)
except OSError as e:
LOG.warn(_LW("Failed to remove dir %(path)s, error: %(e)s"),
- {'path': path, 'e': e})
+ {'path': path, 'e': e})
def write_to_file(path, contents):
@@ -472,7 +472,7 @@ def create_link_without_raise(source, link):
else:
LOG.warn(_LW("Failed to create symlink from %(source)s to %(link)s"
", error: %(e)s"),
- {'source': source, 'link': link, 'e': e})
+ {'source': source, 'link': link, 'e': e})
def safe_rstrip(value, chars=None):
@@ -558,7 +558,7 @@ def check_dir(directory_to_check=None, required_space=1):
# check if directory_to_check is passed in, if not set to tempdir
if directory_to_check is None:
directory_to_check = (tempfile.gettempdir() if CONF.tempdir
- is None else CONF.tempdir)
+ is None else CONF.tempdir)
LOG.debug("checking directory: %s", directory_to_check)