コード例 #1
0
    def __init__(self, config):
        """
        Creates an instance of the Kubernetes Container Manager.

        :param config: Configuration details
        :type config: dict
        """
        ContainerManagerBase.__init__(self, config)
        self.con = requests.Session()
        token = config.get('token', None)
        if token:
            self.con.headers["Authorization"] = "Bearer {0}".format(token)
            self.logger.info('Using bearer token')
            self.logger.debug('Bearer token: {0}'.format(token))

        certificate_path = config.get('certificate_path')
        certificate_key_path = config.get('certificate_key_path')
        if certificate_path and certificate_key_path:
            self.con.cert = (certificate_path, certificate_key_path)
            self.logger.info(
                'Using client side certificate. Certificate path: {0} '
                'Certificate Key Path: {1}'.format(
                    certificate_path, certificate_key_path))

        # TODO: Verify TLS!!!
        self.con.verify = False
        self.base_uri = urljoin(config['server_url'], '/api/v1')
        self.logger.info('Kubernetes Container Manager created: {0}'.format(
            self.base_uri))
        self.logger.debug(
            'Kubernetes Container Manager: {0}'.format(self.__dict__))
コード例 #2
0
ファイル: __init__.py プロジェクト: chuanchangjia/commissaire
    def __init__(self, config):
        """
        Creates an instance of the Kubernetes Container Manager.

        :param config: Configuration information.
        :type config: commissaire.config.Config
        """
        ContainerManagerBase.__init__(self)
        self.scheme = config.kubernetes['uri'].scheme
        self.host = config.kubernetes['uri'].hostname
        self.port = config.kubernetes['uri'].port
        self.con = requests.Session()
        token = config.kubernetes.get('token', None)
        if token:
            self.con.headers["Authorization"] = "Bearer {0}".format(token)
            self.logger.info('Using bearer token')
            self.logger.debug('Bearer token: {0}'.format(token))

        certificate_path = config.kubernetes.get('certificate_path')
        certificate_key_path = config.kubernetes.get('certificate_key_path')
        if certificate_path and certificate_key_path:
            self.con.cert = (certificate_path, certificate_key_path)
            self.logger.info(
                'Using client side certificate. Certificate path: {0} '
                'Certificate Key Path: {1}'.format(
                    certificate_path, certificate_key_path))

        # TODO: Verify TLS!!!
        self.con.verify = False
        self.base_uri = '{0}://{1}:{2}/api/v1'.format(
            self.scheme, self.host, self.port)
        self.logger.info('Kubernetes Container Manager created: {0}'.format(
            self.base_uri))
        self.logger.debug(
            'Kubernetes Container Manager: {0}'.format(self.__dict__))
コード例 #3
0
ファイル: __init__.py プロジェクト: themurph/commissaire
    def __init__(self, config):
        """
        Creates an instance of the Kubernetes Container Manager.

        :param config: Configuration information.
        :type config: commissaire.config.Config
        """
        ContainerManagerBase.__init__(self)
        self.host = config.kubernetes['uri'].hostname
        self.port = config.kubernetes['uri'].port
        self.con = requests.Session()
        token = config.kubernetes['token']
        self.con.headers["Authorization"] = "Bearer {0}".format(token)
        # TODO: Verify TLS!!!
        self.con.verify = False
        self.base_uri = 'http://{0}:{1}/api/v1'.format(
            self.host, self.port)
        print('Kubernetes Container Manager: {0}'.format(
            self.__dict__))
コード例 #4
0
ファイル: __init__.py プロジェクト: cgwalters/commissaire
    def __init__(self, config):
        """
        Creates an instance of the Kubernetes Container Manager.

        :param config: Configuration information.
        :type config: commissaire.config.Config
        """
        ContainerManagerBase.__init__(self)
        self.host = config.kubernetes['uri'].hostname
        self.port = config.kubernetes['uri'].port
        self.con = requests.Session()
        token = config.kubernetes['token']
        self.con.headers["Authorization"] = "Bearer {0}".format(token)
        # TODO: Verify TLS!!!
        self.con.verify = False
        self.base_uri = 'http://{0}:{1}/api/v1'.format(self.host, self.port)
        self.logger.info('Kubernetes Container Manager created: {0}'.format(
            self.base_uri))
        self.logger.debug('Kubernetes Container Manager: {0}'.format(
            self.__dict__))