示例#1
0
 def __init__(self):
     host = cfg.server.host
     port = int(cfg.server.port)
     cert = os.path.join(
         cfg.filesystem.id_cert_dir,
         cfg.filesystem.id_cert_filename)
     connection = PulpConnection(host, port, cert_filename=cert)
     Bindings.__init__(self, connection)
示例#2
0
 def __init__(self):
     cfg = Config(CONFIG_PATH)
     server = cfg['server']
     host = server['host']
     port = int(server['port'])
     files = cfg['filesystem']
     cert = os.path.join(files['id_cert_dir'], files['id_cert_filename'])
     connection = PulpConnection(host, port, cert_filename=cert)
     PulpBindings.__init__(self, connection)
示例#3
0
文件: model.py 项目: kbotc/pulp
 def __init__(self):
     cfg = Config(CONFIG_PATH)
     server = cfg['server']
     host = server['host']
     port = int(server['port'])
     files = cfg['filesystem']
     cert = os.path.join(files['id_cert_dir'], files['id_cert_filename'])
     connection = PulpConnection(host, port, cert_filename=cert)
     PulpBindings.__init__(self, connection)
示例#4
0
文件: pulpplugin.py 项目: omps/pulp
 def __init__(self):
     host = cfg.server.host
     port = int(cfg.server.port)
     verify_ssl = parse_bool(cfg.server.verify_ssl)
     ca_path = cfg.server.ca_path
     cert = os.path.join(cfg.filesystem.id_cert_dir, cfg.filesystem.id_cert_filename)
     connection = PulpConnection(host, port, cert_filename=cert, verify_ssl=verify_ssl,
                                 ca_path=ca_path)
     Bindings.__init__(self, connection)
示例#5
0
 def __init__(self):
     host = cfg['server']['host']
     port = int(cfg['server']['port'])
     cert = os.path.join(
         cfg['filesystem']['id_cert_dir'],
         cfg['filesystem']['id_cert_filename'])
     ssl = cfg.parse_bool(cfg['server']['verify_ssl'])
     connection = PulpConnection(host, port, cert_filename=cert, verify_ssl=ssl)
     Bindings.__init__(self, connection)
示例#6
0
 def __init__(self):
     host = cfg['server']['host']
     port = int(cfg['server']['port'])
     cert = os.path.join(
         cfg['filesystem']['id_cert_dir'],
         cfg['filesystem']['id_cert_filename'])
     ssl = cfg.parse_bool(cfg['server']['verify_ssl'])
     connection = PulpConnection(host, port, cert_filename=cert, verify_ssl=ssl)
     Bindings.__init__(self, connection)
示例#7
0
 def __init__(self):
     host = cfg.server.host
     port = int(cfg.server.port)
     verify_ssl = parse_bool(cfg.server.verify_ssl)
     ca_path = cfg.server.ca_path
     cert = os.path.join(cfg.filesystem.id_cert_dir, cfg.filesystem.id_cert_filename)
     connection = PulpConnection(host, port, cert_filename=cert, verify_ssl=verify_ssl,
                                 ca_path=ca_path)
     Bindings.__init__(self, connection)
示例#8
0
def pulp_bindings():
    """
    Get a pulp bindings object for this node.
    Properties defined in the pulp server configuration are used
    when not defined in the node configuration.
    :return: A pulp bindings object.
    :rtype: Bindings
    """
    node_conf = read_config()
    oauth = node_conf.oauth
    verify_ssl = parse_bool(node_conf.main.verify_ssl)
    ca_path = node_conf.main.ca_path
    host = pulp_conf.get('server', 'server_name')
    key = pulp_conf.get('oauth', 'oauth_key')
    secret = pulp_conf.get('oauth', 'oauth_secret')
    connection = PulpConnection(
        host=host,
        port=443,
        oauth_key=key,
        oauth_secret=secret,
        oauth_user=oauth.user_id,
        verify_ssl=verify_ssl,
        ca_path=ca_path)
    bindings = Bindings(connection)
    return bindings
