def __init__(self): self.log = Log() self.msgQueue = Queue(account_name=config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=config.HALO_QUEUE_MATCH) self.summary = SummaryTable(config.AZURE_STORAGE_ACCOUNT_NAME, config.AZURE_STORAGE_ACCOUNT_KEY, config.AZURE_STORAGE_SUMMARY_TABLE_NAME)
def __init__(self): self.log = Log() self.log.debug("Storage account for analyzer: {0}".format(config.AZURE_STORAGE_ACCOUNT_NAME)) self.msgQueue = Queue(account_name = config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=config.AZURE_STORAGE_QUEUE_NAME) self.summary = SummaryTable(config.AZURE_STORAGE_ACCOUNT_NAME, config.AZURE_STORAGE_ACCOUNT_KEY, config.AZURE_STORAGE_SUMMARY_TABLE_NAME) self.keep_running = bool(config.ANALYZER_KEEP_RUNNING) self.log.debug("Analyzer keep running: {0}".format(self.keep_running)) if self.keep_running: self.sleep_time = float(config.ANALYZER_SLEEP_TIME) self.log.debug("Sleep time between analyses: {0}".format(self.sleep_time))
def simulate(): log = Log() hostname = socket.gethostname() msgQueue = Queue(account_name=config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=config.AZURE_STORAGE_QUEUE_NAME) if int(config.SIMULATION_ACTIONS) > 0: msg = hostname + ': Attempting to simulate ' + str( config.SIMULATION_ACTIONS) + ' actions' log.debug(msg) notify.info(msg) else: msg = hostname + ': Simulating until stopped' log.debug(msg) notify.info(msg) temp = 70 _actions = 0 while int(config.SIMULATION_ACTIONS) == 0 or int( config.SIMULATION_ACTIONS) - _actions > 0: change = random.randint(-1, 1) if temp <= _too_cold: change = 1 elif temp >= _too_hot: change = -1 msgQueue.enqueue("INFO - Change since last reading: " + str(change)) temp = temp + change msgQueue.enqueue("INFO - Current temperature: " + str(temp)) if temp == _just_right: msgQueue.enqueue("INFO - That's perfect") elif temp < _just_right and temp > _too_cold: msgQueue.enqueue('WARNING - Getting a little chilly') elif temp > _just_right and temp < _too_hot: msgQueue.enqueue('WARNING - Getting a touch warm') elif temp <= _too_cold: msgQueue.enqueue('ERROR - Too cold, how did this happen?') elif temp >= _too_hot: msgQueue.enqueue('ERROR - Too hot, how did this happen?') else: msgQueue.enqueue('ERROR - Can' 't tell if it' 's hot or cold') msgQueue.close() _actions = _actions + 1 time.sleep(int(config.SIMULATION_DELAY)) msg = hostname + ": Simulated " + str( config.SIMULATION_ACTIONS) + " actions and added them to the queue" log.debug(msg) notify.info(msg)
def create_queue_entries_for_match(match): """ Create all required queue entries for the supplied match. """ # Increment work_item = { "created": time.time(), "data": json.dumps(match) } queue_name = config.HALO_QUEUE_MATCH work_queue = Queue(account_name = config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=queue_name) work_queue.enqueue(json.dumps(work_item))
def __init__(self): self.log = Log() self.log.debug("Storage account for analyzer: {0}".format( config.AZURE_STORAGE_ACCOUNT_NAME)) self.msgQueue = Queue(account_name=config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=config.AZURE_STORAGE_QUEUE_NAME) self.current_length = self.msgQueue.getLength() self.summary = SummaryTable(config.AZURE_STORAGE_ACCOUNT_NAME, config.AZURE_STORAGE_ACCOUNT_KEY, config.AZURE_STORAGE_SUMMARY_TABLE_NAME) self.sleep_time = float(config.ANALYZER_SLEEP_TIME) self.log.debug("Sleep time between analyses: {0}".format( self.sleep_time))
def enqueue(): queue = request.form['queue'] msgQueue = Queue(account_name=config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=queue) msg = request.form['message'] msgQueue.enqueue(msg) response = { "result": "success", "message": msg, "queue": queue, "storage_account": config.AZURE_STORAGE_ACCOUNT_NAME } return jsonify(response)
def getQueueService(): queue_service = Queue(account_name=config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=config.AZURE_STORAGE_QUEUE_NAME) return queue_service
def __init__(self): self.log = Log() self.msgQueue = Queue(account_name = config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=config.AZURE_STORAGE_QUEUE_NAME)
def getMessageQueue(self, queue_id): self.queue = Queue(account_name=config.AZURE_STORAGE_ACCOUNT_NAME, account_key=config.AZURE_STORAGE_ACCOUNT_KEY, queue_name=queue_id)