Commit 95a2a43e authored by Yusei Tahara's avatar Yusei Tahara

Fix slapos-theia.

parent f965e32c
......@@ -11,11 +11,16 @@ OCF_NOT_RUNNING = 7
action = sys.argv[1]
instance_root = os.getenv('OCF_RESKEY_instance_root') or ''
instance_root_b = instance_root.encode('utf8')
part_id = os.getenv('OCF_RESKEY_part_id')
slappart = 'slappart%s' % part_id
slappart_b = slappart.encode('utf8')
slapuser = 'slapuser%s' % part_id
service_list = os.getenv('OCF_RESKEY_services', '').split(',')
service_list = []
services_text = os.getenv('OCF_RESKEY_services', None)
if services_text:
service_list = services_text.split(',')
#kumofs_gateway,kumofs_manager,kumofs_server,mariadb,zeo,zope,haproxy
......@@ -46,12 +51,12 @@ def isTheiaStopped():
def runSlapOSInTheia(*args):
return runCommand('sudo', '-u', slapuser,
'/srv/slapgrid/%s/srv/runner/bin/slapos' % slappart,
'%s/%s/srv/runner/bin/slapos' % (instance_root, slappart),
*args)
def checkAppStatus(target_status):
completed_process = runSlapOSInTheia('node')
if completed_process.stdout == b'unix:///srv/slapgrid/%s/srv/runner/instance/sv.sock no such file\n' % slappart_b:
if completed_process.stdout == b'unix://%s/%s/srv/runner/instance/sv.sock no such file\n' % (instance_root_b, slappart_b):
if target_status == 'STOPPED':
return True
else:
......@@ -87,6 +92,8 @@ def isAppStopped():
def monitor():
result = OCF_ERR_GENERIC
if not os.path.exists(instance_root):
result = OCF_NOT_RUNNING
try:
if isTheiaRunning() and isAppRunning():
result = OCF_SUCCESS
......@@ -136,6 +143,13 @@ This is the resource agent for SlapOS Theia.
<shortdesc lang="en">Manages SlapOS Theia instance</shortdesc>
<parameters>
<parameter name="instance_root" unique="0" required="1">
<longdesc>
Instance Root Directory Path
</longdesc>
<shortdesc>Instance Root</shortdesc>
<content type="string"/>
</parameter>
<parameter name="part_id" unique="1" required="1">
<longdesc>
Computer Partition ID, slappartX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment