Commit e687ec01 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

PEP8 style fixes



Identified using the “pep8” utility.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent b7bf8b58
......@@ -662,7 +662,7 @@ class Disk(ConfigObject):
"""
if self.dev_type == constants.LD_LV:
val = "<LogicalVolume(/dev/%s/%s" % self.logical_id
val = "<LogicalVolume(/dev/%s/%s" % self.logical_id
elif self.dev_type in constants.LDS_DRBD:
node_a, node_b, port, minor_a, minor_b = self.logical_id[:5]
val = "<DRBD8("
......@@ -789,7 +789,9 @@ class Instance(TaggableObject):
node = self.primary_node
if lvmap is None:
lvmap = { node : [] }
lvmap = {
node: [],
}
ret = lvmap
else:
if not node in lvmap:
......@@ -801,7 +803,7 @@ class Instance(TaggableObject):
for dev in devs:
if dev.dev_type == constants.LD_LV:
lvmap[node].append(dev.logical_id[0]+"/"+dev.logical_id[1])
lvmap[node].append(dev.logical_id[0] + "/" + dev.logical_id[1])
elif dev.dev_type in constants.LDS_DRBD:
if dev.children:
......
......@@ -1536,6 +1536,7 @@ class OpTagsDel(OpCode):
("name", ht.NoDefault, ht.TMaybeString, None),
]
# Test opcodes
class OpTestDelay(OpCode):
"""Sleeps for a configured amount of time.
......
......@@ -53,7 +53,10 @@ def BuildUriList(ids, uri_format, uri_fields=("name", "uri")):
(field_id, field_uri) = uri_fields
def _MapId(m_id):
return { field_id: m_id, field_uri: uri_format % m_id, }
return {
field_id: m_id,
field_uri: uri_format % m_id,
}
# Make sure the result is sorted, makes it nicer to look at and simplifies
# unittests.
......
......@@ -664,7 +664,6 @@ def _ParseModifyGroupRequest(name, data):
})
class R_2_groups_name_modify(baserlib.R_Generic):
"""/2/groups/[group_name]/modify resource.
......
......@@ -187,4 +187,3 @@ def GetEnts(resolver=GetentResolver):
_priv_lock.release()
return _priv
......@@ -82,7 +82,7 @@ class ConfdAsyncUDPServer(daemon.AsyncUDPSocket):
logging.debug(err)
return
answer = self.processor.ExecQuery(query, ip, port)
answer = self.processor.ExecQuery(query, ip, port)
if answer is not None:
try:
self.enqueue_send(ip, port, confd.PackMagic(answer))
......
......@@ -113,6 +113,7 @@ class MasterClientHandler(daemon.AsyncTerminatedMessageStream):
"""
_MAX_UNHANDLED = 1
def __init__(self, server, connected_socket, client_address, family):
daemon.AsyncTerminatedMessageStream.__init__(self, connected_socket,
client_address,
......
......@@ -711,7 +711,6 @@ class NodeHttpServer(http.server.HttpServer):
"""
return backend.DemoteFromMC()
@staticmethod
def perspective_node_powercycle(params):
"""Tries to powercycle the nod.
......@@ -720,7 +719,6 @@ class NodeHttpServer(http.server.HttpServer):
hypervisor_type = params[0]
return backend.PowercycleNode(hypervisor_type)
# cluster --------------------------
@staticmethod
......
......@@ -511,7 +511,7 @@ def TailFile(fname, lines=20):
try:
fd.seek(0, 2)
pos = fd.tell()
pos = max(0, pos-4096)
pos = max(0, pos - 4096)
fd.seek(pos, 0)
raw_data = fd.read()
finally:
......
......@@ -84,7 +84,6 @@ class RunResult(object):
__slots__ = ["exit_code", "signal", "stdout", "stderr",
"failed", "fail_reason", "cmd"]
def __init__(self, exit_code, signal_, stdout, stderr, cmd, timeout_action,
timeout):
self.cmd = cmd
......
......@@ -206,6 +206,7 @@ def SimpleRetry(expected, fn, delay, timeout, args=None, wait_fn=time.sleep,
"""
rdict = {}
def helper(*innerargs):
# pylint: disable-msg=W0142
result = rdict["result"] = fn(*innerargs)
......
......@@ -338,7 +338,7 @@ def SafeEncode(text):
resu = ""
for char in text:
c = ord(char)
if char == "\t":
if char == "\t":
resu += r"\t"
elif char == "\n":
resu += r"\n"
......
......@@ -131,9 +131,9 @@ class NodeMaintenance(object):
"""
my_name = netutils.Hostname.GetSysName()
req = confd.client.ConfdClientRequest(type=
constants.CONFD_REQ_NODE_ROLE_BYNAME,
query=my_name)
req = \
confd.client.ConfdClientRequest(type=constants.CONFD_REQ_NODE_ROLE_BYNAME,
query=my_name)
self.confd_client.SendRequest(req, async=False, coverage=-1)
timed_out, _, _ = self.confd_client.WaitForReply(req.rsalt)
if not timed_out:
......
......@@ -51,6 +51,7 @@ LOG_HEADERS = {
2: ""
}
class InstanceDown(Exception):
"""The checked instance was not up"""
......@@ -73,8 +74,8 @@ def Log(msg, *args, **kwargs):
"""
if args:
msg = msg % args
indent = kwargs.get('indent', 0)
sys.stdout.write("%*s%s%s\n" % (2*indent, "",
indent = kwargs.get("indent", 0)
sys.stdout.write("%*s%s%s\n" % (2 * indent, "",
LOG_HEADERS.get(indent, " "), msg))
sys.stdout.flush()
......@@ -564,8 +565,8 @@ class Burner(object):
Log(msg, indent=2)
op = opcodes.OpInstanceCreate(instance_name=instance,
disks = [ {"size": size}
for size in self.disk_size],
disks=[{"size": size}
for size in self.disk_size],
disk_template=self.opts.disk_template,
nics=self.opts.nics,
mode=constants.INSTANCE_CREATE,
......@@ -719,8 +720,8 @@ class Burner(object):
ignore_failures=True)
imp_dir = utils.PathJoin(constants.EXPORT_DIR, full_name)
imp_op = opcodes.OpInstanceCreate(instance_name=instance,
disks = [ {"size": size}
for size in self.disk_size],
disks=[{"size": size}
for size in self.disk_size],
disk_template=self.opts.disk_template,
nics=self.opts.nics,
mode=constants.INSTANCE_IMPORT,
......@@ -996,7 +997,7 @@ class Burner(object):
if opts.do_replace1 and opts.disk_template in constants.DTS_INT_MIRROR:
self.BurnReplaceDisks1D8()
if (opts.do_replace2 and len(self.nodes) > 2 and
opts.disk_template in constants.DTS_INT_MIRROR) :
opts.disk_template in constants.DTS_INT_MIRROR):
self.BurnReplaceDisks2()
if (opts.disk_template in constants.DTS_GROWABLE and
......
......@@ -134,6 +134,7 @@ class Merger(object):
constants.INSTST_RUNNING,
constants.INSTST_ERRORUP,
])
def __init__(self, clusters, pause_period, groups, restart, params,
stop_instances):
"""Initialize object with sane defaults and infos required.
......@@ -160,7 +161,6 @@ class Merger(object):
if self.restart == _RESTART_UP:
raise NotImplementedError
def Setup(self):
"""Sets up our end so we can do the merger.
......
......@@ -338,7 +338,7 @@ def RunRemoteCommand(connection, command, logfile):
WriteLog("SUCCESS: command output follows", logfile)
for line in output.split("\n"):
WriteLog("output = %s" %line, logfile)
WriteLog("output = %s" % line, logfile)
WriteLog("command execution completed", logfile)
session.close()
......
......@@ -85,7 +85,8 @@ PART_RE = re.compile("^((?:h|s|m|ub)d[a-z]{1,2})[0-9]+$")
#: Minimum partition size to be considered (1 GB)
PART_MINSIZE = 1024 * 1024 * 1024
MBR_MAX_SIZE = 2 * 10**12
MBR_MAX_SIZE = 2 * (10 ** 12)
class Error(Exception):
"""Generic exception"""
......@@ -192,7 +193,6 @@ def ParseOptions():
action="store_true", default=False,
help="use sfdisk instead of parted")
options, args = parser.parse_args()
if len(args) != 1:
Usage()
......@@ -232,7 +232,7 @@ def SysfsName(disk):
match = PART_RE.match(disk)
if match:
# this is a partition, which resides in /sys/block under a different name
disk = "%s/%s" % (match.group(1), disk)
disk = "%s/%s" % (match.group(1), disk)
return "/sys/block/%s" % disk
......@@ -776,7 +776,7 @@ def PartitionDisk(name, use_sfdisk):
result = ExecCommand("parted -s /dev/%s mklabel %s" % (name, label_type))
if result.failed:
raise OperationalError("Critical: failed to create %s label on %s" %
(label_type,name))
(label_type, name))
result = ExecCommand("parted -s /dev/%s mkpart pri ext2 1 100%%" % name)
if result.failed:
raise OperationalError("Critical: failed to create partition on %s" %
......@@ -892,7 +892,6 @@ def BootStrap():
" LV count: %s, size: %s, free: %s." %
(vgname, lv_count, vg_size, vg_free))
disklist = ValidateDiskList(options)
for disk in disklist:
......
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