summaryrefslogtreecommitdiff
path: root/ironic/common
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/common')
-rw-r--r--ironic/common/cinder.py6
-rw-r--r--ironic/common/driver_factory.py4
-rw-r--r--ironic/common/fsm.py8
-rw-r--r--ironic/common/glance_service/base_image_service.py8
-rw-r--r--ironic/common/glance_service/service_utils.py12
-rw-r--r--ironic/common/glance_service/v2/image_service.py16
-rw-r--r--ironic/common/image_service.py4
-rw-r--r--ironic/common/images.py8
-rw-r--r--ironic/common/neutron.py24
-rw-r--r--ironic/common/pxe_utils.py12
-rw-r--r--ironic/common/utils.py4
-rw-r--r--ironic/common/wsgi_service.py4
12 files changed, 55 insertions, 55 deletions
diff --git a/ironic/common/cinder.py b/ironic/common/cinder.py
index 3f356fcd0..9ca3c55a5 100644
--- a/ironic/common/cinder.py
+++ b/ironic/common/cinder.py
@@ -83,9 +83,9 @@ def is_volume_available(volume):
:returns: Boolean if volume is available.
"""
- return (volume.status == AVAILABLE or
- (volume.status == IN_USE and
- volume.multiattach))
+ return (volume.status == AVAILABLE
+ or (volume.status == IN_USE
+ and volume.multiattach))
def is_volume_attached(node, volume):
diff --git a/ironic/common/driver_factory.py b/ironic/common/driver_factory.py
index d33e71838..c8416c9b1 100644
--- a/ironic/common/driver_factory.py
+++ b/ironic/common/driver_factory.py
@@ -180,8 +180,8 @@ def default_interface(driver_or_hw_type, interface_type,
# For non hardware types we need to set a fallback for the network
# interface however hardware_types specify their own defaults if not in
# the config file.
- if (CONF.dhcp.dhcp_provider == 'neutron' and
- 'flat' in CONF.enabled_network_interfaces):
+ if (CONF.dhcp.dhcp_provider == 'neutron'
+ and 'flat' in CONF.enabled_network_interfaces):
additional_defaults['network'] = 'flat'
elif 'noop' in CONF.enabled_network_interfaces:
additional_defaults['network'] = 'noop'
diff --git a/ironic/common/fsm.py b/ironic/common/fsm.py
index 6aab03128..7f1e193bd 100644
--- a/ironic/common/fsm.py
+++ b/ironic/common/fsm.py
@@ -99,8 +99,8 @@ class FSM(machines.FiniteMachine):
def _post_process_event(self, event, result):
# Clear '_target_state' if we've reached it
- if (self._target_state is not None and
- self._target_state == self._current.name):
+ if (self._target_state is not None
+ and self._target_state == self._current.name):
self._target_state = None
# If new state has a different target, update the '_target_state'
if self._states[self._current.name]['target'] is not None:
@@ -136,8 +136,8 @@ class FSM(machines.FiniteMachine):
super(FSM, self).initialize(start_state=start_state)
current_state = self._current.name
self._validate_target_state(target_state)
- self._target_state = (target_state or
- self._states[current_state]['target'])
+ self._target_state = (target_state
+ or self._states[current_state]['target'])
@_translate_excp
def process_event(self, event, target_state=None):
diff --git a/ironic/common/glance_service/base_image_service.py b/ironic/common/glance_service/base_image_service.py
index 387e34290..3a79abd25 100644
--- a/ironic/common/glance_service/base_image_service.py
+++ b/ironic/common/glance_service/base_image_service.py
@@ -83,8 +83,8 @@ def check_image_service(func):
# TODO(pas-ha) remove in Rocky
# NOTE(pas-ha) new option must win if configured
- if (CONF.glance.glance_api_servers and
- not CONF.glance.endpoint_override):
+ if (CONF.glance.glance_api_servers
+ and not CONF.glance.endpoint_override):
# NOTE(pas-ha) all the 2 methods have image_href as the first
# positional arg, but check in kwargs too
image_href = args[0] if args else kwargs.get('image_href')
@@ -211,8 +211,8 @@ class BaseImageService(object):
"""
image_id = service_utils.parse_image_id(image_href)
- if (self.version == 2 and
- 'file' in CONF.glance.allowed_direct_url_schemes):
+ if (self.version == 2
+ and 'file' in CONF.glance.allowed_direct_url_schemes):
location = self._get_location(image_id)
url = urlparse.urlparse(location)
diff --git a/ironic/common/glance_service/service_utils.py b/ironic/common/glance_service/service_utils.py
index 91c19825d..66ce9fcbb 100644
--- a/ironic/common/glance_service/service_utils.py
+++ b/ironic/common/glance_service/service_utils.py
@@ -153,8 +153,8 @@ def is_image_available(context, image):
if hasattr(context, 'auth_token') and context.auth_token:
return True
- if ((getattr(image, 'is_public', None) or
- getattr(image, 'visibility', None) == 'public') or context.is_admin):
+ if ((getattr(image, 'is_public', None)
+ or getattr(image, 'visibility', None) == 'public') or context.is_admin):
return True
properties = image.properties
if context.project_id and ('owner_id' in properties):
@@ -183,8 +183,8 @@ def is_image_active(image):
def is_glance_image(image_href):
if not isinstance(image_href, six.string_types):
return False
- return (image_href.startswith('glance://') or
- uuidutils.is_uuid_like(image_href))
+ return (image_href.startswith('glance://')
+ or uuidutils.is_uuid_like(image_href))
def is_image_href_ordinary_file_name(image_href):
@@ -197,6 +197,6 @@ def is_image_href_ordinary_file_name(image_href):
:returns: True if image_href is ordinary file name, False otherwise.
"""
- return not (is_glance_image(image_href) or
- urlparse.urlparse(image_href).scheme.lower() in
+ return not (is_glance_image(image_href)
+ or urlparse.urlparse(image_href).scheme.lower() in
image_service.protocol_mapping)
diff --git a/ironic/common/glance_service/v2/image_service.py b/ironic/common/glance_service/v2/image_service.py
index 78c9165a6..3302328d7 100644
--- a/ironic/common/glance_service/v2/image_service.py
+++ b/ironic/common/glance_service/v2/image_service.py
@@ -197,13 +197,13 @@ class GlanceImageService(base_image_service.BaseImageService,
def _validate_temp_url_config(self):
"""Validate the required settings for a temporary URL."""
- if (not CONF.glance.swift_temp_url_key and
- CONF.deploy.object_store_endpoint_type != 'swift'):
+ if (not CONF.glance.swift_temp_url_key
+ and CONF.deploy.object_store_endpoint_type != 'swift'):
raise exc.MissingParameterValue(_(
'Swift temporary URLs require a shared secret to be created. '
'You must provide "swift_temp_url_key" as a config option.'))
- if (CONF.glance.swift_temp_url_duration <
- CONF.glance.swift_temp_url_expected_download_start_delay):
+ if (CONF.glance.swift_temp_url_duration
+ < CONF.glance.swift_temp_url_expected_download_start_delay):
raise exc.InvalidParameterValue(_(
'"swift_temp_url_duration" must be greater than or equal to '
'"[glance]swift_temp_url_expected_download_start_delay" '
@@ -244,8 +244,8 @@ class GlanceImageService(base_image_service.BaseImageService,
num_dashes = image_id[:seed_num_chars].count('-')
num_chars = seed_num_chars + num_dashes
name_suffix = image_id[:num_chars]
- new_container_name = (CONF.glance.swift_container +
- '_' + name_suffix)
+ new_container_name = (CONF.glance.swift_container
+ + '_' + name_suffix)
return new_container_name
else:
return CONF.glance.swift_container
@@ -270,8 +270,8 @@ class GlanceImageService(base_image_service.BaseImageService,
usage time.
"""
max_valid_time = (
- int(time.time()) +
- CONF.glance.swift_temp_url_expected_download_start_delay)
+ int(time.time())
+ + CONF.glance.swift_temp_url_expected_download_start_delay)
keys_to_remove = [
k for k, v in self._cache.items()
if (v.url_expires_at < max_valid_time)]
diff --git a/ironic/common/image_service.py b/ironic/common/image_service.py
index 462a76367..41da56b25 100644
--- a/ironic/common/image_service.py
+++ b/ironic/common/image_service.py
@@ -214,8 +214,8 @@ class FileImageService(BaseImageService):
try:
# We should have read and write access to source file to create
# hard link to it.
- if (local_device == os.stat(source_image_path).st_dev and
- os.access(source_image_path, os.R_OK | os.W_OK)):
+ if (local_device == os.stat(source_image_path).st_dev
+ and os.access(source_image_path, os.R_OK | os.W_OK)):
image_file.close()
os.remove(dest_image_path)
os.link(source_image_path, dest_image_path)
diff --git a/ironic/common/images.py b/ironic/common/images.py
index 1a7fa2eb8..7ee63b32e 100644
--- a/ironic/common/images.py
+++ b/ironic/common/images.py
@@ -480,12 +480,12 @@ def is_whole_disk_image(ctx, instance_info):
iproperties = get_image_properties(ctx, image_source)
except Exception:
return
- is_whole_disk_image = (not iproperties.get('kernel_id') and
- not iproperties.get('ramdisk_id'))
+ is_whole_disk_image = (not iproperties.get('kernel_id')
+ and not iproperties.get('ramdisk_id'))
else:
# Non glance image ref
- if (not instance_info.get('kernel') and
- not instance_info.get('ramdisk')):
+ if (not instance_info.get('kernel')
+ and not instance_info.get('ramdisk')):
is_whole_disk_image = True
return is_whole_disk_image
diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py
index 217d1e492..846d0d15f 100644
--- a/ironic/common/neutron.py
+++ b/ironic/common/neutron.py
@@ -63,12 +63,12 @@ def get_client(token=None, context=None):
# 'noauth' then would correspond to 'auth_type=none' and
# 'endpoint_override'
adapter_params = {}
- if (CONF.neutron.auth_strategy == 'noauth' and
- CONF.neutron.auth_type is None):
+ if (CONF.neutron.auth_strategy == 'noauth'
+ and CONF.neutron.auth_type is None):
CONF.set_override('auth_type', 'none', group='neutron')
if not CONF.neutron.endpoint_override:
- adapter_params['endpoint_override'] = (CONF.neutron.url or
- DEFAULT_NEUTRON_URL)
+ adapter_params['endpoint_override'] = (CONF.neutron.url
+ or DEFAULT_NEUTRON_URL)
else:
if CONF.keystone.region_name and not CONF.neutron.region_name:
adapter_params['region_name'] = CONF.keystone.region_name
@@ -464,8 +464,8 @@ def validate_port_info(node, port):
# Subnet Manager.
if port.extra.get('client-id'):
return True
- if (node.network_interface == 'neutron' and
- not port.local_link_connection):
+ if (node.network_interface == 'neutron'
+ and not port.local_link_connection):
LOG.warning("The local_link_connection is required for "
"'neutron' network interface and is not present "
"in the nodes %(node)s port %(port)s",
@@ -577,8 +577,8 @@ class NeutronNetworkInterfaceMixin(object):
def get_cleaning_network_uuid(self, task):
cleaning_network = (
- task.node.driver_info.get('cleaning_network') or
- CONF.neutron.cleaning_network
+ task.node.driver_info.get('cleaning_network')
+ or CONF.neutron.cleaning_network
)
return validate_network(
cleaning_network, _('cleaning network'),
@@ -586,8 +586,8 @@ class NeutronNetworkInterfaceMixin(object):
def get_provisioning_network_uuid(self, task):
provisioning_network = (
- task.node.driver_info.get('provisioning_network') or
- CONF.neutron.provisioning_network
+ task.node.driver_info.get('provisioning_network')
+ or CONF.neutron.provisioning_network
)
return validate_network(
provisioning_network, _('provisioning network'),
@@ -597,8 +597,8 @@ class NeutronNetworkInterfaceMixin(object):
# FlatNetwork uses tenant network for rescue operation.
def get_rescuing_network_uuid(self, task):
rescuing_network = (
- task.node.driver_info.get('rescuing_network') or
- CONF.neutron.rescuing_network
+ task.node.driver_info.get('rescuing_network')
+ or CONF.neutron.rescuing_network
)
return validate_network(
rescuing_network, _('rescuing network'),
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 292bfcf67..07529865f 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -227,8 +227,8 @@ def create_pxe_config(task, pxe_options, template=None):
_ensure_config_dirs_exist(task.node.uuid)
pxe_config_file_path = get_pxe_config_file_path(task.node.uuid)
- is_uefi_boot_mode = (deploy_utils.get_boot_mode_for_deploy(task.node) ==
- 'uefi')
+ is_uefi_boot_mode = (deploy_utils.get_boot_mode_for_deploy(task.node)
+ == 'uefi')
# grub bootloader panics with '{}' around any of its tags in its
# config file. To overcome that 'ROOT' and 'DISK_IDENTIFIER' are enclosed
@@ -274,8 +274,8 @@ def create_ipxe_boot_script():
# NOTE(pas-ha) to prevent unneeded writes,
# only write to file if its content is different from required,
# which should be rather rare
- if (not os.path.isfile(bootfile_path) or
- not utils.file_has_content(bootfile_path, boot_script)):
+ if (not os.path.isfile(bootfile_path)
+ or not utils.file_has_content(bootfile_path, boot_script)):
utils.write_to_file(bootfile_path, boot_script)
@@ -287,8 +287,8 @@ def clean_up_pxe_config(task):
"""
LOG.debug("Cleaning up PXE config for node %s", task.node.uuid)
- is_uefi_boot_mode = (deploy_utils.get_boot_mode_for_deploy(task.node) ==
- 'uefi')
+ is_uefi_boot_mode = (deploy_utils.get_boot_mode_for_deploy(task.node)
+ == 'uefi')
if is_uefi_boot_mode and not CONF.pxe.ipxe_enabled:
api = dhcp_factory.DHCPFactory().provider
ip_addresses = api.get_ip_addresses(task)
diff --git a/ironic/common/utils.py b/ironic/common/utils.py
index e69e0ef83..9fcc5f48e 100644
--- a/ironic/common/utils.py
+++ b/ironic/common/utils.py
@@ -90,8 +90,8 @@ def is_valid_datapath_id(datapath_id):
"""
m = "^[0-9a-f]{16}$"
- return (isinstance(datapath_id, six.string_types) and
- re.match(m, datapath_id.lower()))
+ return (isinstance(datapath_id, six.string_types)
+ and re.match(m, datapath_id.lower()))
_is_valid_logical_name_re = re.compile(r'^[A-Z0-9-._~]+$', re.I)
diff --git a/ironic/common/wsgi_service.py b/ironic/common/wsgi_service.py
index d9f689664..5c30d708e 100644
--- a/ironic/common/wsgi_service.py
+++ b/ironic/common/wsgi_service.py
@@ -32,8 +32,8 @@ class WSGIService(service.ServiceBase):
"""
self.name = name
self.app = app.VersionSelectorApplication()
- self.workers = (CONF.api.api_workers or
- processutils.get_worker_count())
+ self.workers = (CONF.api.api_workers
+ or processutils.get_worker_count())
if self.workers and self.workers < 1:
raise exception.ConfigInvalid(
_("api_workers value of %d is invalid, "