Revision b459a848 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
21 | 21 |
|
22 | 22 |
"""Module implementing the master-side code.""" |
23 | 23 |
|
24 |
# pylint: disable-msg=W0201,C0302
|
|
24 |
# pylint: disable=W0201,C0302 |
|
25 | 25 |
|
26 | 26 |
# W0201 since most LU attributes are defined in CheckPrereq or similar |
27 | 27 |
# functions |
... | ... | |
60 | 60 |
from ganeti import opcodes |
61 | 61 |
from ganeti import ht |
62 | 62 |
|
63 |
import ganeti.masterd.instance # pylint: disable-msg=W0611
|
|
63 |
import ganeti.masterd.instance # pylint: disable=W0611 |
|
64 | 64 |
|
65 | 65 |
|
66 | 66 |
class ResultWithJobs: |
... | ... | |
131 | 131 |
# Used to force good behavior when calling helper functions |
132 | 132 |
self.recalculate_locks = {} |
133 | 133 |
# logging |
134 |
self.Log = processor.Log # pylint: disable-msg=C0103
|
|
135 |
self.LogWarning = processor.LogWarning # pylint: disable-msg=C0103
|
|
136 |
self.LogInfo = processor.LogInfo # pylint: disable-msg=C0103
|
|
137 |
self.LogStep = processor.LogStep # pylint: disable-msg=C0103
|
|
134 |
self.Log = processor.Log # pylint: disable=C0103 |
|
135 |
self.LogWarning = processor.LogWarning # pylint: disable=C0103 |
|
136 |
self.LogInfo = processor.LogInfo # pylint: disable=C0103 |
|
137 |
self.LogStep = processor.LogStep # pylint: disable=C0103 |
|
138 | 138 |
# support for dry-run |
139 | 139 |
self.dry_run_result = None |
140 | 140 |
# support for generic debug attribute |
... | ... | |
322 | 322 |
""" |
323 | 323 |
# API must be kept, thus we ignore the unused argument and could |
324 | 324 |
# be a function warnings |
325 |
# pylint: disable-msg=W0613,R0201
|
|
325 |
# pylint: disable=W0613,R0201 |
|
326 | 326 |
return lu_result |
327 | 327 |
|
328 | 328 |
def _ExpandAndLockInstance(self): |
... | ... | |
390 | 390 |
del self.recalculate_locks[locking.LEVEL_NODE] |
391 | 391 |
|
392 | 392 |
|
393 |
class NoHooksLU(LogicalUnit): # pylint: disable-msg=W0223
|
|
393 |
class NoHooksLU(LogicalUnit): # pylint: disable=W0223 |
|
394 | 394 |
"""Simple LU which runs no hooks. |
395 | 395 |
|
396 | 396 |
This LU is intended as a parent for other LogicalUnits which will |
... | ... | |
757 | 757 |
try: |
758 | 758 |
hm.RunPhase(constants.HOOKS_PHASE_POST, nodes=[node_name]) |
759 | 759 |
except: |
760 |
# pylint: disable-msg=W0702
|
|
760 |
# pylint: disable=W0702 |
|
761 | 761 |
lu.LogWarning("Errors occurred running hooks on %s" % node_name) |
762 | 762 |
|
763 | 763 |
|
... | ... | |
1087 | 1087 |
} |
1088 | 1088 |
if override: |
1089 | 1089 |
args.update(override) |
1090 |
return _BuildInstanceHookEnv(**args) # pylint: disable-msg=W0142
|
|
1090 |
return _BuildInstanceHookEnv(**args) # pylint: disable=W0142 |
|
1091 | 1091 |
|
1092 | 1092 |
|
1093 | 1093 |
def _AdjustCandidatePool(lu, exceptions): |
... | ... | |
1371 | 1371 |
try: |
1372 | 1372 |
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, |
1373 | 1373 |
utils.ReadFile(filename)) |
1374 |
except Exception, err: # pylint: disable-msg=W0703
|
|
1374 |
except Exception, err: # pylint: disable=W0703 |
|
1375 | 1375 |
return (LUClusterVerifyConfig.ETYPE_ERROR, |
1376 | 1376 |
"Failed to load X509 certificate %s: %s" % (filename, err)) |
1377 | 1377 |
|
... | ... | |
1486 | 1486 |
if args: |
1487 | 1487 |
msg = msg % args |
1488 | 1488 |
# then format the whole message |
1489 |
if self.op.error_codes: # This is a mix-in. pylint: disable-msg=E1101
|
|
1489 |
if self.op.error_codes: # This is a mix-in. pylint: disable=E1101 |
|
1490 | 1490 |
msg = "%s:%s:%s:%s:%s" % (ltype, etxt, itype, item, msg) |
1491 | 1491 |
else: |
1492 | 1492 |
if item: |
... | ... | |
1495 | 1495 |
item = "" |
1496 | 1496 |
msg = "%s: %s%s: %s" % (ltype, itype, item, msg) |
1497 | 1497 |
# and finally report it via the feedback_fn |
1498 |
self._feedback_fn(" - %s" % msg) # Mix-in. pylint: disable-msg=E1101
|
|
1498 |
self._feedback_fn(" - %s" % msg) # Mix-in. pylint: disable=E1101 |
|
1499 | 1499 |
|
1500 | 1500 |
def _ErrorIf(self, cond, *args, **kwargs): |
1501 | 1501 |
"""Log an error message if the passed condition is True. |
1502 | 1502 |
|
1503 | 1503 |
""" |
1504 | 1504 |
cond = (bool(cond) |
1505 |
or self.op.debug_simulate_errors) # pylint: disable-msg=E1101
|
|
1505 |
or self.op.debug_simulate_errors) # pylint: disable=E1101 |
|
1506 | 1506 |
if cond: |
1507 | 1507 |
self._Error(*args, **kwargs) |
1508 | 1508 |
# do not mark the operation as failed for WARN cases only |
... | ... | |
1539 | 1539 |
for group in groups) |
1540 | 1540 |
|
1541 | 1541 |
# Fix up all parameters |
1542 |
for op in itertools.chain(*jobs): # pylint: disable-msg=W0142
|
|
1542 |
for op in itertools.chain(*jobs): # pylint: disable=W0142 |
|
1543 | 1543 |
op.debug_simulate_errors = self.op.debug_simulate_errors |
1544 | 1544 |
op.verbose = self.op.verbose |
1545 | 1545 |
op.error_codes = self.op.error_codes |
... | ... | |
1801 | 1801 |
|
1802 | 1802 |
""" |
1803 | 1803 |
node = ninfo.name |
1804 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
1804 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
1805 | 1805 |
|
1806 | 1806 |
# main result, nresult should be a non-empty dict |
1807 | 1807 |
test = not nresult or not isinstance(nresult, dict) |
... | ... | |
1870 | 1870 |
|
1871 | 1871 |
""" |
1872 | 1872 |
node = ninfo.name |
1873 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
1873 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
1874 | 1874 |
|
1875 | 1875 |
ntime = nresult.get(constants.NV_TIME, None) |
1876 | 1876 |
try: |
... | ... | |
1903 | 1903 |
return |
1904 | 1904 |
|
1905 | 1905 |
node = ninfo.name |
1906 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
1906 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
1907 | 1907 |
|
1908 | 1908 |
# checks vg existence and size > 20G |
1909 | 1909 |
vglist = nresult.get(constants.NV_VGLIST, None) |
... | ... | |
1940 | 1940 |
return |
1941 | 1941 |
|
1942 | 1942 |
node = ninfo.name |
1943 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
1943 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
1944 | 1944 |
|
1945 | 1945 |
missing = nresult.get(constants.NV_BRIDGES, None) |
1946 | 1946 |
test = not isinstance(missing, list) |
... | ... | |
1959 | 1959 |
|
1960 | 1960 |
""" |
1961 | 1961 |
node = ninfo.name |
1962 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
1962 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
1963 | 1963 |
|
1964 | 1964 |
test = constants.NV_NODELIST not in nresult |
1965 | 1965 |
_ErrorIf(test, self.ENODESSH, node, |
... | ... | |
2000 | 2000 |
available on the instance's node. |
2001 | 2001 |
|
2002 | 2002 |
""" |
2003 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2003 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2004 | 2004 |
node_current = instanceconfig.primary_node |
2005 | 2005 |
|
2006 | 2006 |
node_vol_should = {} |
... | ... | |
2200 | 2200 |
|
2201 | 2201 |
""" |
2202 | 2202 |
node = ninfo.name |
2203 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2203 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2204 | 2204 |
|
2205 | 2205 |
if drbd_helper: |
2206 | 2206 |
helper_result = nresult.get(constants.NV_DRBDHELPER, None) |
... | ... | |
2259 | 2259 |
|
2260 | 2260 |
""" |
2261 | 2261 |
node = ninfo.name |
2262 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2262 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2263 | 2263 |
|
2264 | 2264 |
remote_os = nresult.get(constants.NV_OSLIST, None) |
2265 | 2265 |
test = (not isinstance(remote_os, list) or |
... | ... | |
2300 | 2300 |
|
2301 | 2301 |
""" |
2302 | 2302 |
node = ninfo.name |
2303 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2303 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2304 | 2304 |
|
2305 | 2305 |
assert not nimg.os_fail, "Entered _VerifyNodeOS with failed OS rpc?" |
2306 | 2306 |
|
... | ... | |
2370 | 2370 |
|
2371 | 2371 |
""" |
2372 | 2372 |
node = ninfo.name |
2373 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2373 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2374 | 2374 |
|
2375 | 2375 |
nimg.lvm_fail = True |
2376 | 2376 |
lvdata = nresult.get(constants.NV_LVLIST, "Missing LV data") |
... | ... | |
2418 | 2418 |
|
2419 | 2419 |
""" |
2420 | 2420 |
node = ninfo.name |
2421 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2421 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2422 | 2422 |
|
2423 | 2423 |
# try to read free memory (from the hypervisor) |
2424 | 2424 |
hv_info = nresult.get(constants.NV_HVINFO, None) |
... | ... | |
2460 | 2460 |
list of tuples (success, payload) |
2461 | 2461 |
|
2462 | 2462 |
""" |
2463 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2463 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2464 | 2464 |
|
2465 | 2465 |
node_disks = {} |
2466 | 2466 |
node_disks_devonly = {} |
... | ... | |
2568 | 2568 |
"""Verify integrity of the node group, performing various test on nodes. |
2569 | 2569 |
|
2570 | 2570 |
""" |
2571 |
# This method has too many local variables. pylint: disable-msg=R0914
|
|
2571 |
# This method has too many local variables. pylint: disable=R0914 |
|
2572 | 2572 |
feedback_fn("* Verifying group '%s'" % self.group_info.name) |
2573 | 2573 |
|
2574 | 2574 |
if not self.my_node_names: |
... | ... | |
2577 | 2577 |
return True |
2578 | 2578 |
|
2579 | 2579 |
self.bad = False |
2580 |
_ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
|
|
2580 |
_ErrorIf = self._ErrorIf # pylint: disable=C0103 |
|
2581 | 2581 |
verbose = self.op.verbose |
2582 | 2582 |
self._feedback_fn = feedback_fn |
2583 | 2583 |
|
... | ... | |
4419 | 4419 |
"""Logical unit for querying nodes. |
4420 | 4420 |
|
4421 | 4421 |
""" |
4422 |
# pylint: disable-msg=W0142
|
|
4422 |
# pylint: disable=W0142 |
|
4423 | 4423 |
REQ_BGL = False |
4424 | 4424 |
|
4425 | 4425 |
def CheckArguments(self): |
... | ... | |
4620 | 4620 |
for instance_name in lu.owned_locks(locking.LEVEL_INSTANCE) |
4621 | 4621 |
for group_uuid in lu.cfg.GetInstanceNodeGroups(instance_name)) |
4622 | 4622 |
elif level == locking.LEVEL_NODE: |
4623 |
lu._LockInstancesNodes() # pylint: disable-msg=W0212
|
|
4623 |
lu._LockInstancesNodes() # pylint: disable=W0212 |
|
4624 | 4624 |
|
4625 | 4625 |
@staticmethod |
4626 | 4626 |
def _CheckGroupLocks(lu): |
... | ... | |
4721 | 4721 |
"""Query for resources/items of a certain kind. |
4722 | 4722 |
|
4723 | 4723 |
""" |
4724 |
# pylint: disable-msg=W0142
|
|
4724 |
# pylint: disable=W0142 |
|
4725 | 4725 |
REQ_BGL = False |
4726 | 4726 |
|
4727 | 4727 |
def CheckArguments(self): |
... | ... | |
4743 | 4743 |
"""Query for resources/items of a certain kind. |
4744 | 4744 |
|
4745 | 4745 |
""" |
4746 |
# pylint: disable-msg=W0142
|
|
4746 |
# pylint: disable=W0142 |
|
4747 | 4747 |
REQ_BGL = False |
4748 | 4748 |
|
4749 | 4749 |
def CheckArguments(self): |
... | ... | |
4990 | 4990 |
# later in the procedure; this also means that if the re-add |
4991 | 4991 |
# fails, we are left with a non-offlined, broken node |
4992 | 4992 |
if self.op.readd: |
4993 |
new_node.drained = new_node.offline = False # pylint: disable-msg=W0201
|
|
4993 |
new_node.drained = new_node.offline = False # pylint: disable=W0201 |
|
4994 | 4994 |
self.LogInfo("Readding a node, the offline/drained flags were reset") |
4995 | 4995 |
# if we demote the node, we do cleanup later in the procedure |
4996 | 4996 |
new_node.master_candidate = self.master_candidate |
... | ... | |
6550 | 6550 |
"""Logical unit for querying instances. |
6551 | 6551 |
|
6552 | 6552 |
""" |
6553 |
# pylint: disable-msg=W0142
|
|
6553 |
# pylint: disable=W0142 |
|
6554 | 6554 |
REQ_BGL = False |
6555 | 6555 |
|
6556 | 6556 |
def CheckArguments(self): |
... | ... | |
8515 | 8515 |
|
8516 | 8516 |
joinargs.append(self.op.instance_name) |
8517 | 8517 |
|
8518 |
# pylint: disable-msg=W0142
|
|
8518 |
# pylint: disable=W0142 |
|
8519 | 8519 |
self.instance_file_storage_dir = utils.PathJoin(*joinargs) |
8520 | 8520 |
|
8521 | 8521 |
def CheckPrereq(self): |
... | ... | |
9674 | 9674 |
self.lu.LogWarning("Can't remove old LV: %s" % msg, |
9675 | 9675 |
hint="remove unused LVs manually") |
9676 | 9676 |
|
9677 |
def _ExecDrbd8DiskOnly(self, feedback_fn): # pylint: disable-msg=W0613
|
|
9677 |
def _ExecDrbd8DiskOnly(self, feedback_fn): # pylint: disable=W0613 |
|
9678 | 9678 |
"""Replace a disk on the primary or secondary for DRBD 8. |
9679 | 9679 |
|
9680 | 9680 |
The algorithm for replace is quite complicated: |
... | ... | |
12436 | 12436 |
return ResultWithJobs(jobs) |
12437 | 12437 |
|
12438 | 12438 |
|
12439 |
class TagsLU(NoHooksLU): # pylint: disable-msg=W0223
|
|
12439 |
class TagsLU(NoHooksLU): # pylint: disable=W0223 |
|
12440 | 12440 |
"""Generic tags LU. |
12441 | 12441 |
|
12442 | 12442 |
This is an abstract class which is the parent of all the other tags LUs. |
... | ... | |
12696 | 12696 |
# Wait for client to close |
12697 | 12697 |
try: |
12698 | 12698 |
try: |
12699 |
# pylint: disable-msg=E1101
|
|
12699 |
# pylint: disable=E1101 |
|
12700 | 12700 |
# Instance of '_socketobject' has no ... member |
12701 | 12701 |
conn.settimeout(cls._CLIENT_CONFIRM_TIMEOUT) |
12702 | 12702 |
conn.recv(1) |
... | ... | |
12793 | 12793 |
easy usage |
12794 | 12794 |
|
12795 | 12795 |
""" |
12796 |
# pylint: disable-msg=R0902
|
|
12796 |
# pylint: disable=R0902 |
|
12797 | 12797 |
# lots of instance attributes |
12798 | 12798 |
|
12799 | 12799 |
def __init__(self, cfg, rpc, mode, **kwargs): |
... | ... | |
13130 | 13130 |
|
13131 | 13131 |
_STRING_LIST = ht.TListOf(ht.TString) |
13132 | 13132 |
_JOB_LIST = ht.TListOf(ht.TListOf(ht.TStrictDict(True, False, { |
13133 |
# pylint: disable-msg=E1101
|
|
13133 |
# pylint: disable=E1101 |
|
13134 | 13134 |
# Class '...' has no 'OP_ID' member |
13135 | 13135 |
"OP_ID": ht.TElemOf([opcodes.OpInstanceFailover.OP_ID, |
13136 | 13136 |
opcodes.OpInstanceMigrate.OP_ID, |
Also available in: Unified diff