Coverage for ocp_resources/machine.py: 0%
38 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
1# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
3from typing import Any, Dict, List, Optional
4from ocp_resources.resource import NamespacedResource
7class Machine(NamespacedResource):
8 """
9 Machine is the Schema for the machines API Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).
10 """
12 api_group: str = NamespacedResource.ApiGroup.MACHINE_OPENSHIFT_IO
14 def __init__(
15 self,
16 lifecycle_hooks: Optional[Dict[str, Any]] = None,
17 metadata: Optional[Dict[str, Any]] = None,
18 provider_id: Optional[str] = "",
19 provider_spec: Optional[Dict[str, Any]] = None,
20 taints: Optional[List[Any]] = None,
21 **kwargs: Any,
22 ) -> None:
23 """
24 Args:
25 lifecycle_hooks (Dict[str, Any]): LifecycleHooks allow users to pause operations on the machine at
26 certain predefined points within the machine lifecycle.
28 metadata (Dict[str, Any]): ObjectMeta will autopopulate the Node created. Use this to indicate
29 what labels, annotations, name prefix, etc., should be used when
30 creating the Node.
32 provider_id (str): ProviderID is the identification ID of the machine provided by the
33 provider. This field must match the provider ID as seen on the
34 node object corresponding to this machine. This field is required
35 by higher level consumers of cluster-api. Example use case is
36 cluster autoscaler with cluster-api as provider. Clean-up logic in
37 the autoscaler compares machines to nodes to find out machines at
38 provider which could not get registered as Kubernetes nodes. With
39 cluster-api as a generic out-of-tree provider for autoscaler, this
40 field is required by autoscaler to be able to have a provider view
41 of the list of machines. Another list of nodes is queried from the
42 k8s apiserver and then a comparison is done to find out
43 unregistered machines and are marked for delete. This field will
44 be set by the actuators and consumed by higher level entities like
45 autoscaler that will be interfacing with cluster-api as generic
46 provider.
48 provider_spec (Dict[str, Any]): ProviderSpec details Provider-specific configuration to use during
49 node creation.
51 taints (List[Any]): The list of the taints to be applied to the corresponding Node in
52 additive manner. This list will not overwrite any other taints
53 added to the Node on an ongoing basis by other entities. These
54 taints should be actively reconciled e.g. if you ask the machine
55 controller to apply a taint and then manually remove the taint the
56 machine controller will put it back) but not have the machine
57 controller remove any taints
59 """
60 super().__init__(**kwargs)
62 self.lifecycle_hooks = lifecycle_hooks
63 self.metadata = metadata
64 self.provider_id = provider_id
65 self.provider_spec = provider_spec
66 self.taints = taints
68 def to_dict(self) -> None:
69 super().to_dict()
71 if not self.kind_dict and not self.yaml_file:
72 self.res["spec"] = {}
73 _spec = self.res["spec"]
75 if self.lifecycle_hooks:
76 _spec["lifecycleHooks"] = self.lifecycle_hooks
78 if self.metadata:
79 _spec["metadata"] = self.metadata
81 if self.provider_id:
82 _spec["providerID"] = self.provider_id
84 if self.provider_spec:
85 _spec["providerSpec"] = self.provider_spec
87 if self.taints:
88 _spec["taints"] = self.taints
90 # End of generated code
92 @property
93 def cluster_name(self):
94 return self.instance.metadata.labels[f"{self.api_group}/cluster-api-cluster"]
96 @property
97 def machine_role(self):
98 return self.instance.metadata.labels[f"{self.api_group}/cluster-api-machine-role"]
100 @property
101 def machine_type(self):
102 return self.instance.metadata.labels[f"{self.api_group}/cluster-api-machine-type"]
104 @property
105 def machineset_name(self):
106 return self.instance.metadata.labels[f"{self.api_group}/cluster-api-machineset"]