def __init__(self, inboxer=Inboxer(), docker_agent=None): self.inboxer = inboxer self.inboxer.on("received", self.__handle_inbox_received_event) self.docker_agent = docker_agent self.id_to_cpu = {} self.id_to_metadata = {} if self.docker_agent is None: self.docker_agent = DockerAgent() # Setup pending queue self.pending = {} self.pending_thread = Thread(target=self.__process_pending) self.pending_thread.daemon = True self.pending_thread.start()
configuration.bootstrap_app_config(app) # Setup authorization plugin token_secret = app.config.get('token_secret', 'password') auth_plugin = TokenAuthorizationPlugin(token_secret) app.install(auth_plugin) count = AtomicLong(0) inbox = Inboxer(atomic_counter=count, master_inbox_path=app.config.get('inbox.master', DEFAULT_MASTER_INBOX), container_inboxes_path=app.config.get( 'inbox.containers', DEFAULT_CONTAINER_INBOXES)) docker_agent = DockerAgent(registry_host=app.config.get("registry.host", None), username=app.config.get("registry.username", None), password=app.config.get("registry.password", None), docker_timeout=app.config.get("docker.timeout", 2)) orchestrator = Orchestrator(inboxer=inbox, docker_agent=docker_agent) # Accepts a multipart form # Field 'topic' -> The topic for the attached file(s) # Field * -> Any field name that is a UploadFile object @app.post('/event') def post_event(): topic = request.forms.get("topic") successfully_queued = [] # Bottle default way of accessing files doesn't seem to like multiple files # which use the same form name (which is standard practice). So let's # access them manually. Muwhahahahaha.