diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6bc8e71281b9495f7e537bc840a3646a32b89074..c3150a0705dd29b9b5c019a2ee20538b47b6e2ea 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -957,9 +957,8 @@ def _RunPostHook(lu, node_name): hm = lu.proc.BuildHooksManager(lu) try: hm.RunPhase(constants.HOOKS_PHASE_POST, nodes=[node_name]) - except: - # pylint: disable=W0702 - lu.LogWarning("Errors occurred running hooks on %s" % node_name) + except Exception, err: # pylint: disable=W0703 + lu.LogWarning("Errors occurred running hooks on %s: %s" % (node_name, err)) def _CheckOutputFields(static, dynamic, selected): diff --git a/lib/netutils.py b/lib/netutils.py index ac87d4d79c90c0b5fca7b6d14992ee6f1926e6b5..42f8e8ba12547686f0b7ae8588b8e5b8f48a676b 100644 --- a/lib/netutils.py +++ b/lib/netutils.py @@ -1,7 +1,7 @@ # # -# Copyright (C) 2010 Google Inc. +# Copyright (C) 2010, 2011, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -280,8 +280,8 @@ def TcpPing(target, port, timeout=10, live_port_needed=False, source=None): if source is not None: try: sock.bind((source, 0)) - except socket.error, (errcode, _): - if errcode == errno.EADDRNOTAVAIL: + except socket.error, err: + if err[0] == errno.EADDRNOTAVAIL: success = False sock.settimeout(timeout) @@ -292,8 +292,8 @@ def TcpPing(target, port, timeout=10, live_port_needed=False, source=None): success = True except socket.timeout: success = False - except socket.error, (errcode, _): - success = (not live_port_needed) and (errcode == errno.ECONNREFUSED) + except socket.error, err: + success = (not live_port_needed) and (err[0] == errno.ECONNREFUSED) return success diff --git a/lib/watcher/__init__.py b/lib/watcher/__init__.py index 7cc3ce35abe2a9bf1dcdf5590da21d494ce50838..20b3a204bb119b3f348b5ff4e12301d4658cacbb 100644 --- a/lib/watcher/__init__.py +++ b/lib/watcher/__init__.py @@ -51,6 +51,7 @@ from ganeti import ssconf from ganeti import ht import ganeti.rapi.client # pylint: disable=W0611 +from ganeti.rapi.client import UsesRapiClient from ganeti.watcher import nodemaint from ganeti.watcher import state @@ -569,7 +570,7 @@ def _CheckMaster(cl): raise NotMasterError("This is not the master node") -@rapi.client.UsesRapiClient +@UsesRapiClient def _GlobalWatcher(opts): """Main function for global watcher. diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 94518128def47432db11da757bc920a71bd789bb..de9c194d14977663846b5b0f7d2f70331c30a674 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -44,10 +44,11 @@ import qa_tags import qa_utils from ganeti import utils -from ganeti import rapi +from ganeti import rapi # pylint: disable=W0611 from ganeti import constants import ganeti.rapi.client # pylint: disable=W0611 +from ganeti.rapi.client import UsesRapiClient def _FormatHeader(line, end=72): @@ -544,7 +545,7 @@ def RunQa(): RunTestIf("cluster-destroy", qa_cluster.TestClusterDestroy) -@rapi.client.UsesRapiClient +@UsesRapiClient def main(): """Main program. diff --git a/qa/qa_config.py b/qa/qa_config.py index a99dac968fc1b2093f158150959b65134759e707..635aec8943c347b89e05a92f7b7f7af878305182 100644 --- a/qa/qa_config.py +++ b/qa/qa_config.py @@ -80,7 +80,7 @@ def Validate(): def get(name, default=None): - return cfg.get(name, default) + return cfg.get(name, default) # pylint: disable=E1103 class Either: @@ -149,7 +149,7 @@ def TestEnabled(tests, _cfg=None): _cfg = cfg # Get settings for all tests - cfg_tests = _cfg.get("tests", {}) + cfg_tests = _cfg.get("tests", {}) # pylint: disable=E1103 # Get default setting default = cfg_tests.get("default", True) @@ -162,7 +162,7 @@ def GetInstanceCheckScript(): """Returns path to instance check script or C{None}. """ - return cfg.get(_INSTANCE_CHECK_KEY, None) + return cfg.get(_INSTANCE_CHECK_KEY, None) # pylint: disable=E1103 def GetEnabledHypervisors(): diff --git a/tools/move-instance b/tools/move-instance index 168ad811fb7789c05cca285bbc612eb9ad38f82d..716b00c4d18127858aaac237bbe756d183268781 100755 --- a/tools/move-instance +++ b/tools/move-instance @@ -1,7 +1,7 @@ #!/usr/bin/python # -# Copyright (C) 2010 Google Inc. +# Copyright (C) 2010, 2011, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -42,6 +42,7 @@ from ganeti import rapi import ganeti.rapi.client # pylint: disable=W0611 import ganeti.rapi.client_utils +from ganeti.rapi.client import UsesRapiClient SRC_RAPI_PORT_OPT = \ @@ -836,7 +837,7 @@ def CheckOptions(parser, options, args): return (src_cluster_name, dest_cluster_name, instance_names) -@rapi.client.UsesRapiClient +@UsesRapiClient def main(): """Main routine.