def main(): global event, playbook, configs cirtaHome = os.path.dirname(os.path.realpath(__file__)) configs = config(os.path.join(cirtaHome, "etc")) options = processArgs(configs) initLogging(configs, options) playbook = Playbook(configs, options) event = Event(cirta_id, configs, options, playbook, cirtaHome) printModeHeader(playbook, event) printCirtaID(event) if options.seed: seedAttributes(event) event.cirta_status = "running" log.state(event.getAttrs()) launchInitializers(playbook, event) collectSourcesInput(playbook, event) launchSources(playbook, event, preAction=True) if playbook.POST_SOURCES and playbook.ACTIONS and launchActionsNow(playbook, event): playbook.actionsLaunched = True launchActions(playbook, event) launchSources(playbook, event, preAction=False) if playbook.POST_SOURCES and playbook.ACTIONS and not playbook.actionsLaunched: keepaliveWait() playbook.actionsLaunched = True launchActions(playbook, event) if not playbook.actionsLaunched: keepaliveWait() launchActions(playbook, event) if hasattr(event, "_backgroundedDS"): launchBackgroundedSources(playbook, event) if hasattr(event, "_backgroundedActions"): launchBackgroundedActions(playbook, event) checkStackTraces(event) event.cirta_status = "finished" log.state(event.getAttrs()) log.info('msg="cirta execution finished"')
def launchActionsNow(playbook, event): keepaliveWait() log.info('msg="prompt to launch actions"') msg = """Launching Playbook Actions now means the remaining Playbook Sources will be executed at the end. Otherwise the remaining Playbook Sources will be executed, followed by the Playbook Actions at the end. Actions to execute: %s%s%s Remaining Playbook Sources: %s%s%s """ % ( colors.BOLDON, ", ".join(playbook.ACTIONS), colors.BOLDOFF, colors.BOLDON, ", ".join(playbook.POST_SOURCES), colors.BOLDOFF, ) printStatusMsg("Launch Playbook Actions Now?") print(msg) return getUserIn("Launch Playbook Actions Now?") in YES