def _get_client(self, context): try: conf = config.new_client_from_config(context=context) except FileNotFoundError: self.log.debug("Kubernetes config file not found, attempting " "to load in-cluster configs") conf = config.load_incluster_config() return ( k8s_client.CoreV1Api(conf), k8s_client.RbacAuthorizationV1beta1Api(conf))
def __init__(self, user): cfg = '/root/.kube/' + user + '.config' kcfg = kconf.new_client_from_config(cfg) ocfg = oconf.new_client_from_config(cfg) self.o1 = openshift.client.OapiApi(ocfg) self.k1 = kubernetes.client.CoreV1Api(kcfg) path = os.path.dirname(__file__) stream = file( (os.path.join(path, '../marketplace/vlabs_template.yml')), 'r') ysrvc = yaml.load(stream) if str(ysrvc['svcsdomain']).startswith('$'): self.domain = os.getenv('SVCSDOMAIN') else: self.domain = ysrvc['svcsdomain']
def chooseprj(self): self.ocfg = oconf.new_client_from_config(self.pathcfg) api_instance = openshift.client.OapiApi(self.ocfg) selector = "namespace=v-labs" try: list = api_instance.list_project( pretty='true', label_selector=selector) ###V-LABS SELECTOR ON NAMESPACES prjs = [] for i in range(0, len(list.items)): prjs.append(list.items[i].metadata.name) return prjs except ApiException as e: print("Exception when calling OapiApi->list_project: %s\n" % e)
def __init__(self, namespace=None, user=None): config_file = '/root/.kube/' + user + '.config' self.namespace = namespace path = os.path.dirname(__file__) stream = file( (os.path.join(path, '../marketplace/vlabs_template.yml')), 'r') self.ysrvc = yaml.load(stream) custompath = os.path.join(path, "../marketplace/custom_marketplace/") for f in sorted(os.listdir(custompath)): if f.endswith(".yml"): stream2 = file((os.path.join(custompath, f)), 'r') ysrvc2 = yaml.load(stream2) for i in ysrvc2: self.ysrvc['marketplace']['apps'].append(i) else: pass self.kcfg = kconf.new_client_from_config(config_file) self.ocfg = oconf.new_client_from_config(config_file)
def _get_client(self, context): conf = config.new_client_from_config(context=context) return ( k8s_client.CoreV1Api(conf), k8s_client.RbacAuthorizationV1beta1Api(conf))
def _get_client(self, context): conf = config.new_client_from_config(context=context) return (k8s_client.CoreV1Api(conf), k8s_client.RbacAuthorizationV1beta1Api(conf))
def _get_client(self, context): conf = config.new_client_from_config(context=context) return (os_client.OapiApi(conf), k8s_client.CoreV1Api(conf))
def _get_client(self, context): conf = config.new_client_from_config(context=context) return ( os_client.OapiApi(conf), k8s_client.CoreV1Api(conf))
def __init__(self, admin): config_file = '/root/.kube/' + admin + '.config' self.kcfg = kconf.new_client_from_config(config_file) self.ocfg = oconf.new_client_from_config(config_file)
def _get_client(self, context): conf = config.new_client_from_config(context=context) token = conf.configuration.api_key.get('authorization', '').split()[-1] return (token, k8s_client.CoreV1Api(conf))