def asynchronous_update(system_id, only_feed=False, update_key=""): """Launches an asynchronous update on the given system_ip Args: system_id (str): The system_id of the system to update. only_feed (boolean): A boolean to indicate that we need to update only the feed. Returns: (boolean, job_id): A tuple containing the result of the execution Examples: >>> asynchronous_update("11111111-1111-1111-111111111111") (True,"/var/log/alienvault/update/system_update.log") """ (success, system_ip) = get_system_ip_from_system_id(system_id) if not success: error_msg = "[asynchronous_update] Error retrieving " + \ "the system ip for the system id " + \ "%s -> %s" % (system_ip, str(system_ip)) return False, error_msg job = alienvault_asynchronous_update.delay(system_ip, only_feed, update_key) if job is None: error_msg = "Cannot update system %s. " % system_id + \ "Please verify that the system is reachable." api_log.error(error_msg) return False, error_msg flush_cache(namespace="system_packages") return True, job.id
def asynchronous_update(system_id, only_feed=False, update_key=""): """Launches an asynchronous update on the given system_ip Args: system_id (str): The system_id of the system to update. only_feed (boolean): A boolean to indicate that we need to update only the feed. Returns: (boolean, job_id): A tuple containing the result of the execution Examples: >>> asynchronous_update("11111111-1111-1111-111111111111") (True,"/var/log/alienvault/update/system_update.log") """ (success, system_ip) = get_system_ip_from_system_id(system_id) if not success: error_msg = "[asynchronous_update] Error retrieving " + \ "the system ip for the system id " + \ "%s -> %s" % (system_ip, str(system_ip)) return False, error_msg job = alienvault_asynchronous_update.delay(system_ip, only_feed, update_key) if job is None: error_msg = "Cannot update system %s. " % system_id + \ "Please verify that the system is reachable." api_log.error(error_msg) return False, error_msg flush_cache(namespace="system_packages") return True, job.id
def update_system_feed(system_id): """Blueprint to launch local/remote feed update Args: system_id (UUID): system to update Returns: data: JSON with status and job ID or error message success example: { "data": { "job_id": "fe7df875-1939-4c55-a499-af99880f3351" }, "status": "success" } error example: { "message": "Cannot update system 564D9762-9196-99CD-46E6-3D941F32AA6. Please verify that the system is reachable.", "status": "error", "status_code": 500, "status_long_message": "Server got itself in trouble", "status_short_message": "Internal Server Error" } """ job = alienvault_asynchronous_update.delay(system_id, only_feed=True) if not job: api_log.error( "Cannot update system %s. Please verify that the system is reachable." % system_id, 500) return make_error( "Cannot update system %s. Please verify that the system is reachable." % system_id, 500) return make_ok(job_id=job.id)
def get_license_pro(system_id): # Retrieve URL parameters. key = request.args.get('key') if key is None: current_app.logger.error("license: get_license_pro error: Missing param 'key'") return make_error('Missing param key', 400) (success, msg) = register_appliance_pro(key, system_id, False) if not success: current_app.logger.error ("license: get_license_pro error: " + str(msg)) return make_error(msg, 500) #Launch the upgrade job = alienvault_asynchronous_update.delay(system_id, only_feed=False,update_key=key) return make_ok(job_id=job.id)