def alienvault_asynchronous_reconfigure(system_id): """Runs an asynchronous alienvault reconfig Args: system_id (str): The system ID where we would like to run the alienvault-reconfig Returns: rt (boolean): True if success false otherwise , job_log=job_log""" if exist_task_running(task_type='alienvault_asynchronous_reconfigure', current_task_request=current_task.request, param_to_compare=system_id, argnum=0): return JobResult(False, "An existing task running", "").serialize try: logger.info("Start asynchronous reconfigure <%s>" % system_id) rt, error_str = api_run_reconfigure(system_id) # -- When the task has been launched properly the error_str variable will contain the log file. if not rt: return JobResult(False, "Something wrong happend while running the alienvault reconfig %s" % error_str, "").serialize logger.info("reconfigure <%s> waiting to finish...." % system_id) time.sleep(1) # Wait until the task is lauched. n_process = 1 while n_process > 0: success, n_process = api_check_if_process_is_running(system_id, error_str) time.sleep(1) logger.info("Running alienvault-reconfig ... end %s - %s" % (rt, error_str)) rt, log_file = apimethod_get_asynchronous_command_log_file(system_id, error_str) if not rt: return JobResult(False, "Something wrong happend while retrieving the alienvault-reconfig log file %s" % log_file, "").serialize rt, return_code_msg = apimethod_check_asynchronous_command_return_code(system_id, error_str+".rc") if not rt: return JobResult(False, "Something wrong happend while retrieving the return code", log_file).serialize except Exception, e: logger.error("An error occurred running alienvault-reconfig: %s, %s" % (str(e), traceback.format_exc())) return JobResult(False, "An error occurred running alienvault-reconfig: %s" % (str(e)), "").serialize
def alienvault_asynchronous_update(system_id, only_feed=False, update_key=""): """Runs an asynchronous alienvault update Args: system_id (str): The system ID where we would like to run the alienvault-update only_feed (boolean): A boolean indicatin whether we should update only the feed or not. Returns: rt (boolean): True if success false otherwise """ if exist_task_running(task_type='alienvault_asynchronous_update', current_task_request=current_task.request, param_to_compare=system_id, argnum=0): return JobResult(False, "An existing task running", "").serialize try: logger.info("Start asynchronous update <%s>" % system_id) rt, error_str = api_run_update(system_id, only_feed=only_feed, update_key=update_key) # When the task has been launched properly the error_str variable will contain the log file. if not rt: return JobResult( False, "Something wrong happend while running the alienvault update %s" % error_str, "").serialize logger.info(" alienvault-update <%s> waiting to finish...." % system_id) time.sleep(1) # Wait until the task is lauched. n_process = 1 while n_process > 0: success, n_process = api_check_if_process_is_running( system_id, error_str) time.sleep(1) rt, log_file = apimethod_get_asynchronous_command_log_file( system_id, error_str) if not rt: return JobResult( False, "Something wrong happend while retrieving the alienvault-update log file %s" % log_file, "").serialize rt, return_code_msg = apimethod_check_asynchronous_command_return_code( system_id, error_str + ".rc") if not rt: return JobResult( False, "Something wrong happend while retrieving the alienvault-return code <%s>" % str(return_code_msg), log_file).serialize flush_cache(namespace="system_packages") logger.info("Running alienvault-update ... end %s - %s" % (rt, error_str)) except Exception, e: logger.error("An error occurred running alienvault-reconfig: %s, %s" % (str(e), traceback.format_exc())) return JobResult( False, "An error occurred running alienvault-update <%s>" % str(e), "").serialize
def alienvault_asynchronous_reconfigure(system_id): """Runs an asynchronous alienvault reconfig Args: system_id (str): The system ID where we would like to run the alienvault-reconfig Returns: rt (boolean): True if success false otherwise , job_log=job_log""" if exist_task_running(task_type='alienvault_asynchronous_reconfigure', current_task_request=current_task.request, param_to_compare=system_id, argnum=0): return JobResult(False, "An existing task running", "").serialize try: logger.info("Start asynchronous reconfigure <%s>" % system_id) rt, error_str = api_run_reconfigure(system_id) # -- When the task has been launched properly the error_str variable will contain the log file. if not rt: return JobResult( False, "Something wrong happend while running the alienvault reconfig %s" % error_str, "").serialize logger.info("reconfigure <%s> waiting to finish...." % system_id) time.sleep(1) # Wait until the task is lauched. n_process = 1 while n_process > 0: success, n_process = api_check_if_process_is_running( system_id, error_str) time.sleep(1) logger.info("Running alienvault-reconfig ... end %s - %s" % (rt, error_str)) rt, log_file = apimethod_get_asynchronous_command_log_file( system_id, error_str) if not rt: return JobResult( False, "Something wrong happend while retrieving the alienvault-reconfig log file %s" % log_file, "").serialize rt, return_code_msg = apimethod_check_asynchronous_command_return_code( system_id, error_str + ".rc") if not rt: return JobResult( False, "Something wrong happend while retrieving the return code", log_file).serialize except Exception, e: logger.error("An error occurred running alienvault-reconfig: %s, %s" % (str(e), traceback.format_exc())) return JobResult( False, "An error occurred running alienvault-reconfig: %s" % (str(e)), "").serialize
def alienvault_asynchronous_update(system_id, only_feed=False,update_key=""): """Runs an asynchronous alienvault update Args: system_id (str): The system ID where we would like to run the alienvault-update only_feed (boolean): A boolean indicatin whether we should update only the feed or not. Returns: rt (boolean): True if success false otherwise """ if exist_task_running(task_type='alienvault_asynchronous_update',current_task_request=current_task.request, param_to_compare=system_id,argnum=0): return JobResult(False, "An existing task running","").serialize try: logger.info("Start asynchronous update <%s>" % system_id) rt, error_str = api_run_update(system_id, only_feed=only_feed,update_key=update_key) # When the task has been launched properly the error_str variable will contain the log file. if not rt: return JobResult( False, "Something wrong happend while running the alienvault update %s" % error_str,"").serialize logger.info(" alienvault-update <%s> waiting to finish...." % system_id) time.sleep(1) # Wait until the task is lauched. n_process = 1 while n_process > 0: success,n_process = api_check_if_process_is_running(system_id, error_str) time.sleep(1) rt, log_file = apimethod_get_asynchronous_command_log_file(system_id, error_str) if not rt: return JobResult(False, "Something wrong happend while retrieving the alienvault-update log file %s" % log_file,"").serialize rt, return_code_msg = apimethod_check_asynchronous_command_return_code(system_id,error_str+".rc") if not rt: return JobResult(False,"Something wrong happend while retrieving the alienvault-return code <%s>" % str(return_code_msg) , log_file).serialize flush_cache(namespace="system_packages") logger.info("Running alienvault-update ... end %s - %s" % (rt,error_str)) except Exception, e: logger.error("An error occurred running alienvault-reconfig: %s, %s" % (str(e), traceback.format_exc())) return JobResult(False, "An error occurred running alienvault-update <%s>" % str(e),"").serialize