Commit 099c52ad authored by Iustin Pop's avatar Iustin Pop
Browse files

Another round of pylint-related style fixes



A newer version of pylint, more warnings…
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e3bdb1c2
......@@ -1807,13 +1807,13 @@ def OSFromDisk(name, base_dir=None):
return payload
def OSEnvironment(instance, os, debug=0):
def OSEnvironment(instance, inst_os, debug=0):
"""Calculate the environment for an os script.
@type instance: L{objects.Instance}
@param instance: target instance for the os script run
@type os: L{objects.OS}
@param os: operating system for which the environment is being built
@type inst_os: L{objects.OS}
@param inst_os: operating system for which the environment is being built
@type debug: integer
@param debug: debug level (0 or 1, for OS Api 10)
@rtype: dict
......@@ -1823,7 +1823,8 @@ def OSEnvironment(instance, os, debug=0):
"""
result = {}
api_version = max(constants.OS_API_VERSIONS.intersection(os.api_versions))
api_version = \
max(constants.OS_API_VERSIONS.intersection(inst_os.api_versions))
result['OS_API_VERSION'] = '%d' % api_version
result['INSTANCE_NAME'] = instance.name
result['INSTANCE_OS'] = instance.os
......@@ -1835,7 +1836,7 @@ def OSEnvironment(instance, os, debug=0):
try:
variant = instance.os.split('+', 1)[1]
except IndexError:
variant = os.supported_variants[0]
variant = inst_os.supported_variants[0]
result['OS_VARIANT'] = variant
for idx, disk in enumerate(instance.disks):
real_disk = _RecursiveFindBD(disk)
......
......@@ -48,7 +48,7 @@ def _IgnoreError(fn, *args, **kwargs):
fn(*args, **kwargs)
return True
except errors.BlockDeviceError, err:
logging.warning("Caught BlockDeviceError but ignoring: %s" % str(err))
logging.warning("Caught BlockDeviceError but ignoring: %s", str(err))
return False
......
......@@ -362,7 +362,7 @@ def FinalizeClusterDestroy(master):
result = rpc.RpcRunner.call_node_stop_master(master, True)
msg = result.fail_msg
if msg:
logging.warning("Could not disable the master role: %s" % msg)
logging.warning("Could not disable the master role: %s", msg)
result = rpc.RpcRunner.call_node_leave_cluster(master, modify_ssh_setup)
msg = result.fail_msg
if msg:
......
......@@ -5092,8 +5092,8 @@ class TLMigrateInstance(Tasklet):
False)
abort_msg = abort_result.fail_msg
if abort_msg:
logging.error("Aborting migration failed on target node %s: %s" %
(target_node, abort_msg))
logging.error("Aborting migration failed on target node %s: %s",
target_node, abort_msg)
# Don't raise an exception here, as we stil have to try to revert the
# disk status, even if this step failed.
......@@ -5178,7 +5178,7 @@ class TLMigrateInstance(Tasklet):
msg = result.fail_msg
if msg:
logging.error("Instance migration succeeded, but finalization failed:"
" %s" % msg)
" %s", msg)
raise errors.OpExecError("Could not finalize instance migration: %s" %
msg)
......@@ -6886,7 +6886,7 @@ class TLReplaceDisks(Tasklet):
minors = self.cfg.AllocateDRBDMinor([self.new_node
for dev in self.instance.disks],
self.instance.name)
logging.debug("Allocated minors %r" % (minors,))
logging.debug("Allocated minors %r", minors)
iv_names = {}
for idx, (dev, new_minor) in enumerate(zip(self.instance.disks, minors)):
......
......@@ -32,7 +32,6 @@ much memory.
"""
import os
import tempfile
import random
import logging
import time
......@@ -905,7 +904,7 @@ class ConfigWriter:
@param node: a Node instance
"""
logging.info("Adding node %s to configuration" % node.name)
logging.info("Adding node %s to configuration", node.name)
self._EnsureUUID(node)
......@@ -920,7 +919,7 @@ class ConfigWriter:
"""Remove a node from the configuration.
"""
logging.info("Removing node %s from configuration" % node_name)
logging.info("Removing node %s from configuration", node_name)
if node_name not in self._config_data.nodes:
raise errors.ConfigurationError("Unknown node '%s'" % node_name)
......
......@@ -297,7 +297,7 @@ def GenericMain(daemon_name, optionparser, dirs, check_fn, exec_fn):
debug=options.debug,
stderr_logging=not options.fork,
multithreaded=multithread)
logging.info("%s daemon startup" % daemon_name)
logging.info("%s daemon startup", daemon_name)
exec_fn(options, args)
finally:
utils.RemovePidFile(daemon_name)
......@@ -372,7 +372,7 @@ class OpQueryNodeStorage(OpCode):
class OpModifyNodeStorage(OpCode):
""""""
"""Modifies the properies of a storage unit"""
OP_ID = "OP_NODE_MODIFY_STORAGE"
__slots__ = OpCode.__slots__ + [
"node_name",
......
......@@ -61,6 +61,7 @@ class SimpleConfigReader(object):
self._config_data = None
self._inst_ips_by_link = None
self._ip_to_inst_by_link = None
self._instances_ips = None
self._mc_primary_ips = None
self._nodes_primary_ips = None
......@@ -470,4 +471,3 @@ def CheckMasterCandidate(debug, ss=None):
if debug:
sys.stderr.write("Not master candidate, exiting.\n")
sys.exit(constants.EXIT_NOTCANDIDATE)
......@@ -221,7 +221,7 @@ class SshRunner:
msg += ": %s" % output
else:
msg += ": %s (no output)" % retval.fail_reason
logging.error("Command %s failed: %s" % (retval.cmd, msg))
logging.error("Command %s failed: %s", retval.cmd, msg)
return False, msg
remotehostname = retval.stdout.strip()
......
......@@ -42,7 +42,6 @@ import fcntl
import resource
import logging
import signal
import string
from cStringIO import StringIO
......@@ -519,14 +518,14 @@ def MatchNameComponent(key, name_list, case_sensitive=True):
re_flags = 0
if not case_sensitive:
re_flags |= re.IGNORECASE
key = string.upper(key)
key = key.upper()
mo = re.compile("^%s(\..*)?$" % re.escape(key), re_flags)
names_filtered = []
string_matches = []
for name in name_list:
if mo.match(name) is not None:
names_filtered.append(name)
if not case_sensitive and key == string.upper(name):
if not case_sensitive and key == name.upper():
string_matches.append(name)
if len(string_matches) == 1:
......@@ -1107,7 +1106,7 @@ def TcpPing(target, port, timeout=10, live_port_needed=False, source=None):
success = True
except socket.timeout:
success = False
except socket.error, (errcode, errstring):
except socket.error, (errcode, _):
success = (not live_port_needed) and (errcode == errno.ECONNREFUSED)
return success
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment