def delete(self, agent_id): username = self.get_current_user() customer_name = ( get_user_property(username, UserKeys.CurrentCustomer) ) uri = self.request.uri method = self.request.method try: agent = AgentManager(agent_id, customer_name=customer_name) delete_oper = StorePatchingOperation(username, customer_name, uri, method) delete_oper.uninstall_agent(agent_id) results = agent.delete_agent(uri, method) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4)) except Exception as e: results = ( GenericResults( username, uri, method ).something_broke(agent_id, 'delete agent', e) ) logger.exception(e) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4))
def delete(self): username = self.get_current_user() customer_name = ( get_user_property(username, UserKeys.CurrentCustomer) ) uri = self.request.uri method = self.request.method try: agent_ids = self.arguments.get('agent_ids') if not isinstance(agent_ids, list): agent_ids = agent_ids.split() agentids_deleted =[] agentids_not_deleted =[] for agent_id in agent_ids: agent = AgentManager(agent_id, customer_name=customer_name) results = agent.delete_agent(uri, method) if results['http_status'] == 200: delete_oper = ( StorePatchingOperation( username, customer_name, uri, method ) ) delete_oper.uninstall_agent(agent_id) agentids_deleted.append(agent_id) else: agentids_not_deleted.append(agent_id) results['data'] = { 'agentids_deleted': agentids_deleted, 'agentids_not_deleted': agentids_not_deleted } self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4)) except Exception as e: results = ( GenericResults( username, uri, method ).something_broke('agent_ids', 'delete agentids', e) ) logger.exception(e) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4))
def delete(self, agent_id): username = self.get_current_user() customer_name = (get_user_property(username, UserKeys.CurrentCustomer)) uri = self.request.uri method = self.request.method try: agent = AgentManager(agent_id, customer_name=customer_name) delete_oper = StorePatchingOperation(username, customer_name, uri, method) delete_oper.uninstall_agent(agent_id) results = agent.delete_agent(uri, method) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4)) except Exception as e: results = (GenericResults(username, uri, method).something_broke( agent_id, 'delete agent', e)) logger.exception(e) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4))
def delete(self): username = self.get_current_user() customer_name = (get_user_property(username, UserKeys.CurrentCustomer)) uri = self.request.uri method = self.request.method try: agent_ids = self.arguments.get('agent_ids') if not isinstance(agent_ids, list): agent_ids = agent_ids.split() agentids_deleted = [] agentids_not_deleted = [] for agent_id in agent_ids: agent = AgentManager(agent_id, customer_name=customer_name) results = agent.delete_agent(uri, method) if results['http_status'] == 200: delete_oper = (StorePatchingOperation( username, customer_name, uri, method)) delete_oper.uninstall_agent(agent_id) agentids_deleted.append(agent_id) else: agentids_not_deleted.append(agent_id) results['data'] = { 'agentids_deleted': agentids_deleted, 'agentids_not_deleted': agentids_not_deleted } self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4)) except Exception as e: results = (GenericResults(username, uri, method).something_broke( 'agent_ids', 'delete agentids', e)) logger.exception(e) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(json.dumps(results, indent=4))