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

Fix slapos-theia.

parent f965e32c
...@@ -11,11 +11,16 @@ OCF_NOT_RUNNING = 7 ...@@ -11,11 +11,16 @@ OCF_NOT_RUNNING = 7
action = sys.argv[1] 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') part_id = os.getenv('OCF_RESKEY_part_id')
slappart = 'slappart%s' % part_id slappart = 'slappart%s' % part_id
slappart_b = slappart.encode('utf8') slappart_b = slappart.encode('utf8')
slapuser = 'slapuser%s' % part_id 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 #kumofs_gateway,kumofs_manager,kumofs_server,mariadb,zeo,zope,haproxy
...@@ -46,12 +51,12 @@ def isTheiaStopped(): ...@@ -46,12 +51,12 @@ def isTheiaStopped():
def runSlapOSInTheia(*args): def runSlapOSInTheia(*args):
return runCommand('sudo', '-u', slapuser, return runCommand('sudo', '-u', slapuser,
'/srv/slapgrid/%s/srv/runner/bin/slapos' % slappart, '%s/%s/srv/runner/bin/slapos' % (instance_root, slappart),
*args) *args)
def checkAppStatus(target_status): def checkAppStatus(target_status):
completed_process = runSlapOSInTheia('node') 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': if target_status == 'STOPPED':
return True return True
else: else:
...@@ -87,6 +92,8 @@ def isAppStopped(): ...@@ -87,6 +92,8 @@ def isAppStopped():
def monitor(): def monitor():
result = OCF_ERR_GENERIC result = OCF_ERR_GENERIC
if not os.path.exists(instance_root):
result = OCF_NOT_RUNNING
try: try:
if isTheiaRunning() and isAppRunning(): if isTheiaRunning() and isAppRunning():
result = OCF_SUCCESS result = OCF_SUCCESS
...@@ -136,6 +143,13 @@ This is the resource agent for SlapOS Theia. ...@@ -136,6 +143,13 @@ This is the resource agent for SlapOS Theia.
<shortdesc lang="en">Manages SlapOS Theia instance</shortdesc> <shortdesc lang="en">Manages SlapOS Theia instance</shortdesc>
<parameters> <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"> <parameter name="part_id" unique="1" required="1">
<longdesc> <longdesc>
Computer Partition ID, slappartX 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