Beispiel #1
0
#
# checkHost
# Receives:
#   host -> ip dom0
#
def checkHost(host):
	try:
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect((host, int(xenPort)))
		sock.close()
		return 1
	except socket.error, err:
		return 0

#
# XOM - Main
#
dbManager = DBManager()
for dom0 in dbManager.returnDom0s():
	dom0Manager = Dom0Manager()
	if (checkHost(dom0[5])):
		xenApi = xmlrpclib.Server("http://" + dom0[5] + ":" + xenPort)
		session = Session(xenUser, xenPassword, xenApi).authentication()
		print "[xom] dom0 " + dom0[5] + " up."
		dom0Manager.updateDom0(dom0[5],"up")
		if(session['Status'] == "Success"):
			dom0Manager.registerVMs(xenApi, session, dom0[5])
	else:
		print "[xom] dom0 " + dom0[5] + " down."
		dom0Manager.updateDom0(dom0[5],"down")