Esempio n. 1
0
def task_logs(instance_name, module_id, task_index):
	inst = wok().instance(instance_name)
	if inst is None:
		abort(404)

	module_id = ".".join([inst.root_node_name, module_id])
	
	#if not inst.task_exists(module_id, task_index):
	#	abort(404)

	try:
		task_index = int(task_index)
		
		logs = inst.task_logs(module_id, task_index)
		
		return make_json_response({
			"ok" : True,
			"logs" : logs })
	except Exception as e:
		if wok().conf.get("wok.server.debug", False, dtype=bool):
			raise
		
		return make_json_response({
			"ok" : False,
			"error" :  repr(e)})
Esempio n. 2
0
def instance_state(name):
	inst = wok().instance(name)
	if inst is None:
		abort(404)

	e = inst.to_element()

	return make_json_response(e.to_native())
Esempio n. 3
0
def module_conf(instance_name, module_id):
	inst = wok().instance(instance_name)
	if inst is None:
		abort(404)
	
	#if not inst.module_exists(module_id):
	#	abort(404)

	expanded = bool_arg("expanded", False)
	
	conf = inst.module_conf(module_id, expanded = expanded)

	return make_json_response(conf.to_native())
Esempio n. 4
0
def instance_control(instance_name):
	inst = wok().instance(instance_name)
	if inst is None:
		abort(404)

	action = request.args.get("action")
	if action is None:
		return make_json_response({
			"ok" : False,
			"instance" : instance_name,
			"error" : "'action' argument not specified" })

	if action not in ["start", "pause", "stop", "reset", "reload"]:
		return make_json_response({
			"ok" : False,
			"instance" : instance_name,
			"error" : "Unknown 'action': %s" % action })

	prev_state = str(inst.state)

	try:
		if action == "start":
			inst.start()
		elif action == "pause":
			inst.pause()
		elif action == "stop":
			inst.stop()
		elif action == "reset":
			inst.reset()
		elif action == "reload":
			inst.reload()

		new_state = str(inst.state)

	except Exception as ex:
		return make_json_response({
			"ok" : False,
			"instance" : instance_name,
			"error" : str(ex) })

	return make_json_response({
		"ok" : True,
		"instance" : instance_name,
		"previous_state" : prev_state,
		"current_state" : new_state })
Esempio n. 5
0
def index():
	instances = wok().instances()
	return render_template('monitoring.html', instances=instances)
Esempio n. 6
0
def instance_repr(instance_name):
	inst = wok().instance(instance_name)
	if inst is None:
		abort(404)
	return make_text_response(repr(inst))