File: //usr/lib/python2.7/site-packages/lap/xen_ldap.py
#!/usr/bin/python
import socket
import subprocess
try:
from xenapi import XenAPI
except:
import XenAPI
socket.setdefaulttimeout(10)
def __run__(params):
xapi = XenAPI.xapi_local()
xapi.login_with_password("", "")
hostname = socket.gethostname()
host_ref = xapi.xenapi.host.get_by_name_label(hostname)
if len(host_ref) > 1:
xapi.xenapi.session.logout()
return "UNKNOWN: Hostname duplicated"
host = xapi.xenapi.host.get_record(host_ref[0])
xapi.xenapi.session.logout()
if host["external_auth_type"].lower() == "ad":
return [0, "OK: External Auth Type is AD"]
else:
return [2, "CRITICAL: Host is out of AD"]