Commit c37434ae authored by Yusei Tahara's avatar Yusei Tahara

Change parameters. Add `serious_services` and `autostart_services`.

parent 95a2a43e
......@@ -17,10 +17,14 @@ 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 = []
services_text = os.getenv('OCF_RESKEY_services', None)
if services_text:
service_list = services_text.split(',')
serious_service_list = []
serious_services_text = os.getenv('OCF_RESKEY_serious_services', None)
if serious_services_text:
serious_service_list = serious_services_text.split(',')
autostart_service_list = []
autostart_services_text = os.getenv('OCF_RESKEY_autostart_services', None)
if autostart_services_text:
autostart_service_list = autostart_services_text.split(',')
#kumofs_gateway,kumofs_manager,kumofs_server,mariadb,zeo,zope,haproxy
......@@ -61,27 +65,25 @@ def checkAppStatus(target_status):
return True
else:
return False
error_list = []
service_status_dict = {}
for service in service_list:
service_status_dict[service] = []
service_data_list = []
for line in completed_process.stdout.split(b'\n'):
if not line:
continue
split_line = splitLine(line)
if split_line[0].decode('utf8') == 'watchdog':
continue
service_id = split_line[0].decode('utf8')
service_name = split_line[0].split(b':')[1].split(b'-')[0].decode('utf8')
current_status = split_line[1].decode('utf8')
if service_name in service_status_dict:
service_status_dict[service_name].append(current_status)
service_data_list.append((service_id, service_name, current_status))
for service_id, service_name, current_status in service_data_list:
if service_name in serious_service_list:
if current_status != target_status:
error_list.append(line)
if error_list:
return False
for service in service_status_dict:
if set(service_status_dict[service]) != set([target_status]):
return False
return False
if target_status == 'RUNNING' and autostart_service_list:
for service_id, service_name, current_status in service_data_list:
if current_status == 'EXITED' and service_name in autostart_service_list:
runSlapOSInTheia('node', 'start', service_id)
return True
def isAppRunning():
......@@ -157,11 +159,21 @@ Computer Partition ID, slappartX
<shortdesc>Partition ID</shortdesc>
<content type="integer"/>
</parameter>
<parameter name="services" unique="0" required="1">
<parameter name="serious_services" unique="0" required="0">
<longdesc>
Serious service names separated by comma
If serious service fails, then this resource is considered as failed.
</longdesc>
<shortdesc>Serious service names</shortdesc>
<content type="string"/>
</parameter>
<parameter name="autostart_services" unique="0" required="0">
<longdesc>
Service names separated by comma
Auto-start service names separated by comma
If auto-start service becomes `EXITED`, then `slapos node start` is executed
automatically and it is not considered as failed.
</longdesc>
<shortdesc>Service names</shortdesc>
<shortdesc>Auto-start service names</shortdesc>
<content type="string"/>
</parameter>
</parameters>
......@@ -169,7 +181,7 @@ Service names separated by comma
<actions>
<action name="start" timeout="60s" />
<action name="stop" timeout="60s" />
<action name="monitor" depth="0" timeout="20s" interval="60s" />
<action name="monitor" depth="0" timeout="30s" interval="60s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
......
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