diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2011-11-23 07:50:25 -0500 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2011-11-23 07:50:25 -0500 |
commit | c3f2470c4d6d9594764d2cd312f9733dbce77791 (patch) | |
tree | 695af19fd202b9d92a239fd670b6a5dbbf091e5c /src/sbin | |
parent | abec6d84060655052345233a6e27a4379995b103 (diff) | |
download | bcfg2-c3f2470c4d6d9594764d2cd312f9733dbce77791.tar.gz bcfg2-c3f2470c4d6d9594764d2cd312f9733dbce77791.tar.bz2 bcfg2-c3f2470c4d6d9594764d2cd312f9733dbce77791.zip |
made error handling from bcfg2 client more consistent; avoid some
backtraces
Diffstat (limited to 'src/sbin')
-rwxr-xr-x | src/sbin/bcfg2 | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index 5ddfd8791..58f2964f9 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -189,23 +189,21 @@ class Client: if self.setup['profile']: try: proxy.AssertProfile(self.setup['profile']) - except xmlrpclib.Fault: + except Bcfg2.Proxy.ProxyError: + err = sys.exc_info()[1] self.fatal_error("Failed to set client profile") - return(1) + self.logger.error(str(err)) + raise SystemExit(1) try: probe_data = proxy.GetProbes() - except xmlrpclib.Fault: - flt = sys.exc_info()[1] - self.logger.error("Failed to download probes from bcfg2") - self.logger.error(flt.faultString) - raise SystemExit(1) - except (Bcfg2.Proxy.CertificateError, + except (Bcfg2.Proxy.ProxyError, + Bcfg2.Proxy.CertificateError, socket.gaierror, socket.error): - e = sys.exc_info()[1] - self.logger.error("Failed to download probes from bcfg2: %s" - % e) + err = sys.exc_info()[1] + self.logger.error("Failed to download probes from bcfg2: %s" % + err) raise SystemExit(1) times['probe_download'] = time.time() @@ -231,31 +229,33 @@ class Client: if len(probes.findall(".//probe")) > 0: try: # upload probe responses - proxy.RecvProbeData(Bcfg2.Client.XML.tostring(probedata, encoding='UTF-8', xml_declaration=True)) - except: - self.logger.error("Failed to upload probe data", exc_info=1) + proxy.RecvProbeData(Bcfg2.Client.XML.tostring(probedata, + encoding='UTF-8', + xml_declaration=True)) + except Bcfg2.Proxy.ProxyError: + err = sys.exc_info()[1] + self.logger.error("Failed to upload probe data: %s" % err) raise SystemExit(1) times['probe_upload'] = time.time() if self.setup['decision'] in ['whitelist', 'blacklist']: try: - self.setup['decision_list'] = proxy.GetDecisionList( \ - self.setup['decision']) + self.setup['decision_list'] = \ + proxy.GetDecisionList(self.setup['decision']) self.logger.info("Got decision list from server:") self.logger.info(self.setup['decision_list']) - except xmlrpclib.Fault: - f = sys.exc_info()[1] - if f.faultCode == 1: - print("GetDecisionList method not supported by server") - else: - self.logger.error("Failed to de", exc_info=1) + except Bcfg2.Proxy.ProxyError: + err = sys.exc_info()[1] + self.logger.error("Failed to get decision list: %s" % err) raise SystemExit(1) try: rawconfig = proxy.GetConfig().encode('UTF-8') - except xmlrpclib.Fault: - self.logger.error("Failed to download configuration from Bcfg2") + except Bcfg2.Proxy.ProxyError: + err = sys.exc_info()[1] + self.logger.error("Failed to download configuration from " + "Bcfg2: %s" % err) raise SystemExit(2) times['config_download'] = time.time() @@ -327,8 +327,10 @@ class Client: proxy.RecvStats(Bcfg2.Client.XML.tostring(feedback, encoding='UTF-8', xml_declaration=True)) - except xmlrpclib.Fault: - self.logger.error("Failed to upload configuration statistics") + except Bcfg2.Proxy.ProxyError: + err = sys.exc_info()[1] + self.logger.error("Failed to upload configuration statistics: " + "%s" % err) raise SystemExit(2) if __name__ == '__main__': |