def on_get(self, req, resp): workers = self.db.find('worker') workers_status = [Worker(**worker).get_status() for worker in workers] resp.status = falcon.HTTP_200 resp.body = format_response_body({'status': workers_status})
def on_get(self, req, resp, tenant_id): tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body({'tenant': tenant.format()})
def on_get(self, req, resp, tenant_id): tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body( {'event_producers': [p.format() for p in tenant.event_producers]})
def on_get(self, req, resp, tenant_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body({'token': tenant.token.format()})
def on_get(self, req, resp, tenant_id): tenant = find_tenant(self.db, tenant_id=tenant_id, create_on_missing=True) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body({'tenant': tenant.format()})
def on_get(self, req, resp, tenant_id): tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body({'event_producers': [p.format() for p in tenant.event_producers]})
def on_get(self, req, resp): workers = self.db.find('worker') workers_status = [ Worker(**worker).get_status() for worker in workers] resp.status = falcon.HTTP_200 resp.body = format_response_body({'status': workers_status})
def on_get(self, req, resp): """ Retrieve the status of all workers in the meniscus cluster """ workers = worker_util.retrieve_all_workers() workers_status = [worker.get_status() for worker in workers] resp.status = falcon.HTTP_200 resp.body = api.format_response_body({'status': workers_status})
def on_get(self, req, resp): """ Retrieve the status of all workers in the meniscus cluster """ workers = worker_util.retrieve_all_workers() workers_status = [worker.get_status() for worker in workers] resp.status = falcon.HTTP_200 resp.body = api.format_response_body({"status": workers_status})
def on_get(self, req, resp, worker_id): #find the worker in db worker_dict = self.db.find_one('worker', {'worker_id': worker_id}) if not worker_dict: _worker_not_found() worker = Worker(**worker_dict) resp.status = falcon.HTTP_200 resp.body = format_response_body({'status': worker.get_status()})
def on_get(self, req, resp, tenant_id): """ Retrieve a list of all Event Producers for a specified Tenant """ tenant = tenant_util.find_tenant(tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = api.format_response_body( {'event_producers': [p.format() for p in tenant.event_producers]})
def on_get(self, req, resp, tenant_id): """ Retrieve a specified tenant when a HTTP GET is received """ tenant = tenant_util.find_tenant( tenant_id=tenant_id, create_on_missing=True) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = api.format_response_body({'tenant': tenant.format()})
def on_get(self, req, resp, tenant_id): """ Retrieve a specified tenant when a HTTP GET is received """ tenant = tenant_util.find_tenant(tenant_id=tenant_id, create_on_missing=True) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = api.format_response_body({'tenant': tenant.format()})
def on_get(self, req, resp, tenant_id): #ensure the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 #jsonify a list of formatted profiles resp.body = format_response_body({ 'profiles': [p.format() for p in tenant.profiles] })
def on_get(self, req, resp, hostname): """ Retrieve the status of a specified worker node """ #find the worker in db worker = worker_util.find_worker(hostname) if worker is None: api.abort(falcon.HTTP_404, 'Unable to locate worker.') resp.status = falcon.HTTP_200 resp.body = api.format_response_body({'status': worker.get_status()})
def on_get(self, req, resp, worker_id): """ Retrieve the status of a specified worker node """ #find the worker in db worker = worker_util.find_worker(worker_id) if worker is None: _worker_not_found() resp.status = falcon.HTTP_200 resp.body = api.format_response_body({'status': worker.get_status()})
def on_get(self, req, resp, hostname): """ Retrieve the status of a specified worker node """ # find the worker in db worker = worker_util.find_worker(hostname) if worker is None: api.abort(falcon.HTTP_404, "Unable to locate worker.") resp.status = falcon.HTTP_200 resp.body = api.format_response_body({"status": worker.get_status()})
def on_get(self, req, resp, tenant_id, profile_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() #verify the profile exists and belongs to the tenant profile = find_host_profile(tenant, profile_id=profile_id) if not profile: _profile_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body({'profile': profile.format()})
def on_get(self, req, resp, tenant_id, host_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() #verify the hosts exists and belongs to the tenant host = find_host(tenant, host_id=host_id) if not host: _host_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body({'host': host.format()})
def on_get(self, req, resp, tenant_id): """ Retrieves Token information for a specified Tenant when an HTTP GET call is received """ #verify the tenant exists tenant = tenant_util.find_tenant(tenant_id=tenant_id) if not tenant: _tenant_not_found() resp.status = falcon.HTTP_200 resp.body = api.format_response_body({'token': tenant.token.format()})
def on_get(self, req, resp, tenant_id, event_producer_id): #verify the tenant exists tenant = find_tenant(self.db, tenant_id=tenant_id) if not tenant: _tenant_not_found() #verify the event_producer exists and belongs to the tenant event_producer = find_event_producer(tenant, producer_id=event_producer_id) if not event_producer: _producer_not_found() resp.status = falcon.HTTP_200 resp.body = format_response_body( {'event_producer': event_producer.format()})
def on_post(self, req, resp, validated_body): """ receives json req to register worker responds with a 202 for success """ #load json payload in body body = validated_body['worker_registration'] #instantiate new worker object new_worker = Worker(**body) #persist the new worker coordinator_flow.add_worker(self.db, new_worker) resp.status = falcon.HTTP_202 resp.body = format_response_body( {'worker_identity': new_worker.get_registration_identity()})
def on_post(self, req, resp, tenant_id, validated_body): """ This method is passed log event data by a tenant. The request will have a message token and a tenant id which must be validated either by the local cache or by a call to this workers coordinator. """ #read message token from header message_token = req.get_header(MESSAGE_TOKEN, required=True) #Validate the tenant's JSON event log data as valid JSON. message = validated_body['log_message'] tenant_identification = correlator.TenantIdentification( tenant_id, message_token) try: tenant = tenant_identification.get_validated_tenant() message = correlator.add_correlation_info_to_message( tenant, message) except errors.MessageAuthenticationError as ex: abort(falcon.HTTP_401, ex.message) except errors.ResourceNotFoundError as ex: abort(falcon.HTTP_404, ex.message) except errors.CoordinatorCommunicationError: abort(falcon.HTTP_500) dispatch.persist_message(message) #if message is durable, return durable job info if message['meniscus']['correlation']['durable']: durable_job_id = message['meniscus']['correlation']['job_id'] job_status_uri = "http://{0}/v1/job/{1}/status" \ .format("meniscus_uri", durable_job_id) resp.status = falcon.HTTP_202 resp.body = format_response_body( { "job_id": durable_job_id, "job_status_uri": job_status_uri } ) else: resp.status = falcon.HTTP_204
def on_post(self, req, resp, validated_body): """ Registers a new worker when an HTTP POST is received and responds with a 202 for success """ #load json payload in body body = validated_body['worker_registration'] #instantiate new worker object new_worker = Worker(**body) #persist the new worker worker_util.create_worker(new_worker) resp.status = falcon.HTTP_202 resp.body = api.format_response_body( {'worker_identity': new_worker.get_registration_identity()})
def on_post(self, req, resp, tenant_id, validated_body): """ This method is passed log event data by a tenant. The request will have a message token and a tenant id which must be validated either by the local cache or by a call to this workers coordinator. """ #read message token from header message_token = req.get_header(MESSAGE_TOKEN, required=True) #Validate the tenant's JSON event log data as valid JSON. message = validated_body['log_message'] tenant_identification = correlator.TenantIdentification( tenant_id, message_token) try: tenant = tenant_identification.get_validated_tenant() message = correlator.add_correlation_info_to_message( tenant, message) except errors.MessageAuthenticationError as ex: abort(falcon.HTTP_401, ex.message) except errors.ResourceNotFoundError as ex: abort(falcon.HTTP_404, ex.message) except errors.CoordinatorCommunicationError: abort(falcon.HTTP_500) dispatch.persist_message(message) #if message is durable, return durable job info if message['meniscus']['correlation']['durable']: durable_job_id = message['meniscus']['correlation']['job_id'] job_status_uri = "http://{0}/v1/job/{1}/status" \ .format("meniscus_uri", durable_job_id) resp.status = falcon.HTTP_202 resp.body = format_response_body({ "job_id": durable_job_id, "job_status_uri": job_status_uri }) else: resp.status = falcon.HTTP_204
def on_get(self, req, resp, tenant_id, event_producer_id): """ Retrieve a specified Event Producer from a Tenant when an HTTP GET is received """ #verify the tenant exists tenant = tenant_util.find_tenant(tenant_id=tenant_id) if not tenant: _tenant_not_found() #verify the event_producer exists and belongs to the tenant event_producer = tenant_util.find_event_producer( tenant, producer_id=event_producer_id) if not event_producer: _producer_not_found() resp.status = falcon.HTTP_200 resp.body = api.format_response_body( {'event_producer': event_producer.format()})
def on_post(self, req, resp, tenant_id): """ This method is passed log event data by a tenant. The request will have a message token and a tenant id which must be validated either by the local cache or by a call to this workers coordinator. """ #read message token from header message_token = req.get_header(MESSAGE_TOKEN, required=True) #Validate the tenant's JSON event log data as valid JSON. body = load_body(req) self._validate_req_body_on_post(body) tenant_identification = TenantIdentification( tenant_id, message_token) try: tenant = tenant_identification.get_validated_tenant() correlator = Correlator(tenant, body) correlator.process_message() try: self.router.route_message(correlator.message) except RoutingException as ex: abort(falcon.HTTP_500, 'error routing message') if correlator.is_durable(): resp.status = falcon.HTTP_202 resp.body = format_response_body( correlator.get_durable_job_info()) else: resp.status = falcon.HTTP_204 except MessageAuthenticationError as ex: abort(falcon.HTTP_401, ex.message) except ResourceNotFoundError as ex: abort(falcon.HTTP_404, ex.message) except CoordinatorCommunicationError: abort(falcon.HTTP_500)
def on_get(self, req, resp): resp.status = falcon.HTTP_200 resp.body = format_response_body({"v1": "current"})
def on_get(self, req, resp): resp.status = falcon.HTTP_200 resp.body = format_response_body({'v1': 'current'})