Coverage for ocp_resources/virtual_machine_instancetype.py: 0%
40 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, MissingRequiredArgumentError
7class VirtualMachineInstancetype(NamespacedResource):
8 """
9 VirtualMachineInstancetype resource contains quantitative and resource related VirtualMachine configuration
10 that can be used by multiple VirtualMachine resources.
11 """
13 api_group: str = NamespacedResource.ApiGroup.INSTANCETYPE_KUBEVIRT_IO
15 def __init__(
16 self,
17 spec_annotations: Optional[Dict[str, Any]] = None,
18 cpu: Optional[Dict[str, Any]] = None,
19 gpus: Optional[List[Any]] = None,
20 host_devices: Optional[List[Any]] = None,
21 io_threads_policy: Optional[str] = "",
22 launch_security: Optional[Dict[str, Any]] = None,
23 memory: Optional[Dict[str, Any]] = None,
24 node_selector: Optional[Dict[str, Any]] = None,
25 scheduler_name: Optional[str] = "",
26 **kwargs: Any,
27 ) -> None:
28 """
29 Args:
30 spec_annotations (Dict[str, Any]): Optionally defines the required Annotations to be used by the instance
31 type and applied to the VirtualMachineInstance
33 cpu (Dict[str, Any]): Required CPU related attributes of the instancetype.
35 gpus (List[Any]): Optionally defines any GPU devices associated with the instancetype.
37 host_devices (List[Any]): Optionally defines any HostDevices associated with the instancetype.
39 io_threads_policy (str): Optionally defines the IOThreadsPolicy to be used by the instancetype.
41 launch_security (Dict[str, Any]): Optionally defines the LaunchSecurity to be used by the instancetype.
43 memory (Dict[str, Any]): Required Memory related attributes of the instancetype.
45 node_selector (Dict[str, Any]): NodeSelector is a selector which must be true for the vmi to fit on a
46 node. Selector which must match a node's labels for the vmi to be
47 scheduled on that node. More info:
48 https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
49 NodeSelector is the name of the custom node selector for the
50 instancetype.
52 scheduler_name (str): If specified, the VMI will be dispatched by specified scheduler. If
53 not specified, the VMI will be dispatched by default scheduler.
54 SchedulerName is the name of the custom K8s scheduler for the
55 instancetype.
57 """
58 super().__init__(**kwargs)
60 self.spec_annotations = spec_annotations
61 self.cpu = cpu
62 self.gpus = gpus
63 self.host_devices = host_devices
64 self.io_threads_policy = io_threads_policy
65 self.launch_security = launch_security
66 self.memory = memory
67 self.node_selector = node_selector
68 self.scheduler_name = scheduler_name
70 def to_dict(self) -> None:
71 super().to_dict()
73 if not self.kind_dict and not self.yaml_file:
74 if not self.cpu:
75 raise MissingRequiredArgumentError(argument="self.cpu")
77 if not self.memory:
78 raise MissingRequiredArgumentError(argument="self.memory")
80 self.res["spec"] = {}
81 _spec = self.res["spec"]
83 _spec["cpu"] = self.cpu
84 _spec["memory"] = self.memory
86 if self.spec_annotations:
87 _spec["annotations"] = self.spec_annotations
89 if self.gpus:
90 _spec["gpus"] = self.gpus
92 if self.host_devices:
93 _spec["hostDevices"] = self.host_devices
95 if self.io_threads_policy:
96 _spec["ioThreadsPolicy"] = self.io_threads_policy
98 if self.launch_security:
99 _spec["launchSecurity"] = self.launch_security
101 if self.node_selector:
102 _spec["nodeSelector"] = self.node_selector
104 if self.scheduler_name:
105 _spec["schedulerName"] = self.scheduler_name
107 # End of generated code