Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
IsXAPIRunning check for /run/pid and /var/run/pid based identificatio…
Browse files Browse the repository at this point in the history
…n of running xapi
  • Loading branch information
jamesbulpin authored and andyhhp committed Jan 24, 2014
1 parent a1dc181 commit 8f2c1ce
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import XenAPI

import commands, re, shutil, sys, tempfile, socket
import commands, re, shutil, sys, tempfile, socket, os
from pprint import pprint
from simpleconfig import SimpleConfigFile

Expand Down Expand Up @@ -1051,10 +1051,28 @@ def PurgeVBDs(self):

def IsXAPIRunning(self):
try:
if ShellPipe('/sbin/pidof', '-s', '/opt/xensource/bin/xapi').CallRC() == 0:
retVal = True
pidfile = None
if os.path.exists("/run/xapi.pid"):
pidfile = "/run/xapi.pid"
elif os.path.exists("/var/run/xapi.pid"):
pidfile = "/var/run/xapi.pid"
if pidfile:
# Look for any "xapi" running
pid = file(pidfile).read().strip()
exelink = "/proc/%s/exe" % (pid)
if os.path.exists(exelink):
if os.path.basename(os.readlink(exelink)) == "xapi":
retVal = True
else:
retVal = False
else:
retVal = False
else:
retVal = False
# Look for XenServer/XCP appliance xapi
if ShellPipe('/sbin/pidof', '-s', '/opt/xensource/bin/xapi').CallRC() == 0:
retVal = True
else:
retVal = False
except:
retVal = False
return retVal
Expand Down

0 comments on commit 8f2c1ce

Please sign in to comment.