Exemplo n.º 1
0
    def __init__(self, opts):
        if opts.conf:
            config = opts.conf
        else:
            config = None

        ac = get_all_configs(config)

        p_cls = get_class_by_keyword("Parameters", allconfigs=ac)
        self.p = p_cls(ac, opts)

        c_cls = get_class_by_keyword("Common", allconfigs=ac)
        self.c = c_cls(self.p)

        event_gather_cls = self.c.get_class_by_keyword("EventGather")
        event_gather = event_gather_cls(self.p, self.c)

        persistence = em_core_persistence.Persistence(self.p, self.c)

        runlogs_cls = self.c.get_class_by_keyword("Runlogs")
        runlogs = runlogs_cls(self.p, self.c)

        remote_svc_adapter_cls = self.c.get_class_by_keyword("RemoteSvcAdapter")
        remote_svc_adapter = remote_svc_adapter_cls(self.p, self.c)

        event_gather.validate()
        persistence.validate()
        runlogs.validate()
        remote_svc_adapter.validate()

        self.m = Modules(event_gather, persistence, runlogs, remote_svc_adapter)
Exemplo n.º 2
0
def core(opts, dbgmsgs=None):
    """Run epumgmt.
    
    From here 'down' there is no concept of a commandline program, only
    'args' which could be coming from any kind of protocol based request.
    
    To make such a thing, construct an opts object with the expected
    member names and values and pass it in to this method.
    
    See the 'em_args' module and the defaults 'Parameters' implementations to
    fully understand arg intake.  See the 'em_cmdline' module to see how args
    are taken in and how the result of the program (no exception or exception)
    is translated into a return code.
    """

    # -------------------------------------------------------------------------
    # SETUP Parameters
    # -------------------------------------------------------------------------

    if not opts:
        raise InvalidInput("No arguments")

    # in the default deployment, this is added by the .sh script wrapper
    if not opts.conf:
        config = get_default_config()
    else:
        config = opts.conf

    ac = get_all_configs(config)

    p_cls = get_class_by_keyword("Parameters", allconfigs=ac)
    p = p_cls(ac, opts)

    # -------------------------------------------------------------------------
    # REQUIRED arguments
    # -------------------------------------------------------------------------

    # --conf is also required; already checked for above

    given_action = p.get_arg_or_none(em_args.ACTION)
    if not given_action:
        em_optparse.print_help()
        msg = "You must specify an action as one of your arguments"
        raise InvalidInput(msg)

    action = validate_action(given_action)

    # -------------------------------------------------------------------------
    # Common
    # -------------------------------------------------------------------------

    c_cls = get_class_by_keyword("Common", allconfigs=ac)
    c = c_cls(p)

    # now there is a logger finally:
    if dbgmsgs:
        c.log.debug(dbgmsgs)

    try:
        _core(action, p, c)
    except:
        # Important for invocation logs to also record any problem
        c.log.exception("")
        raise
Exemplo n.º 3
0
def get_default_ac():
    conf_file = get_default_config()
    ac = get_all_configs(conf_file)
    return ac
Exemplo n.º 4
0
def get_parameters(confpath):
    # mini implementation of the dependency injection used in the real program:
    allconfs = get_all_configs(confpath)
    p_cls = get_class_by_keyword("Parameters", allconfigs=allconfs)
    return p_cls(allconfs, None)
Exemplo n.º 5
0
def get_allconfigs():
    conf_file = epumgmt.api.get_default_config()
    ac = get_all_configs(conf_file)
    return ac