示例#9
0
    def setUp(self):
        super(PulpClientTests, self).setUp()

        self.config = SafeConfigParser()
        config_filename = os.path.join(DATA_DIR, 'test-override-client.conf')
        self.config = Config(config_filename)

        self.server_mock = mock.Mock()
        self.pulp_connection = PulpConnection('',
                                              server_wrapper=self.server_mock)
        self.bindings = Bindings(self.pulp_connection)

        # Disabling color makes it easier to grep results since the character codes aren't there
        self.recorder = okaara.prompt.Recorder()
        self.prompt = PulpPrompt(enable_color=False,
                                 output=self.recorder,
                                 record_tags=True)

        self.logger = logging.getLogger('pulp')
        self.exception_handler = ExceptionHandler(self.prompt, self.config)

        self.context = ClientContext(self.bindings, self.config, self.logger,
                                     self.prompt, self.exception_handler)

        self.cli = PulpCli(self.context)
        self.context.cli = self.cli
示例#10
0
def _create_bindings(config, logger, username, password):
    """
    @return: bindings with a fully configured Pulp connection
    @rtype:  pulp.bindings.bindings.Bindings
    """

    # Extract all of the necessary values
    hostname = config['server']['host']
    port = int(config['server']['port'])

    cert_dir = config['filesystem']['id_cert_dir']
    cert_name = config['filesystem']['id_cert_filename']

    cert_dir = os.path.expanduser(
        cert_dir)  # this will likely be in a user directory
    cert_filename = os.path.join(cert_dir, cert_name)

    # If the certificate doesn't exist, don't pass it to the connection creation
    if not os.path.exists(cert_filename):
        cert_filename = None

    call_log = None
    if config.has_option('logging', 'call_log_filename'):
        filename = config['logging']['call_log_filename']
        filename = os.path.expanduser(filename)  # also likely in a user dir

        # Make sure the parent directories for the log files exist
        dirname = os.path.dirname(filename)
        if not os.path.exists(dirname):
            os.makedirs(dirname)

        handler = logging.handlers.RotatingFileHandler(filename,
                                                       mode='w',
                                                       maxBytes=1048576,
                                                       backupCount=2)
        handler.setFormatter(
            logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))

        call_log = logging.getLogger('call_log')
        call_log.addHandler(handler)
        call_log.setLevel(logging.INFO)

    # Create the connection and bindings
    verify_ssl = config.parse_bool(config['server']['verify_ssl'])
    ca_path = config['server']['ca_path']
    conn = PulpConnection(hostname,
                          port,
                          username=username,
                          password=password,
                          cert_filename=cert_filename,
                          logger=logger,
                          api_responses_logger=call_log,
                          verify_ssl=verify_ssl,
                          ca_path=ca_path)
    bindings = Bindings(conn)

    return bindings
示例#11
0
def parent_bindings(host, port=443):
    """
    Get a pulp bindings object for the parent node.
    :param host: The hostname of IP of the parent server.
    :type host: str
    :param port: The TCP port number.
    :type port: int
    :return: A pulp bindings object.
    :rtype: Bindings
    """
    node_conf = node_configuration()
    oauth = node_conf.parent_oauth
    connection = PulpConnection(host=host,
                                port=port,
                                oauth_key=oauth.key,
                                oauth_secret=oauth.secret,
                                oauth_user=oauth.user_id)
    bindings = Bindings(connection)
    return bindings
示例#12
0
 def setUp(self):
     TestCase.setUp(self)
     self.config = SafeConfigParser()
     path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data',
                         'client.conf')
     self.config = Config(path)
     self.server_mock = mock.Mock()
     self.pulp_connection = \
         PulpConnection('', server_wrapper=self.server_mock)
     self.bindings = Bindings(self.pulp_connection)
     self.recorder = okaara.prompt.Recorder()
     self.prompt = PulpPrompt(enable_color=False,
                              output=self.recorder,
                              record_tags=True)
     self.logger = logging.getLogger('pulp')
     self.exception_handler = ExceptionHandler(self.prompt, self.config)
     self.context = ClientContext(self.bindings, self.config, self.logger,
                                  self.prompt, self.exception_handler)
     self.cli = PulpCli(self.context)
     self.context.cli = self.cli
