Esempio n. 1
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
Esempio n. 2
0
    def test_read(self, fake_config):
        # test
        cfg = read_config()

        # validation
        calls = fake_config.call_args_list
        self.assertEqual(len(calls), 2)
        self.assertEqual(calls[0][0][0], DEFAULT)
        self.assertEqual(calls[1][0][0], NODE_CONFIGURATION_PATH)
        fake_config().validate.assert_called_with(SCHEMA)
        self.assertEqual(cfg, fake_config().graph())
Esempio n. 3
0
    def test_read_no_validation(self, fake_config):
        path = '/tmp/abc'

        # test
        cfg = read_config(path=path, validate=False)

        # validation
        calls = fake_config.call_args_list
        self.assertEqual(len(calls), 2)
        self.assertEqual(calls[0][0][0], DEFAULT)
        self.assertEqual(calls[1][0][0], path)
        self.assertFalse(fake_config().validate.called)
        self.assertEqual(cfg, fake_config().graph())
Esempio n. 4
0
    def test_read_path(self, fake_config):
        path = '/tmp/abc'

        # test
        cfg = read_config(path=path)

        # validation
        calls = fake_config.call_args_list
        self.assertEqual(len(calls), 2)
        self.assertEqual(calls[0][0][0], DEFAULT)
        self.assertEqual(calls[1][0][0], path)
        fake_config().validate.assert_called_with(SCHEMA)
        self.assertEqual(cfg, fake_config().graph())
Esempio n. 5
0
 def _inject_parent_settings(self, options):
     """
     Inject the parent settings into the options.
     Add the pulp server host and port information to the options.
     Used by the agent handler to make REST calls back to the parent.
     :param options: An options dictionary.
     :type options: dict
     """
     port = 443
     host = pulp_conf.get("server", "server_name")
     node_conf = read_config()
     path = node_conf.main.node_certificate
     with open(path) as fp:
         node_certificate = fp.read()
     settings = {constants.HOST: host, constants.PORT: port, constants.NODE_CERTIFICATE: node_certificate}
     options[constants.PARENT_SETTINGS] = settings
Esempio n. 6
0
File: nodes.py Progetto: omps/pulp
 def _inject_parent_settings(self, options):
     """
     Inject the parent settings into the options.
     Add the pulp server host and port information to the options.
     Used by the agent handler to make REST calls back to the parent.
     :param options: An options dictionary.
     :type options: dict
     """
     port = 443
     host = pulp_conf.get('server', 'server_name')
     node_conf = read_config()
     path = node_conf.main.node_certificate
     with open(path) as fp:
         node_certificate = fp.read()
     settings = {
         constants.HOST: host,
         constants.PORT: port,
         constants.NODE_CERTIFICATE: node_certificate,
     }
     options[constants.PARENT_SETTINGS] = settings
Esempio n. 7
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