def start(): '''Start the Application''' log = configure_log() log.info('Starting Cloud Worker Node Agent') log.info('--------------------------') args = parse_args() settings = {'base_url': args.server, 'secret': args.secret, 'client_id': C.CLIENT_ID, 'client_secret': C.CLIENT_SECRET, 'username': C.USERNAME, 'password': C.PASSWORD} server = Server(settings) node = Node(server) #Send the hostname, ip etc to the server node.send_info() #Update the node status to ready node.update_node_status(C.STATUS_READY) #Get Config config = Config(server, node) actions = Action(server, node) processor = Processor() workers = Worker(server, node, processor) output = Output(server, node) finished = False #Loop forever (kind of) while not finished: log.info('Looping') log.info('--------------------------') #Update last seen date node.update_node_date() #Get config config.refresh() #Get actions num_pending = actions.get_pending() #Respond to actions if actions.has_pending(): message = 'Responding to %d Actions ...' % num_pending output.send(message) actions.respond_to_pending() #Get workers/commands workers.refresh() workers.process_workers() #TODO #Respond to/run commands #Send output to server log.info('Sleeping for %d seconds ...', config.get(C.CONFIG_POLL_PERIOD)) time.sleep(config.get(C.CONFIG_POLL_PERIOD))