Ejemplo n.º 1
0
    def __init__(self, hostname, protocol="https", port=8443, k_entry="api/v1", o_entry="oapi/v1",
                 debug=False, verify_ssl=False, **kwargs):
        super(Openshift, self).__init__(kwargs)
        self.hostname = hostname
        self.username = kwargs.get('username', '')
        self.password = kwargs.get('password', '')
        self.base_url = kwargs.get('base_url', None)
        self.token = kwargs.get('token', '')
        self.auth = self.token if self.token else (self.username, self.password)
        self.old_k_api = self.k_api = ContainerClient(hostname, self.auth, protocol, port, k_entry)
        self.old_o_api = self.o_api = ContainerClient(hostname, self.auth, protocol, port, o_entry)
        if 'new_client' in kwargs:
            url = '{proto}://{host}:{port}'.format(proto=protocol, host=self.hostname, port=port)
            ociclient.configuration.host = url
            kubeclient.configuration.host = url

            ociclient.configuration.verify_ssl = verify_ssl
            kubeclient.configuration.verify_ssl = verify_ssl

            kubeclient.configuration.debug = debug
            ociclient.configuration.debug = debug

            token = 'Bearer {token}'.format(token=self.token)
            ociclient.configuration.api_key['authorization'] = token
            kubeclient.configuration.api_key['authorization'] = token
            self.ociclient = ociclient
            self.kclient = kubeclient
            self.o_api = ociclient.OapiApi()
            self.k_api = kubeclient.CoreV1Api()

        self.api = self.k_api  # default api is the kubernetes one for Kubernetes-class requests
        self.list_image_openshift = self.list_docker_image  # For backward compatibility
Ejemplo n.º 2
0
 def __init__(self,
         hostname, protocol="https", port=8443, k_entry="api/v1", o_entry="oapi/v1", **kwargs):
     self.hostname = hostname
     self.username = kwargs.get('username', '')
     self.password = kwargs.get('password', '')
     self.token = kwargs.get('token', '')
     self.auth = self.token if self.token else (self.username, self.password)
     self.k_api = ContainerClient(hostname, self.auth, protocol, port, k_entry)
     self.o_api = ContainerClient(hostname, self.auth, protocol, port, o_entry)
     self.api = self.k_api  # default api is the kubernetes one for Kubernetes-class requests
     self.list_image_openshift = self.list_docker_image  # For backward compatibility
Ejemplo n.º 3
0
 def __init__(self, hostname, protocol="https", port=6443, entry='api/v1', **kwargs):
     self.hostname = hostname
     self.username = kwargs.get('username', '')
     self.password = kwargs.get('password', '')
     self.token = kwargs.get('token', '')
     self.auth = self.token if self.token else (self.username, self.password)
     self.api = ContainerClient(hostname, self.auth, protocol, port, entry)
     super(Kubernetes, self).__init__(kwargs)