def put(self, agent_id): try: username = self.get_current_user() customer_name = get_user_property(username, UserKeys.CurrentCustomer) uri = self.request.uri method = self.request.method rebooted = self.arguments.get(AgentKey.Rebooted) plugins = self.arguments.get(AgentKey.Plugins) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) logger.info("data received on startup: %s" % self.request.body) agent_data = update_agent(agent_id, system_info, hardware, rebooted, username, customer_name, uri, method) uris = get_result_uris(agent_id, username, uri, method) uris[AgentOperationKey.Operation] = AgentOperations.REFRESH_RESPONSE_URIS agent_data.pop("data") agent_data["data"] = [uris] self.set_status(agent_data["http_status"]) if agent_data["http_status"] == 200: if "rv" in plugins: RvHandOff(username, customer_name, uri, method).startup_operation(agent_id, plugins["rv"]["data"]) if "ra" in plugins: RaHandoff.startup(agent_id, plugins["ra"]) self.set_header("Content-Type", "application/json") self.write(dumps(agent_data)) except Exception as e: status = GenericResults(username, uri, method).something_broke(agent_id, "startup", e) logger.exception(status["message"]) self.write(dumps(status))
def post(self): username = self.get_current_user() customer_name = self.arguments.get(AgentKey.CustomerName) plugins = self.arguments.get(AgentKey.Plugins) rebooted = self.arguments.get(AgentKey.Rebooted) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) uri = self.request.uri method = self.request.method logger.info('data received on newagent: %s' % (self.request.body)) self.set_header('Content-Type', 'application/json') try: new_agent_results = (add_agent(system_info, hardware, username, customer_name, uri, method)) self.set_status(new_agent_results[ApiResultKeys.HTTP_STATUS_CODE]) if (new_agent_results[ApiResultKeys.VFENSE_STATUS_CODE] == AgentResultCodes.NewAgentSucceeded): agent_info = new_agent_results[ApiResultKeys.DATA][-1] agent_id = ( new_agent_results[ApiResultKeys.GENERATED_IDS].pop()) uris = get_result_uris(agent_id, username, uri, method) uris[AgentOperationKey.Operation] = ( AgentOperations.REFRESH_RESPONSE_URIS) json_msg = { AgentOperationKey.Operation: "new_agent_id", AgentOperationKey.OperationId: "", OperationPerAgentKey.AgentId: agent_id } new_agent_results[ApiResultKeys.DATA] = [json_msg, uris] try: if 'rv' in plugins: RvHandOff(username, customer_name, uri, method).new_agent_operation( agent_id, plugins['rv']['data'], agent_info) if 'ra' in plugins: RaHandoff.startup(agent_id, plugins['ra']) except Exception as e: logger.exception(e) self.write(dumps(new_agent_results, indent=4)) else: self.write(dumps(new_agent_results, indent=4)) except Exception as e: status = (GenericResults(username, uri, method).something_broke( 'agent', 'new_agent', e)) logger.exception(e) self.write(dumps(status, indent=4))
def put(self, agent_id): try: username = self.get_current_user() customer_name = get_current_customer_name(username) uri = self.request.uri method = self.request.method rebooted = self.arguments.get(AgentKey.Rebooted) plugins = self.arguments.get(AgentKey.Plugins) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) logger.info( 'data received on startup: %s' % self.request.body ) agent_data = ( update_agent( username, customer_name, uri, method, agent_id, system_info, hardware, rebooted ) ) agent_data.pop('data') agent_data['data'] = [] logger.info(agent_data) self.set_status(agent_data['http_status']) if agent_data['http_status'] == 200: if 'rv' in plugins: RvHandOff( username, customer_name, uri, method, agent_id, plugins['rv']['data'], oper_type='updates_applications' ) if 'ra' in plugins: RaHandoff.startup(agent_id, plugins['ra']) self.set_header('Content-Type', 'application/json') self.write(dumps(agent_data)) except Exception as e: status = ( GenericResults( username, uri, method ).something_broke(agent_id, 'startup', e) ) logger.exception(status['message']) self.write(dumps(status))
def put(self, agent_id): try: username = self.get_current_user() customer_name = (get_user_property(username, UserKeys.CurrentCustomer)) uri = self.request.uri method = self.request.method rebooted = self.arguments.get(AgentKey.Rebooted) plugins = self.arguments.get(AgentKey.Plugins) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) logger.info('data received on startup: %s' % self.request.body) agent_data = (update_agent( agent_id, system_info, hardware, rebooted, username, customer_name, uri, method, )) uris = get_result_uris(agent_id, username, uri, method) uris[AgentOperationKey.Operation] = ( AgentOperations.REFRESH_RESPONSE_URIS) agent_data.pop('data') agent_data['data'] = [uris] self.set_status(agent_data['http_status']) if agent_data['http_status'] == 200: if 'rv' in plugins: RvHandOff(username, customer_name, uri, method).startup_operation( agent_id, plugins['rv']['data']) if 'ra' in plugins: RaHandoff.startup(agent_id, plugins['ra']) self.set_header('Content-Type', 'application/json') self.write(dumps(agent_data)) except Exception as e: status = (GenericResults(username, uri, method).something_broke( agent_id, 'startup', e)) logger.exception(status['message']) self.write(dumps(status))
def post(self): username = self.get_current_user() customer_name = self.arguments.get(AgentKey.CustomerName) plugins = self.arguments.get(AgentKey.Plugins) rebooted = self.arguments.get(AgentKey.Rebooted) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) uri = self.request.uri method = self.request.method logger.info('data received on newagent: %s' % (self.request.body)) try: new_agent = (add_agent(username, customer_name, uri, method, system_info, hardware)) agent_info = new_agent['data'] self.set_status(new_agent['http_status']) if new_agent['http_status'] == 200: agent_id = agent_info[AgentKey.AgentId] json_msg = { OperationKey.Operation: "new_agent_id", OperationKey.OperationId: "", OperationPerAgentKey.AgentId: agent_id } new_agent['data'] = [json_msg] self.set_header('Content-Type', 'application/json') try: if 'rv' in plugins: RvHandOff(username, customer_name, uri, method, agent_id, plugins['rv']['data'], agent_info) if 'ra' in plugins: RaHandoff.startup(agent_id, plugins['ra']) except Exception as e: logger.exception(e) self.write(dumps(new_agent, indent=4)) else: self.set_header('Content-Type', 'application/json') self.write(dumps(new_agent, indent=4)) except Exception as e: status = (GenericResults(username, uri, method).something_broke( 'agent', 'new_agent', e)) logger.exception(e) self.write(dumps(status, indent=4))
def post(self): username = self.get_current_user() customer_name = self.arguments.get(AgentKey.CustomerName) plugins = self.arguments.get(AgentKey.Plugins) rebooted = self.arguments.get(AgentKey.Rebooted) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) uri = self.request.uri method = self.request.method logger.info("data received on newagent: %s" % (self.request.body)) try: new_agent = add_agent(username, customer_name, uri, method, system_info, hardware) agent_info = new_agent["data"] self.set_status(new_agent["http_status"]) if new_agent["http_status"] == 200: agent_id = agent_info[AgentKey.AgentId] json_msg = { OperationKey.Operation: "new_agent_id", OperationKey.OperationId: "", OperationPerAgentKey.AgentId: agent_id, } new_agent["data"] = [json_msg] self.set_header("Content-Type", "application/json") try: if "rv" in plugins: RvHandOff(username, customer_name, uri, method, agent_id, plugins["rv"]["data"], agent_info) if "ra" in plugins: RaHandoff.startup(agent_id, plugins["ra"]) except Exception as e: logger.exception(e) self.write(dumps(new_agent, indent=4)) else: self.set_header("Content-Type", "application/json") self.write(dumps(new_agent, indent=4)) except Exception as e: status = GenericResults(username, uri, method).something_broke("agent", "new_agent", e) logger.exception(e) self.write(dumps(status, indent=4))
def post(self): username = self.get_current_user() customer_name = self.arguments.get(AgentKey.CustomerName) plugins = self.arguments.get(AgentKey.Plugins) rebooted = self.arguments.get(AgentKey.Rebooted) system_info = self.arguments.get(AgentKey.SystemInfo) hardware = self.arguments.get(AgentKey.Hardware) uri = self.request.uri method = self.request.method logger.info('data received on newagent: %s' % (self.request.body)) self.set_header('Content-Type', 'application/json') try: new_agent_results = ( add_agent( system_info, hardware, username, customer_name, uri, method ) ) self.set_status( new_agent_results[ApiResultKeys.HTTP_STATUS_CODE] ) if ( new_agent_results[ApiResultKeys.VFENSE_STATUS_CODE] == AgentResultCodes.NewAgentSucceeded ): agent_info = new_agent_results[ApiResultKeys.DATA][-1] agent_id = ( new_agent_results[ApiResultKeys.GENERATED_IDS].pop() ) uris = get_result_uris(agent_id, username, uri, method) uris[AgentOperationKey.Operation] = ( AgentOperations.REFRESH_RESPONSE_URIS ) json_msg = { AgentOperationKey.Operation: "new_agent_id", AgentOperationKey.OperationId: "", OperationPerAgentKey.AgentId: agent_id } new_agent_results[ApiResultKeys.DATA] = [json_msg, uris] try: if 'rv' in plugins: RvHandOff( username, customer_name, uri, method ).new_agent_operation( agent_id, plugins['rv']['data'], agent_info ) if 'ra' in plugins: RaHandoff.startup(agent_id, plugins['ra']) except Exception as e: logger.exception(e) self.write(dumps(new_agent_results, indent=4)) else: self.write(dumps(new_agent_results, indent=4)) except Exception as e: status = ( GenericResults( username, uri, method ).something_broke('agent', 'new_agent', e) ) logger.exception(e) self.write(dumps(status, indent=4))