diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 5342d57c..87ee86af 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -15,6 +15,7 @@ # limitations under the License. from datetime import datetime +import errno import json import os.path import pyghmi.constants as pygconst @@ -25,6 +26,7 @@ import pyghmi.ipmi.private.util as util import pyghmi.ipmi.sdr as sdr import pyghmi.util.webclient as webclient import random +import socket import struct import threading import urllib @@ -137,7 +139,9 @@ class IMMClient(object): wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv) try: wc.connect() - except Exception: + except socket.error as se: + if se.errno != errno.ECONNREFUSED: + raise return None adata = urllib.urlencode({'user': self.username, 'password': self.password, @@ -455,7 +459,9 @@ class XCCClient(IMMClient): wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv) try: wc.connect() - except Exception: + except socket.error as se: + if se.errno != errno.ECONNREFUSED: + raise return None adata = json.dumps({'username': self.username, 'password': self.password