[XEND] Make python-pam warning only appear if using XenAPI
authorAlastair Tse <atse@xensource.com>
Wed, 31 Jan 2007 12:58:41 +0000 (12:58 +0000)
committerAlastair Tse <atse@xensource.com>
Wed, 31 Jan 2007 12:58:41 +0000 (12:58 +0000)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendAuthSessions.py

index 5c9a4e9a2f604ddc24015a843e6889c4077f66f9..769c66f3facb6a1fec9b4af2312d7273c1ae23d4 100644 (file)
@@ -21,11 +21,6 @@ from xen.xend import uuid
 from xen.xend.XendError import *
 from xen.xend.XendLogging import log
 
-try:
-    import PAM
-except ImportError:
-    log.warn("python-pam is required for XenAPI support.")
-
 class XendAuthSessions:
     """Keeps track of Xen API Login Sessions using PAM.
 
@@ -80,7 +75,11 @@ class XendAuthSessions:
         """
         pam_auth = None
         try:
+            import PAM
             pam_auth = PAM.pam()
+        except ImportError:
+            log.warn("python-pam is required for XenAPI support.")
+            return False
         except NameError:
             # if PAM doesn't exist, let's ignore it
             return False