def put(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: operation_id = self.arguments.get('operation_id') data = self.arguments.get('data') apps_to_delete = self.arguments.get('apps_to_delete', []) apps_to_add = self.arguments.get('apps_to_add', []) error = self.arguments.get('error', None) reboot_required = self.arguments.get('reboot_required') app_id = self.arguments.get('app_id') success = self.arguments.get('success') status_code = self.arguments.get('status_code', None) logger.info("self.arguments: {0}".format(self.arguments)) if not isinstance(reboot_required, bool): if reboot_required == CommonKeys.TRUE: reboot_required = True else: reboot_required = False results = PatchingOperationResults( username, agent_id, operation_id, success, error, status_code, uri, method ) results_data = results.install_supported_apps( app_id, reboot_required, apps_to_delete, apps_to_add ) print results_data self.set_status(results_data['http_status']) self.set_header('Content-Type', 'application/json') self.write(dumps(results_data, indent=4)) send_notifications(username, customer_name, operation_id, agent_id) except Exception as e: results = ( GenericResults( username, uri, method ).something_broke(agent_id, 'install_supported_apps results', e) ) logger.exception(results) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(dumps(results, indent=4))
def put(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: operation_id = self.arguments.get('operation_id', None) error = self.arguments.get('error', None) success = self.arguments.get('success', 'true') apps_data = self.arguments.get('data') status_code = self.arguments.get('status_code', None) RvHandOff( username, customer_name, uri, method ).refresh_apps_operation(agent_id, apps_data) if operation_id: logger.info("self.arguments: {0}".format(self.arguments)) results = PatchingOperationResults( username, agent_id, operation_id, success, error, status_code, uri, method ) results_data = results.apps_refresh() print results_data results_apps_refresh = results.apps_refresh() self.set_status(results_apps_refresh['http_status']) self.write(dumps(results_apps_refresh)) else: results = ( UpdateApplicationsResults(username, uri, method) .applications_updated(agent_id, apps_data) ) results['data'] = [] self.set_status(results['http_status']) self.write(dumps(results)) except Exception as e: results = GenericResults( username, uri, method ).something_broke(agent_id, AgentOperations.REFRESH_APPS, e) logger.exception(results) self.set_status(results['http_status']) self.write(dumps(results))
def put(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: operation_id = self.arguments.get('operation_id', None) error = self.arguments.get('error', None) success = self.arguments.get('success', 'true') apps_data = self.arguments.get('data') status_code = self.arguments.get('status_code', None) RvHandOff(username, customer_name, uri, method).refresh_apps_operation(agent_id, apps_data) if operation_id: logger.info("self.arguments: {0}".format(self.arguments)) results = PatchingOperationResults(username, agent_id, operation_id, success, error, status_code, uri, method) results_data = results.apps_refresh() print results_data results_apps_refresh = results.apps_refresh() self.set_status(results_apps_refresh['http_status']) self.write(dumps(results_apps_refresh)) else: results = (UpdateApplicationsResults( username, uri, method).applications_updated(agent_id, apps_data)) results['data'] = [] self.set_status(results['http_status']) self.write(dumps(results)) except Exception as e: results = GenericResults(username, uri, method).something_broke( agent_id, AgentOperations.REFRESH_APPS, e) logger.exception(results) self.set_status(results['http_status']) self.write(dumps(results))
def put(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: operation_id = self.arguments.get('operation_id') data = self.arguments.get('data') apps_to_delete = self.arguments.get('apps_to_delete', []) apps_to_add = self.arguments.get('apps_to_add', []) error = self.arguments.get('error', None) reboot_required = self.arguments.get('reboot_required') app_id = self.arguments.get('app_id') success = self.arguments.get('success') status_code = self.arguments.get('status_code', None) logger.info("self.arguments: {0}".format(self.arguments)) if not isinstance(reboot_required, bool): if reboot_required == CommonKeys.TRUE: reboot_required = True else: reboot_required = False results = PatchingOperationResults(username, agent_id, operation_id, success, error, status_code, uri, method) results_data = results.install_supported_apps( app_id, reboot_required, apps_to_delete, apps_to_add) print results_data self.set_status(results_data['http_status']) self.set_header('Content-Type', 'application/json') self.write(dumps(results_data, indent=4)) send_notifications(username, customer_name, operation_id, agent_id) except Exception as e: results = (GenericResults(username, uri, method).something_broke( agent_id, 'install_supported_apps results', e)) logger.exception(results) self.set_status(results['http_status']) self.set_header('Content-Type', 'application/json') self.write(dumps(results, indent=4))