Beispiel #1
0
def debug(request):
	if request.method == 'POST':
		worker.start_worker()
	butler = worker.get_current_butler()
	job = butler.current_job 
	applications = worker.get_applications()
	
	post_url = BUTLER_MASTER_URL + "new/job/"
	return locals()
Beispiel #2
0
def callback(request, application):
	if request.method == 'GET':
		mode = request.GET['hub.mode']
		topic = request.GET['hub.topic']
		challenge = request.GET['hub.challenge']
		lease_seconds = request.GET.get('hub.lease_seconds')
		verify_token = request.GET.get('hub.verify_token', '')
		if mode == 'subscribe':
			from worker import get_applications
			applications = get_applications()
			if application not in applications:
				raise Http404 
			if verify_token != worker.get_application_key(application):
				raise Http404
		return HttpResponse(challenge, content_type='text/plain')
	elif request.method == 'POST':
		worker.start_worker()
		return HttpResponse('')
	return Http404
Beispiel #3
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    start_worker()
    authn_policy = AuthTktAuthenticationPolicy('blargon5',
                                               callback=groupfinder,
                                               hashalg='sha512',
                                               timeout=900)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
                          root_factory='senex.models.RootFactory')
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.add_request_method(get_user, 'user', reify=True)
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)

    config.add_route('view_main_page', '/')
    config.add_route('return_status', '/senexstatus')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    config.add_route('add_old', '/olds/add')
    config.add_route('view_old', '/olds/{oldname}')
    config.add_route('edit_old', '/olds/{oldname}/edit')
    config.add_route('stop_old', '/olds/{oldname}/stop')
    config.add_route('start_old', '/olds/{oldname}/start')

    config.add_route('add_user', '/users/add')
    config.add_route('view_user', '/users/{username}')
    config.add_route('edit_user', '/users/{username}/edit')

    config.scan()
    return config.make_wsgi_app()
Beispiel #4
0
#!/usr/bin/env python

import logging

from worker import start_worker

logging.basicConfig(level=logging.DEBUG)

if __name__ == '__main__':
    start_worker()
Beispiel #5
0
# test if task executes with exit status 0
print('Testing docker_task explicitly...')
assert docker_task(args) == 0
print('Done')

# test if task gets enqueued to the queue
assert q.push('test_task', args) == 0
assert q.push('test_task', args) == 0
assert q.push('test_task', args) == 0
assert q.push('test_task', args) == 0

# test if task has enqueued
assert q.q_size() == n + 4

# test if worker executes 3 tasks with given resources and exit with status 0
# since the required cpu of the tasks is 20% and available is 50% only 2 tasks
# should be executed parallely and 3rd will be executed only when one of
# the earlier two is completed. This can be verified through log timestamp.
assert start_worker(max=3, resources=[50, 18000000]) == 0

# test if task has removed from queue
assert q.q_size() == n + 1

# test if pop and front works
assert not q.front() is None
assert not q.pop() is None

# test if pop reduced the size of queue
assert q.q_size() == n
Beispiel #6
0
            elif cmd == "stop":
                #read server_id from the paylaoad
                server_id = commands[1]
                vm_list = cloud_cop_obj.stop_server(server_id)
                stop_CL(server_id)

            elif cmd == "extend":
                #read server_id from the paylaoad
                server_id = commands[1]
                start_time = datetime.utcnow()
                end_time = start_time + timedelta(minutes=10)
                cloud_cop_obj.extend_server(server_id)
                update_cache("extend", cloud_cop_obj, server_id, slack_id, end_time)

            elif cmd == "keepalive":
                #read server_id from the paylaoad
                server_id = commands[1]
                hours = commands[2]

        if send_reply_flag is True:
            web_client.chat_postMessage(channel=channel_id,text=r_message)

        print(f"Replied to by user {user}")


rtm_client = RTMClient(token=SLACK_TOKEN)


start_worker()
rtm_client.start()