Пример #1
0
 def _detect_api_object(self, api_version):
     # Due to https://github.com/kubernetes-client/python/issues/387
     if api_version == 'apps/v1beta1':
         return client.AppsV1beta1Api()
     if api_version == 'v1':
         return client.CoreV1Api()
     if api_version == 'extensions/v1beta1':
         return client.ExtensionsV1beta1Api()
     if api_version == 'batch/v1':
         return client.BatchV1Api()
     if api_version == 'batch/v2alpha1':
         return client.BatchV2alpha1Api()
     if api_version == 'batch/v1beta1':
         return client.BatchV1beta1Api()
     if api_version == 'policy/v1beta1':
         return client.PolicyV1beta1Api()
     if api_version == 'storage.k8s.io/v1':
         return client.StorageV1Api()
     if api_version == 'apps/v1':
         return client.AppsV1Api()
     if api_version == 'autoscaling/v1':
         return client.AutoscalingV1Api()
     if api_version == 'rbac.authorization.k8s.io/v1':
         return client.RbacAuthorizationV1Api()
     if api_version == 'scheduling.k8s.io/v1alpha1':
         return client.SchedulingV1alpha1Api()
     if api_version == 'scheduling.k8s.io/v1beta1':
         return client.SchedulingV1beta1Api()
     if api_version == 'test/test':
         return K8sClientMock(self.name)
Пример #2
0
def confirm_priority_class(context):
    if context is None:
        raise SystemExit("invalid empty context for PriorityClass given")
    load_kube(context)
    api = client.SchedulingV1beta1Api()
    return general_confirm("PriorityClass", lambda: api.list_priority_class(),
                           lambda i: i.metadata.name)
Пример #3
0
 def get_resource_api(api_client: client.ApiClient = None,
                      **kwargs) -> "client.SchedulingV1beta1Api":
     """
     Returns an instance of the kubernetes API client associated with
     this object.
     """
     if api_client:
         kwargs["apl_client"] = api_client
     return client.SchedulingV1beta1Api(**kwargs)
Пример #4
0
def remove_priority_class(context, name):
    if context is None:
        raise SystemExit("invalid empty context for PriorityClass given")
    if name is None:
        raise SystemExit("invalid empty name for PriorityClass given")

    load_kube(context)
    api = client.SchedulingV1beta1Api()
    ret, status, _ = api.delete_priority_class_with_http_info(name)
    handle_status(ret, status, "PriorityClass", None, name)
Пример #5
0
def wait_for_priority_class_is_away(context, name):
    if name is None:
        raise SystemExit("invalid empty name for PriorityClass given")
    if context is None:
        raise SystemExit("invalid empty name context given")
    load_kube(context)
    print("check removal of", "PriorityClass", name)
    api = client.SchedulingV1beta1Api()
    return general_away_check(
        None, "PriorityClass", name,
        lambda: api.read_priority_class_with_http_info(name))
Пример #6
0
def create_priority_class(name, level, default=False):
    try:
        config.load_kube_config()
    except:
        config.load_incluster_config()

    api = client.SchedulingV1beta1Api()
    pretty = 'true'

    body = client.V1beta1PriorityClass(value=level, global_default=default, metadata=client.V1ObjectMeta(name=name))


    try:
        api_response = api.create_priority_class(body, pretty=pretty)
        return api_response
    except ApiException as e:
        print("Exception when calling SchedulingV1alpha1Api->create_priority_class: %s\n" % e)