def get_e2e_configuration(): config = Configuration() config.host = None if os.path.exists( os.path.expanduser(kube_config.KUBE_CONFIG_DEFAULT_LOCATION)): kube_config.load_kube_config(client_configuration=config) else: print('Unable to load config from %s' % kube_config.KUBE_CONFIG_DEFAULT_LOCATION) for url in [ 'https://%s:8443' % DEFAULT_E2E_HOST, 'http://%s:8080' % DEFAULT_E2E_HOST ]: try: urllib3.PoolManager().request('GET', url) config.host = url config.verify_ssl = False urllib3.disable_warnings() break except urllib3.exceptions.HTTPError: pass if config.host is None: raise unittest.SkipTest('Unable to find a running Kubernetes instance') print('Running test against : %s' % config.host) config.assert_hostname = False return config
def build(self, url=None): config = Configuration() config.host = None if os.path.exists( os.path.expanduser(kube_config.KUBE_CONFIG_DEFAULT_LOCATION)): kube_config.load_kube_config(client_configuration=config) else: print('Unable to load config from %s' % kube_config.KUBE_CONFIG_DEFAULT_LOCATION) if url is None: url = 'http://%s:8085' % Config.DEFAULT_HOST try: urllib3.PoolManager().request('GET', url) config.host = url config.verify_ssl = False urllib3.disable_warnings() except urllib3.exceptions.HTTPError: raise urllib3.exceptions.HTTPError( 'Unable to find a running Kubernetes instance') self.config = config #Resetting old Client & Related API's self.clnt = None # api_manager.reset() print('Running test against : %s' % config.host) return config
def get_e2e_configuration(): config = Configuration() config.host = None if os.path.exists( os.path.expanduser(kube_config.KUBE_CONFIG_DEFAULT_LOCATION)): kube_config.load_kube_config(client_configuration=config) else: print('Unable to load config from %s' % kube_config.KUBE_CONFIG_DEFAULT_LOCATION) for url in ['https://%s:8443' % DEFAULT_E2E_HOST, 'http://%s:8080' % DEFAULT_E2E_HOST]: try: urllib3.PoolManager().request('GET', url) config.host = url config.verify_ssl = False urllib3.disable_warnings() break except urllib3.exceptions.HTTPError: pass if config.host is None: raise unittest.SkipTest('Unable to find a running Kubernetes instance') print('Running test against : %s' % config.host) config.assert_hostname = False return config
with open(os.path.join(service_account_path, 'namespace')) as fp: namespace = fp.read().strip() # Initialise client for the REST API used doing configuration. # # XXX Currently have a workaround here for OpenShift 4.0 beta versions # which disables verification of the certificate. If don't use this the # Python openshift/kubernetes clients will fail. We also disable any # warnings from urllib3 to get rid of the noise in the logs this creates. load_incluster_config() import urllib3 urllib3.disable_warnings() instance = Configuration() instance.verify_ssl = False Configuration.set_default(instance) api_client = DynamicClient(ApiClient()) image_stream_resource = api_client.resources.get( api_version='image.openshift.io/v1', kind='ImageStream') # Helper function for determining the correct name for the image. We # need to do this for references to image streams because of the image # lookup policy often not being correctly setup on OpenShift clusters. def resolve_image_name(name): # If the image name contains a slash, we assume it is already # referring to an image on some image registry. Even if it does