예제 #1
0
 def __init__(self, path=None):
     """
     Read the configuration.
     """
     conf = Config(AGENT_DEFAULTS, path or AgentConfig.PATH)
     conf.validate(AGENT_SCHEMA)
     Graph.__init__(self, conf)
예제 #2
0
파일: config.py 프로젝트: credativ/gofer
 def __init__(self, path=None):
     """
     Read the configuration.
     """
     conf = Config(AGENT_DEFAULTS, path or AgentConfig.PATH)
     conf.validate(AGENT_SCHEMA)
     Graph.__init__(self, conf)
예제 #3
0
def update_settings():
    """
    Setup the plugin based on the RHSM configuration.
    """
    rhsm_conf = Config(RHSM_CONFIG_PATH)
    certificate = ConsumerIdentity.read()
    if 'ca_cert_dir' in rhsm_conf['rhsm']:
        ca_cert_dir = rhsm_conf['rhsm']['ca_cert_dir']
    else:
        #handle old subscription-manager configurations
        ca_cert_dir = rhsm_conf['server']['ca_cert_dir']

    # the 'katello-default-ca.pem' is the ca used for generating the CA certs.
    # the 'candlepin-local.pem' is there for compatibility reasons (the old path where the
    # legacy installer was putting this file. If none of them is present, there is still
    # a chance the rhsm_conf['rhsm']['repo_ca_cert'] is serving as the CA for issuing
    # the client certs
    ca_candidates = [os.path.join(ca_cert_dir, 'katello-default-ca.pem'),
                     os.path.join(ca_cert_dir, 'candlepin-local.pem'),
                     rhsm_conf['rhsm']['repo_ca_cert'] % {'ca_cert_dir': ca_cert_dir}]
    existing_ca_certs = [cert for cert in ca_candidates if os.path.exists(cert)]
    if not existing_ca_certs:
       log.warn('None of the ca cert files %s found for the qpid connection' % ca_candidates)

       raise
    else:
       log.info('Using %s as the ca cert for qpid connection' % existing_ca_certs[0])

    plugin.cfg.messaging.cacert = existing_ca_certs[0]
    plugin.cfg.messaging.url = 'proton+amqps://%s:5647' % rhsm_conf['server']['hostname']
    plugin.cfg.messaging.uuid = 'pulp.agent.%s' % certificate.getConsumerId()
    bundle(certificate)
예제 #4
0
파일: agent.py 프로젝트: swipswaps/gofer
def install_plugins(url, queue, threads, auth, exchange):
    root = os.path.dirname(__file__)
    _dir = os.path.join(root, 'plugins')
    for fn in os.listdir(_dir):
        path = os.path.join(_dir, fn)
        _, ext = os.path.splitext(path)
        if ext in ('.conf', '.json'):
            conf = Config(path)
            pd = PluginDescriptor(conf)
            if pd.model.queue == 'TEST':
                pd.main.threads = threads
                pd.messaging.url = url
                pd.model.queue = queue
                pd.messaging.auth = auth
            if exchange:
                pd.messaging.exchange = exchange
            path = os.path.join(PluginDescriptor.ROOT, fn)
            with open(path, 'w') as fp:
                if ext == '.conf':
                    fp.write(str(pd))
                else:
                    json.dump(conf, fp, indent=4)
            continue
        if fn.endswith('.py'):
            f = open(path)
            plugin = f.read()
            f.close()
            path = os.path.join(PluginLoader.PATH[0], fn)
            with open(path, 'w') as fp:
                fp.write(plugin)
            continue
예제 #5
0
def update_settings():
    """
    Setup the plugin based on the RHSM configuration.
    """
    rhsm_conf = Config(RHSM_CONFIG_PATH)
    certificate = ConsumerIdentity.read()
    plugin.cfg.messaging.cacert = rhsm_conf['rhsm'][
        'repo_ca_cert'] % rhsm_conf['rhsm']
    plugin.cfg.messaging.url = 'proton+amqps://%s:5647' % rhsm_conf['server'][
        'hostname']
    plugin.cfg.messaging.uuid = 'pulp.agent.%s' % certificate.getConsumerId()
    bundle(certificate)
예제 #6
0
파일: plugin.py 프로젝트: jortel/gofer
 def load(path):
     """
     Load the specified plugin.
     :param path: A plugin descriptor path.
     :type path: str
     :return: The loaded plugin.
     :rtype: Plugin
     """
     fn = os.path.basename(path)
     name, _ = os.path.splitext(fn)
     default = dict(main=dict(name=name))
     conf = Config(PLUGIN_DEFAULTS, default, path)
     conf.validate(PLUGIN_SCHEMA)
     descriptor = PluginDescriptor(conf)
     plugin = Plugin(descriptor, path)
     if not plugin.enabled:
         log.warning('plugin:%s, DISABLED', plugin.name)
         plugin = None
     else:
         plugin = PluginLoader._load(plugin)
     return plugin
예제 #7
0
 def load(path):
     """
     Load the specified plugin.
     :param path: A plugin descriptor path.
     :type path: str
     :return: The loaded plugin.
     :rtype: Plugin
     """
     fn = os.path.basename(path)
     name, _ = os.path.splitext(fn)
     default = dict(main=dict(name=name))
     conf = Config(PLUGIN_DEFAULTS, default, path)
     conf.validate(PLUGIN_SCHEMA)
     descriptor = PluginDescriptor(conf)
     plugin = Plugin(descriptor, path)
     if plugin.enabled:
         plugin = Plugin(descriptor, path)
         plugin = PluginLoader._load(plugin)
     else:
         log.warn('plugin:%s, DISABLED', plugin.name)
         plugin = None
     return plugin
예제 #8
0
def setup_plugin():
    """
    Setup the plugin based on registration status using the RHSM configuration.
    """
    if not ConsumerIdentity.existsAndValid():
        # not registered
        return
    cfg = plugin.cfg()
    rhsm_conf = Config(RHSM_CONFIG_PATH)
    certificate = ConsumerIdentity.read()
    cfg.messaging.url = 'ssl://%s:5671' % rhsm_conf['server']['hostname']
    cfg.messaging.uuid = 'pulp.agent.%s' % certificate.getConsumerId()
    bundle(certificate)