diff --git a/class_generator/schema/__resources-mappings.json.gz b/class_generator/schema/__resources-mappings.json.gz index 54e80ac191..de771fd544 100644 Binary files a/class_generator/schema/__resources-mappings.json.gz and b/class_generator/schema/__resources-mappings.json.gz differ diff --git a/ocp_resources/cluster_queue.py b/ocp_resources/cluster_queue.py new file mode 100644 index 0000000000..b52a1b2ef8 --- /dev/null +++ b/ocp_resources/cluster_queue.py @@ -0,0 +1,157 @@ +# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md + + +from typing import Any + +from ocp_resources.resource import Resource + + +class ClusterQueue(Resource): + """ + ClusterQueue is the Schema for the clusterQueue API. + """ + + api_group: str = Resource.ApiGroup.KUEUE_X_K8S_IO + + def __init__( + self, + admission_checks: list[Any] | None = None, + admission_checks_strategy: dict[str, Any] | None = None, + admission_scope: dict[str, Any] | None = None, + cohort: str | None = None, + cohort_name: str | None = None, + fair_sharing: dict[str, Any] | None = None, + flavor_fungibility: dict[str, Any] | None = None, + namespace_selector: dict[str, Any] | None = None, + preemption: dict[str, Any] | None = None, + queueing_strategy: str | None = None, + resource_groups: list[Any] | None = None, + stop_policy: str | None = None, + **kwargs: Any, + ) -> None: + r""" + Args: + admission_checks (list[Any]): admissionChecks lists the AdmissionChecks required by this + ClusterQueue. Cannot be used along with AdmissionCheckStrategy. + Available in kueue.x-k8s.io/v1beta1. + + admission_checks_strategy (dict[str, Any]): admissionCheckStrategy defines a list of strategies to determine which + ResourceFlavors require AdmissionChecks. + + admission_scope (dict[str, Any]): admissionScope indicates whether the ClusterQueue participates in + AdmissionFairSharing. Available in kueue.x-k8s.io/v1beta2+. + + cohort (str): cohort that this ClusterQueue belongs to. CQs that belong to the same + cohort can borrow unused resources from each other. + Available in kueue.x-k8s.io/v1beta1. + + cohort_name (str): cohortName that this ClusterQueue belongs to. CQs that belong to the + same cohort can borrow unused resources from each other. A CQ can + be a member of a single borrowing cohort. A workload submitted to + a queue referencing this CQ can borrow quota from any CQ in the + cohort. Only quota for the [resource, flavor] pairs listed in the + CQ can be borrowed. If empty, this ClusterQueue cannot borrow from + any other ClusterQueue and vice versa. A cohort is a name that + links CQs together, but it doesn't reference any object. + Available in kueue.x-k8s.io/v1beta2+. + + fair_sharing (dict[str, Any]): fairSharing defines the properties of the ClusterQueue when + participating in FairSharing. The values are only relevant if + FairSharing is enabled in the Kueue configuration. + + flavor_fungibility (dict[str, Any]): flavorFungibility defines whether a workload should try the next + flavor before borrowing or preempting in the flavor being + evaluated. + + namespace_selector (dict[str, Any]): namespaceSelector defines which namespaces are allowed to submit + workloads to this clusterQueue. Beyond this basic support for + policy, a policy agent like Gatekeeper should be used to enforce + more advanced policies. Defaults to null which is a nothing + selector (no namespaces eligible). If set to an empty selector + `{}`, then all namespaces are eligible. + + preemption (dict[str, Any]): preemption defines the preemption policies for the ClusterQueue. + + queueing_strategy (str): QueueingStrategy indicates the queueing strategy of the workloads + across the queues in this ClusterQueue. Current Supported + Strategies: - StrictFIFO: workloads are ordered strictly by + creation time. Older workloads that can't be admitted will block + admitting newer workloads even if they fit available quota. - + BestEffortFIFO: workloads are ordered by creation time, however + older workloads that can't be admitted will not block admitting + newer workloads that fit existing quota. + + resource_groups (list[Any]): resourceGroups describes groups of resources. Each resource group + defines the list of resources and a list of flavors that provide + quotas for these resources. Each resource and each flavor can only + form part of one resource group. resourceGroups can be up to 16. + + stop_policy (str): stopPolicy - if set to a value different from None, the ClusterQueue + is considered Inactive, no new reservation being made. Depending + on its value, its associated workloads will: - None - Workloads + are admitted - HoldAndDrain - Admitted workloads are evicted and + Reserving workloads will cancel the reservation. - Hold - Admitted + workloads will run to completion and Reserving workloads will + cancel the reservation. + + """ + super().__init__(**kwargs) + + self.admission_checks = admission_checks + self.admission_checks_strategy = admission_checks_strategy + self.admission_scope = admission_scope + self.cohort = cohort + self.cohort_name = cohort_name + self.fair_sharing = fair_sharing + self.flavor_fungibility = flavor_fungibility + self.namespace_selector = namespace_selector + self.preemption = preemption + self.queueing_strategy = queueing_strategy + self.resource_groups = resource_groups + self.stop_policy = stop_policy + + def to_dict(self) -> None: + + super().to_dict() + + if not self.kind_dict and not self.yaml_file: + self.res["spec"] = {} + _spec = self.res["spec"] + + if self.admission_checks is not None: + _spec["admissionChecks"] = self.admission_checks + + if self.admission_checks_strategy is not None: + _spec["admissionChecksStrategy"] = self.admission_checks_strategy + + if self.admission_scope is not None: + _spec["admissionScope"] = self.admission_scope + + if self.cohort is not None: + _spec["cohort"] = self.cohort + + if self.cohort_name is not None: + _spec["cohortName"] = self.cohort_name + + if self.fair_sharing is not None: + _spec["fairSharing"] = self.fair_sharing + + if self.flavor_fungibility is not None: + _spec["flavorFungibility"] = self.flavor_fungibility + + if self.namespace_selector is not None: + _spec["namespaceSelector"] = self.namespace_selector + + if self.preemption is not None: + _spec["preemption"] = self.preemption + + if self.queueing_strategy is not None: + _spec["queueingStrategy"] = self.queueing_strategy + + if self.resource_groups is not None: + _spec["resourceGroups"] = self.resource_groups + + if self.stop_policy is not None: + _spec["stopPolicy"] = self.stop_policy + + # End of generated code diff --git a/ocp_resources/kueue_components_platform_opendatahub_io.py b/ocp_resources/kueue_components_platform_opendatahub_io.py new file mode 100644 index 0000000000..691fd0b757 --- /dev/null +++ b/ocp_resources/kueue_components_platform_opendatahub_io.py @@ -0,0 +1,81 @@ +# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md + + +from typing import Any + +from ocp_resources.resource import Resource + + +class Kueue(Resource): + """ + Kueue is the Schema for the kueues API + """ + + api_group: str = Resource.ApiGroup.COMPONENTS_PLATFORM_OPENDATAHUB_IO + + def __init__( + self, + auto_create_queues: bool | None = None, + default_cluster_queue_name: str | None = None, + default_local_queue_name: str | None = None, + dev_flags: dict[str, Any] | None = None, + management_state: str | None = None, + **kwargs: Any, + ) -> None: + r""" + Args: + auto_create_queues (bool): Controls whether the operator automatically creates default + ClusterQueue, LocalQueue and ResourceFlavor resources in managed + namespaces. When false (the default), the operator skips queue + creation entirely. Only used when autoCreateQueues is true. + Available in RHOAI >= 3.5. + + default_cluster_queue_name (str): Configures the automatically created cluster queue name. + + default_local_queue_name (str): Configures the automatically created, in the managed namespaces, local + queue name. + + dev_flags (dict[str, Any]): Add developer fields. Available in RHOAI <= 2.x. + + management_state (str): Set to one of the following values: - "Managed" : the operator is + actively managing the component and trying to keep it active. + It will only upgrade the component if it is safe to do so - + "Unmanaged" : the operator is actively managing the component and + trying to keep it active. It will only upgrade the + component if it is safe to do so - "Removed" : the operator is + actively managing the component and will not install it, + or if it is installed, the operator will try to remove it + + """ + super().__init__(**kwargs) + + self.auto_create_queues = auto_create_queues + self.default_cluster_queue_name = default_cluster_queue_name + self.default_local_queue_name = default_local_queue_name + self.dev_flags = dev_flags + self.management_state = management_state + + def to_dict(self) -> None: + + super().to_dict() + + if not self.kind_dict and not self.yaml_file: + self.res["spec"] = {} + _spec = self.res["spec"] + + if self.auto_create_queues is not None: + _spec["autoCreateQueues"] = self.auto_create_queues + + if self.default_cluster_queue_name is not None: + _spec["defaultClusterQueueName"] = self.default_cluster_queue_name + + if self.default_local_queue_name is not None: + _spec["defaultLocalQueueName"] = self.default_local_queue_name + + if self.dev_flags is not None: + _spec["devFlags"] = self.dev_flags + + if self.management_state is not None: + _spec["managementState"] = self.management_state + + # End of generated code diff --git a/ocp_resources/kueue_kueue_openshift_io.py b/ocp_resources/kueue_kueue_openshift_io.py new file mode 100644 index 0000000000..dfae79d82d --- /dev/null +++ b/ocp_resources/kueue_kueue_openshift_io.py @@ -0,0 +1,93 @@ +# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md + + +from typing import Any + +from ocp_resources.resource import Resource + + +class Kueue(Resource): + """ + Kueue is the CRD to represent the Kueue operator. + """ + + api_group: str = Resource.ApiGroup.KUEUE_OPENSHIFT_IO + + def __init__( + self, + config: dict[str, Any] | None = None, + log_level: str | None = None, + management_state: str | None = None, + observed_config: dict[str, Any] | None = None, + operator_log_level: str | None = None, + unsupported_config_overrides: dict[str, Any] | None = None, + **kwargs: Any, + ) -> None: + r""" + Args: + config (dict[str, Any]): config is the desired configuration for the Kueue operator. + + log_level (str): logLevel is an intent based logging for an overall component. It does + not give fine grained control, but it is a simple way to manage + coarse grained logging choices that operators have to interpret + for their operands. Valid values are: "Normal", "Debug", "Trace", + "TraceAll". Defaults to "Normal". + + management_state (str): managementState indicates whether and how the operator should manage + the component + + observed_config (dict[str, Any]): observedConfig holds a sparse config that controller has observed from + the cluster state. It exists in spec because it is an input to + the level for the operator + + operator_log_level (str): operatorLogLevel is an intent based logging for the operator itself. + It does not give fine grained control, but it is a simple way to + manage coarse grained logging choices that operators have to + interpret for themselves. Valid values are: "Normal", "Debug", + "Trace", "TraceAll". Defaults to "Normal". + + unsupported_config_overrides (dict[str, Any]): unsupportedConfigOverrides overrides the final configuration that was + computed by the operator. Red Hat does not support the use of this + field. Misuse of this field could lead to unexpected behavior or + conflict with other configuration options. Seek guidance from the + Red Hat support before using this field. Use of this property + blocks cluster upgrades, it must be removed before upgrading your + cluster. + + """ + super().__init__(**kwargs) + + self.config = config + self.log_level = log_level + self.management_state = management_state + self.observed_config = observed_config + self.operator_log_level = operator_log_level + self.unsupported_config_overrides = unsupported_config_overrides + + def to_dict(self) -> None: + + super().to_dict() + + if not self.kind_dict and not self.yaml_file: + self.res["spec"] = {} + _spec = self.res["spec"] + + if self.config is not None: + _spec["config"] = self.config + + if self.log_level is not None: + _spec["logLevel"] = self.log_level + + if self.management_state is not None: + _spec["managementState"] = self.management_state + + if self.observed_config is not None: + _spec["observedConfig"] = self.observed_config + + if self.operator_log_level is not None: + _spec["operatorLogLevel"] = self.operator_log_level + + if self.unsupported_config_overrides is not None: + _spec["unsupportedConfigOverrides"] = self.unsupported_config_overrides + + # End of generated code diff --git a/ocp_resources/local_queue.py b/ocp_resources/local_queue.py new file mode 100644 index 0000000000..c1c8b6e058 --- /dev/null +++ b/ocp_resources/local_queue.py @@ -0,0 +1,65 @@ +# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md + + +from typing import Any + +from ocp_resources.resource import NamespacedResource + + +class LocalQueue(NamespacedResource): + """ + LocalQueue is the Schema for the localQueues API + """ + + api_group: str = NamespacedResource.ApiGroup.KUEUE_X_K8S_IO + + def __init__( + self, + cluster_queue: str | None = None, + fair_sharing: dict[str, Any] | None = None, + stop_policy: str | None = None, + **kwargs: Any, + ) -> None: + r""" + Args: + cluster_queue (str): clusterQueue is a reference to a clusterQueue that backs this + localQueue. + + fair_sharing (dict[str, Any]): fairSharing defines the properties of the LocalQueue when + participating in AdmissionFairSharing. The values are only + relevant if AdmissionFairSharing is enabled in the Kueue + configuration. Available in kueue.x-k8s.io/v1beta2+. + + stop_policy (str): stopPolicy - if set to a value different from None, the LocalQueue is + considered Inactive, no new reservation being made. Depending on + its value, its associated workloads will: - None - Workloads are + admitted - HoldAndDrain - Admitted workloads are evicted and + Reserving workloads will cancel the reservation. - Hold - Admitted + workloads will run to completion and Reserving workloads will + cancel the reservation. + + """ + super().__init__(**kwargs) + + self.cluster_queue = cluster_queue + self.fair_sharing = fair_sharing + self.stop_policy = stop_policy + + def to_dict(self) -> None: + + super().to_dict() + + if not self.kind_dict and not self.yaml_file: + self.res["spec"] = {} + _spec = self.res["spec"] + + if self.cluster_queue is not None: + _spec["clusterQueue"] = self.cluster_queue + + if self.fair_sharing is not None: + _spec["fairSharing"] = self.fair_sharing + + if self.stop_policy is not None: + _spec["stopPolicy"] = self.stop_policy + + # End of generated code diff --git a/ocp_resources/resource.py b/ocp_resources/resource.py index 279b52cc94..49179b3c62 100644 --- a/ocp_resources/resource.py +++ b/ocp_resources/resource.py @@ -537,6 +537,8 @@ class ApiGroup: KUBERNETES_IO: str = "kubernetes.io" KUBEVIRT_IO: str = "kubevirt.io" KUBEVIRT_KUBEVIRT_IO: str = "kubevirt.kubevirt.io" + KUEUE_OPENSHIFT_IO: str = "kueue.openshift.io" + KUEUE_X_K8S_IO: str = "kueue.x-k8s.io" LITMUS_IO: str = "litmuschaos.io" LLAMASTACK_IO: str = "llamastack.io" MAAS_OPENDATAHUB_IO: str = "maas.opendatahub.io" diff --git a/ocp_resources/resource_flavor.py b/ocp_resources/resource_flavor.py new file mode 100644 index 0000000000..6b71896bba --- /dev/null +++ b/ocp_resources/resource_flavor.py @@ -0,0 +1,82 @@ +# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md + + +from typing import Any + +from ocp_resources.resource import Resource + + +class ResourceFlavor(Resource): + """ + ResourceFlavor is the Schema for the resourceflavors API. + """ + + api_group: str = Resource.ApiGroup.KUEUE_X_K8S_IO + + def __init__( + self, + node_labels: dict[str, Any] | None = None, + node_taints: list[Any] | None = None, + tolerations: list[Any] | None = None, + topology_name: str | None = None, + **kwargs: Any, + ) -> None: + r""" + Args: + node_labels (dict[str, Any]): nodeLabels are labels that associate the ResourceFlavor with Nodes + that have the same labels. When a Workload is admitted, its + podsets can only get assigned ResourceFlavors whose nodeLabels + match the nodeSelector and nodeAffinity fields. Once a + ResourceFlavor is assigned to a podSet, the ResourceFlavor's + nodeLabels should be injected into the pods of the Workload by the + controller that integrates with the Workload object. nodeLabels + can be up to 8 elements. + + node_taints (list[Any]): nodeTaints are taints that the nodes associated with this + ResourceFlavor have. Workloads' podsets must have tolerations for + these nodeTaints in order to get assigned this ResourceFlavor + during admission. Only the 'NoSchedule' and 'NoExecute' taint + effects are evaluated, while 'PreferNoSchedule' is ignored. An + example of a nodeTaint is + cloud.provider.com/preemptible="true":NoSchedule nodeTaints can + be up to 8 elements. + + tolerations (list[Any]): tolerations are extra tolerations that will be added to the pods + admitted in the quota associated with this resource flavor. An + example of a toleration is + cloud.provider.com/preemptible="true":NoSchedule tolerations can + be up to 8 elements. + + topology_name (str): topologyName indicates topology for the TAS ResourceFlavor. When + specified, it enables scraping of the topology information from + the nodes matching to the Resource Flavor node labels. + + """ + super().__init__(**kwargs) + + self.node_labels = node_labels + self.node_taints = node_taints + self.tolerations = tolerations + self.topology_name = topology_name + + def to_dict(self) -> None: + + super().to_dict() + + if not self.kind_dict and not self.yaml_file: + self.res["spec"] = {} + _spec = self.res["spec"] + + if self.node_labels is not None: + _spec["nodeLabels"] = self.node_labels + + if self.node_taints is not None: + _spec["nodeTaints"] = self.node_taints + + if self.tolerations is not None: + _spec["tolerations"] = self.tolerations + + if self.topology_name is not None: + _spec["topologyName"] = self.topology_name + + # End of generated code diff --git a/ocp_resources/workload.py b/ocp_resources/workload.py new file mode 100644 index 0000000000..c34f0eb6d9 --- /dev/null +++ b/ocp_resources/workload.py @@ -0,0 +1,114 @@ +# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/class_generator/README.md + + +from typing import Any + +from ocp_resources.resource import NamespacedResource + + +class Workload(NamespacedResource): + """ + Workload is the Schema for the workloads API + """ + + api_group: str = NamespacedResource.ApiGroup.KUEUE_X_K8S_IO + + def __init__( + self, + active: bool | None = None, + maximum_execution_time_seconds: int | None = None, + pod_sets: list[Any] | None = None, + priority: int | None = None, + priority_class_name: str | None = None, + priority_class_ref: dict[str, Any] | None = None, + priority_class_source: str | None = None, + queue_name: str | None = None, + **kwargs: Any, + ) -> None: + r""" + Args: + active (bool): Active determines if a workload can be admitted into a queue. Changing + active from true to false will evict any running workloads. + Possible values are: - false: indicates that a workload should + never be admitted and evicts running workloads - true: indicates + that a workload can be evaluated for admission into it's + respective queue. Defaults to true + + maximum_execution_time_seconds (int): maximumExecutionTimeSeconds if provided, determines the maximum time, + in seconds, the workload can be admitted before it's automatically + deactivated. If unspecified, no execution time limit is enforced + on the Workload. + + pod_sets (list[Any]): podSets is a list of sets of homogeneous pods, each described by a Pod + spec and a count. There must be at least one element and at most + 8. podSets cannot be changed. + + priority (int): Priority determines the order of access to the resources managed by + the ClusterQueue where the workload is queued. The priority value + is populated from the referenced PriorityClass. The higher the + value, the higher the priority. + + priority_class_name (str): If specified, indicates the workload's priority. "system-node- + critical" and "system-cluster-critical" are two special keywords + which indicate the highest priorities with the former being the + highest priority. Any other name must be defined by creating a + PriorityClass object with that name. If not specified, the + workload priority will be default or zero if there is no default. + Available in kueue.x-k8s.io/v1beta1. + + priority_class_ref (dict[str, Any]): priorityClassRef references the workload's priority. + Available in kueue.x-k8s.io/v1beta2+. + + priority_class_source (str): priorityClassSource determines whether the priorityClass field refers + to a pod PriorityClass or kueue.x-k8s.io/workloadpriorityclass. + Available in kueue.x-k8s.io/v1beta1. + + queue_name (str): queueName is the name of the LocalQueue the Workload is associated + with. queueName cannot be changed while .status.admission is not + null. + + """ + super().__init__(**kwargs) + + self.active = active + self.maximum_execution_time_seconds = maximum_execution_time_seconds + self.pod_sets = pod_sets + self.priority = priority + self.priority_class_name = priority_class_name + self.priority_class_ref = priority_class_ref + self.priority_class_source = priority_class_source + self.queue_name = queue_name + + def to_dict(self) -> None: + + super().to_dict() + + if not self.kind_dict and not self.yaml_file: + self.res["spec"] = {} + _spec = self.res["spec"] + + if self.active is not None: + _spec["active"] = self.active + + if self.maximum_execution_time_seconds is not None: + _spec["maximumExecutionTimeSeconds"] = self.maximum_execution_time_seconds + + if self.pod_sets is not None: + _spec["podSets"] = self.pod_sets + + if self.priority is not None: + _spec["priority"] = self.priority + + if self.priority_class_name is not None: + _spec["priorityClassName"] = self.priority_class_name + + if self.priority_class_ref is not None: + _spec["priorityClassRef"] = self.priority_class_ref + + if self.priority_class_source is not None: + _spec["priorityClassSource"] = self.priority_class_source + + if self.queue_name is not None: + _spec["queueName"] = self.queue_name + + # End of generated code