Exemplo n.º 1
0
    def test_unbind(self, repolib_unbind, bind_report):
        options = {}
        conduit = MagicMock(autospec=Conduit)
        repo_id = 'animals'
        cfg = {
            'filesystem': {
                'repo_file': 'pulp.repo',
                'mirror_list_dir': '/tmp/mirror-list',
                'gpg_keys_dir': '/tmp/gpg',
                'cert_dir': '/tmp/certs',
            }
        }
        cfg = Config(cfg)
        conduit.get_consumer_config.return_value = cfg

        # test
        handler = bind.RepoHandler({})
        report = handler.unbind(conduit, repo_id, options)

        # validation
        cfg = cfg.graph()
        bind_report.assert_called_once_with(repo_id)
        repolib_unbind.assert_called_once_with(
            cfg.filesystem.repo_file,
            os.path.join(cfg.filesystem.mirror_list_dir, repo_id),
            cfg.filesystem.gpg_keys_dir, cfg.filesystem.cert_dir, repo_id)
        bind_report.return_value.set_succeeded.assert_called_once_with()
        self.assertEqual(bind_report.return_value, report)
Exemplo n.º 2
0
    def test_unbind(self, repolib_unbind, bind_report):
        options = {}
        conduit = MagicMock(autospec=Conduit)
        repo_id = 'animals'
        cfg = {
            'filesystem': {
                'repo_file': 'pulp.repo',
                'mirror_list_dir': '/tmp/mirror-list',
                'gpg_keys_dir': '/tmp/gpg',
                'cert_dir': '/tmp/certs',
            }
        }
        cfg = Config(cfg)
        conduit.get_consumer_config.return_value = cfg

        # test
        handler = bind.RepoHandler({})
        report = handler.unbind(conduit, repo_id, options)

        # validation
        cfg = cfg.graph()
        bind_report.assert_called_once_with(repo_id)
        repolib_unbind.assert_called_once_with(
            cfg.filesystem.repo_file,
            os.path.join(cfg.filesystem.mirror_list_dir, repo_id),
            cfg.filesystem.gpg_keys_dir,
            cfg.filesystem.cert_dir,
            repo_id)
        bind_report.return_value.set_succeeded.assert_called_once_with()
        self.assertEqual(bind_report.return_value, report)
Exemplo n.º 3
0
def node_configuration(path=NODE_CONFIGURATION_PATH):
    """
    Get the node configuration object.
    The node configuration is overridden using values from the pulp
    consumer.conf and defaulted using server.conf as appropriate.
    :param path: The optional path to the configuration.
    :return: The configuration object.
    :rtype: pulp.common.config.Graph
    """
    cfg = Config(path)
    cfg.validate(NODE_SCHEMA)
    return cfg.graph()
Exemplo n.º 4
0
    def test_bind(self, repolib_bind, urls, bind_report):
        options = {}
        conduit = MagicMock(autospec=Conduit)
        repo_id = 'animals'
        repo_name = 'Animals'
        cfg = {
            'server': {
                'verify_ssl': 'true'
            },
            'filesystem': {
                'repo_file': 'pulp.repo',
                'mirror_list_dir': '/tmp/mirror-list',
                'gpg_keys_dir': '/tmp/gpg',
                'cert_dir': '/tmp/certs',
            }
        }
        cfg = Config(cfg)
        conduit.get_consumer_config.return_value = cfg
        details = {
            'repo_name': repo_name,
            'protocols': ['https'],
            'server_name': 'content-world',
            'relative_path': 'relative/path'
        }
        binding = {
            'type_id': 'dog',
            'repo_id': repo_id,
            'details': details
        }
        urls.return_value = ['https://content-world']

        # test
        handler = bind.RepoHandler({})
        report = handler.bind(conduit, binding, options)

        # validation
        cfg = cfg.graph()
        bind_report.assert_called_once_with(repo_id)
        repolib_bind.assert_called_once_with(
            cfg.filesystem.repo_file,
            os.path.join(cfg.filesystem.mirror_list_dir, repo_id),
            cfg.filesystem.gpg_keys_dir,
            cfg.filesystem.cert_dir,
            repo_id,
            repo_name,
            urls.return_value,
            details.get('gpg_keys', {}),
            details.get('client_cert'),
            len(urls.return_value) > 0,
            verify_ssl=True,
            ca_path=cfg.server.ca_path)
        bind_report.return_value.set_succeeded.assert_called_once_with()
        self.assertEqual(bind_report.return_value, report)
Exemplo n.º 5
0
def node_configuration(path=NODE_CONFIGURATION_PATH):
    """
    Get the node configuration object.
    The node configuration is overridden using values from the pulp
    consumer.conf and defaulted using server.conf as appropriate.
    :param path: The optional path to the configuration.
    :return: The configuration object.
    :rtype: pulp.common.config.Graph
    """
    cfg = Config(path)
    cfg.validate(NODE_SCHEMA)
    return cfg.graph()
Exemplo n.º 6
0
def read_config(path=NODE_CONFIGURATION_PATH, validate=True):
    """
    Get the node configuration object.
    The node configuration is overridden using values from the pulp
    consumer.conf and defaulted using server.conf as appropriate.
    :param path: The optional path to the configuration.
    :return: The configuration object.
    :rtype: pulp.common.config.Graph
    """
    config = Config(DEFAULT)
    config.update(Config(path))
    if validate:
        config.validate(SCHEMA)
    return config.graph()
