def find_once(p, c, m, run_name): em_core_logfetch.fetch_by_service_name(p, c, m, run_name, PROVISIONER) em_core_eventgather.update_events(p, c, m, run_name) # order is important, first "new_node" launched_vms = vms_launched(m, run_name, "new_node") for vm in launched_vms: if m.persistence.new_vm(run_name, vm): c.log.info("Found new worker: %s : %s" % (vm.instanceid, vm.hostname)) # then "node_started" launched_vms = vms_launched(m, run_name, "node_started") for vm in launched_vms: m.persistence.new_vm(run_name, vm) allvms = m.persistence.get_run_vms_or_none(run_name) c.log.debug("Know of %d VMs in run '%s'" % (len(allvms), run_name))
def _core(action, p, c): # ------------------------------------------------------------------------- # INSTANTIATE the rest of the needed instances # ------------------------------------------------------------------------- event_gather_cls = c.get_class_by_keyword("EventGather") event_gather = event_gather_cls(p, c) persistence = em_core_persistence.Persistence(p, c) runlogs_cls = c.get_class_by_keyword("Runlogs") runlogs = runlogs_cls(p, c) remote_svc_adapter_cls = c.get_class_by_keyword("RemoteSvcAdapter") remote_svc_adapter = remote_svc_adapter_cls(p, c) # ------------------------------------------------------------------------- # VALIDATE # ------------------------------------------------------------------------- run_name = p.get_arg_or_none(em_args.NAME) if not run_name: raise InvalidInput("The %s action requires the --name argument." % action) # Validate and load cloudinitd for all actions c.log.info("Validating '%s' action for '%s'" % (action, run_name)) event_gather.validate() persistence.validate() runlogs.validate() remote_svc_adapter.validate() modules = Modules(event_gather, persistence, runlogs, remote_svc_adapter) # Always load from cloudinit.d initially c.log.debug("Loading the launch plan for '%s'" % run_name) cloudinitd = em_core_load.get_cloudinit(p, c, modules, run_name) # ------------------------------------------------------------------------- # BRANCH on action # ------------------------------------------------------------------------- if c.dryrun: c.log.info("Performing DRYRUN '%s' for '%s'" % (action, run_name)) else: c.log.info("Performing '%s' for '%s'" % (action, run_name)) if action == ACTIONS.LOAD: c.log.info("Load only, done.") elif action == ACTIONS.UPDATE_EVENTS: em_core_eventgather.update_events(p, c, modules, run_name) elif action == ACTIONS.KILLRUN: no_fetch = p.get_arg_or_none(em_args.KILLRUN_NOFETCH) try: if not no_fetch: em_core_findworkers.find_once(p, c, modules, run_name) em_core_logfetch.fetch_all(p, c, modules, run_name, cloudinitd) except KeyboardInterrupt: raise except Exception: c.log.exception("Fetch failed, moving on to terminate anyhow") em_core_termination.terminate(p, c, modules, run_name, cloudinitd) elif action == ACTIONS.LOGFETCH: em_core_logfetch.fetch_all(p, c, modules, run_name, cloudinitd) elif action == ACTIONS.FIND_WORKERS_ONCE: em_core_findworkers.find_once(p, c, modules, run_name) elif action == ACTIONS.FETCH_KILL: em_core_findworkers.find_once(p, c, modules, run_name) em_core_fetchkill.fetch_kill(p, c, modules, run_name, cloudinitd) elif action == ACTIONS.EXECUTE_WORKLOAD_TEST: em_core_workloadtest.execute_workload_test(p, c, modules, run_name) elif action == ACTIONS.TORQUE_LOGFETCH: em_core_torquelogfetch.fetch_logs(p, c, modules, run_name) elif action == ACTIONS.FIND_VERSIONS: no_fetch = p.get_arg_or_none(em_args.KILLRUN_NOFETCH) if not no_fetch: em_core_findworkers.find_once(p, c, modules, run_name) em_core_logfetch.fetch_all(p, c, modules, run_name, cloudinitd) em_core_eventgather.update_events(p, c, modules, run_name) em_core_versions.print_versions(p, c, modules, run_name) elif action == ACTIONS.GENERATE_GRAPH: try: import em_core_generategraph except ImportError: c.log.exception("") raise IncompatibleEnvironment( "Problem with graphing dependencies: do you have " "matplotlib installed? (matplotlib is the source of the 'pylab' module)" ) em_core_generategraph.generate_graph(p, c, modules, run_name) elif action == ACTIONS.RECONFIGURE_N: em_core_reconfigure.reconfigure_n(p, c, modules, run_name, cloudinitd) elif action == ACTIONS.STATUS: # These parsable reports are not ready yet instance_report = p.get_arg_or_none(em_args.REPORT_INSTANCE) service_report = p.get_arg_or_none(em_args.REPORT_SERVICE) if instance_report and service_report: both = em_args.REPORT_INSTANCE.long_syntax + " and " + em_args.REPORT_SERVICE.long_syntax raise InvalidInput("You may only choose one status report option at a time, you choose both %s" % both) if instance_report: pass elif service_report: pass else: em_core_status.pretty_status(p, c, modules, run_name, cloudinitd) else: raise ProgrammingError("unhandled action %s" % action)
def update(self, runname): return em_core_eventgather.update_events(self.p, self.c, self.m, runname)