示例#13
0
文件: launcher.py 项目: W3SS/pulp
def _create_bindings(config, cli_logger, username, password, verbose=None):
    """
    @return: bindings with a fully configured Pulp connection
    @rtype:  pulp.bindings.bindings.Bindings
    """

    # Extract all of the necessary values
    hostname = config['server']['host']
    port = int(config['server']['port'])

    cert_dir = config['filesystem']['id_cert_dir']
    cert_name = config['filesystem']['id_cert_filename']

    cert_dir = os.path.expanduser(cert_dir)  # this will likely be in a user directory
    cert_filename = os.path.join(cert_dir, cert_name)

    # If the certificate doesn't exist, don't pass it to the connection creation
    if not os.path.exists(cert_filename):
        cert_filename = None

    api_logger = None
    if verbose and verbose > 1:
        api_log_handler = logging.StreamHandler(sys.stderr)
        api_log_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))

        api_logger = logging.getLogger('call_log')
        api_logger.addHandler(api_log_handler)
        api_logger.setLevel(logging.INFO)

    # Create the connection and bindings
    verify_ssl = config.parse_bool(config['server']['verify_ssl'])
    ca_path = config['server']['ca_path']
    path_prefix = config['server']['api_prefix']
    conn = PulpConnection(
        hostname, port, username=username, password=password, cert_filename=cert_filename,
        logger=cli_logger, api_responses_logger=api_logger, verify_ssl=verify_ssl,
        ca_path=ca_path, path_prefix=path_prefix)
    bindings = Bindings(conn)

    return bindings
示例#14
0
def parent_bindings(host, port=443):
    """
    Get a pulp bindings object for the parent node.
    :param host: The hostname of IP of the parent server.
    :type host: str
    :param port: The TCP port number.
    :type port: int
    :return: A pulp bindings object.
    :rtype: Bindings
    """
    node_conf = read_config()
    oauth = node_conf.parent_oauth
    verify_ssl = parse_bool(node_conf.main.verify_ssl)
    ca_path = node_conf.main.ca_path
    connection = PulpConnection(
        host=host,
        port=port,
        oauth_key=oauth.key,
        oauth_secret=oauth.secret,
        oauth_user=oauth.user_id,
        verify_ssl=verify_ssl,
        ca_path=ca_path)
    bindings = Bindings(connection)
    return bindings
示例#15
0
 def __init__(self):
     host = cfg.server.host
     port = int(cfg.server.port)
     cert = os.path.join(cfg.filesystem.id_cert_dir, cfg.filesystem.id_cert_filename)
     connection = PulpConnection(host, port, cert_filename=cert)
     Bindings.__init__(self, connection)
示例#16
0
 def __init__(self):
     host = socket.gethostname()
     port = 443
     cert = '/etc/pki/pulp/nodes/local.crt'
     connection = PulpConnection(host, port, cert_filename=cert)
     PulpBindings.__init__(self, connection)
示例#17
0
文件: model.py 项目: kbotc/pulp
 def __init__(self):
     host = socket.gethostname()
     port = 443
     cert = '/etc/pki/pulp/nodes/local.crt'
     connection = PulpConnection(host, port, cert_filename=cert)
     PulpBindings.__init__(self, connection)
示例#18
0
 def __init__(self):
     host = cfg.rest.host
     port = int(cfg.rest.port)
     cert = cfg.rest.clientcert
     connection = PulpConnection(host, port, cert_filename=cert)
     Bindings.__init__(self, connection)
示例#19
0
def create_bindings():
    mock_context = mock.MagicMock()
    mock_context.server = Bindings(mock.MagicMock())
    return mock_context