Exemplo n.º 7
0
def read_config(path=NODE_CONFIGURATION_PATH, validate=True):
    """
    Get the node configuration object.
    The node configuration is overridden using values from the pulp
    consumer.conf and defaulted using server.conf as appropriate.
    :param path: The optional path to the configuration.
    :return: The configuration object.
    :rtype: pulp.common.config.Graph
    """
    config = Config(DEFAULT)
    config.update(Config(path))
    if validate:
        config.validate(SCHEMA)
    return config.graph()
Exemplo n.º 8
0
    def test_bind(self, repolib_bind, urls, bind_report):
        options = {}
        conduit = MagicMock(autospec=Conduit)
        repo_id = 'animals'
        repo_name = 'Animals'
        cfg = {
            'server': {
                'verify_ssl': 'true'
            },
            'filesystem': {
                'repo_file': 'pulp.repo',
                'mirror_list_dir': '/tmp/mirror-list',
                'gpg_keys_dir': '/tmp/gpg',
                'cert_dir': '/tmp/certs',
            }
        }
        cfg = Config(cfg)
        conduit.get_consumer_config.return_value = cfg
        details = {
            'repo_name': repo_name,
            'protocols': ['https'],
            'server_name': 'content-world',
            'relative_path': 'relative/path'
        }
        binding = {'type_id': 'dog', 'repo_id': repo_id, 'details': details}
        urls.return_value = ['https://content-world']

        # test
        handler = bind.RepoHandler({})
        report = handler.bind(conduit, binding, options)

        # validation
        cfg = cfg.graph()
        bind_report.assert_called_once_with(repo_id)
        repolib_bind.assert_called_once_with(
            cfg.filesystem.repo_file,
            os.path.join(cfg.filesystem.mirror_list_dir, repo_id),
            cfg.filesystem.gpg_keys_dir,
            cfg.filesystem.cert_dir,
            repo_id,
            repo_name,
            urls.return_value,
            details.get('gpg_keys', {}),
            details.get('client_cert'),
            len(urls.return_value) > 0,
            verify_ssl=True,
            ca_path=cfg.server.ca_path)
        bind_report.return_value.set_succeeded.assert_called_once_with()
        self.assertEqual(bind_report.return_value, report)
Exemplo n.º 9
0
    def test_clean(self, delete, clean_report):
        conduit = MagicMock(autospec=Conduit)
        cfg = {
            'filesystem': {
                'repo_file': 'pulp.repo',
            }
        }
        cfg = Config(cfg)
        conduit.get_consumer_config.return_value = cfg

        # test
        handler = bind.RepoHandler({})
        report = handler.clean(conduit)

        # validation
        cfg = cfg.graph()
        clean_report.assert_called_once_with()
        delete.assert_called_once_with(cfg.filesystem.repo_file)
        clean_report.return_value.set_succeeded.assert_called_once_with()
        self.assertEqual(clean_report.return_value, report)
Exemplo n.º 10
0
    def test_clean(self, delete, clean_report):
        conduit = MagicMock(autospec=Conduit)
        cfg = {
            'filesystem': {
                'repo_file': 'pulp.repo',
            }
        }
        cfg = Config(cfg)
        conduit.get_consumer_config.return_value = cfg

        # test
        handler = bind.RepoHandler({})
        report = handler.clean(conduit)

        # validation
        cfg = cfg.graph()
        clean_report.assert_called_once_with()
        delete.assert_called_once_with(cfg.filesystem.repo_file)
        clean_report.return_value.set_succeeded.assert_called_once_with()
        self.assertEqual(clean_report.return_value, report)
Exemplo n.º 11
0
 def node_configuration(self):
     path = os.path.join(self.parentfs, 'node.crt')
     with open(path, 'w+') as fp:
         fp.write(NODE_CERTIFICATE)
     node_conf = Config({'main': {constants.NODE_CERTIFICATE: path}})
     return node_conf.graph()
Exemplo n.º 12
0
 def node_configuration(self):
     path = os.path.join(self.parentfs, 'node.crt')
     with open(path, 'w+') as fp:
         fp.write(NODE_CERTIFICATE)
     node_conf = Config({'main': {constants.NODE_CERTIFICATE: path}})
     return node_conf.graph()
Exemplo n.º 13
0
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#

import os
from yum.plugins import TYPE_CORE
from rhsm.profile import get_profile
from pulp.bindings.server import PulpConnection
from pulp.bindings.bindings import Bindings
from pulp.common.bundle import Bundle as BundleImpl
from pulp.common.config import Config

requires_api_version = '2.5'
plugin_type = (TYPE_CORE,)
cfg = Config('/etc/pulp/consumer/consumer.conf')
cfg = cfg.graph()

#
# Pulp Integration
#

class Bundle(BundleImpl):
    """
    Consumer certificate (bundle)
    """

    def __init__(self):
        path = os.path.join(
            cfg.filesystem.id_cert_dir,
            cfg.filesystem.id_cert_filename)
        BundleImpl.__init__(self, path)