Coverage for ocp_resources/performance_profile.py: 0%

41 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-30 10:48 +0200

1from ocp_resources.resource import MissingRequiredArgumentError, Resource 

2 

3 

4class PerformanceProfile(Resource): 

5 api_group = Resource.ApiGroup.PERFORMANCE_OPENSHIFT_IO 

6 

7 def __init__( 

8 self, 

9 additional_kernel_args=None, 

10 cpu=None, 

11 globally_disable_irq_load_balancing=None, 

12 hugepages=None, 

13 machine_config_label=None, 

14 machine_config_pool_selector=None, 

15 net=None, 

16 numa=None, 

17 real_time_kernel=None, 

18 workload_hints=None, 

19 **kwargs, 

20 ): 

21 """ 

22 PerformanceProfile object. API reference: 

23 https://docs.openshift.com/container-platform/4.14/rest_api/node_apis/performanceprofile-performance-openshift-io-v2.html#performanceprofile-performance-openshift-io-v2 

24 

25 Args: 

26 additional_kernel_args (list, optional): Additional kernel arguments. 

27 cpu (dict, required): Set of CPU related parameters. 

28 globally_disable_irq_load_balancing (bool, optional): Toggles whether IRQ load balancing will be 

29 disabled for the Isolated CPU set. 

30 hugepages (dict, optional): Defines a set of huge pages related parameters. 

31 machine_config_label (str, optional): Defines the label to add to the MachineConfigs the operator creates. 

32 machine_config_pool_selector (str, optional): Defines the MachineConfigPool label to use in the 

33 MachineConfigPoolSelector of resources like KubeletConfigs created by the operator. 

34 net (dict, optional): Defines a set of network related features. 

35 node_selector (str, required): Defines the node label to use in the NodeSelectors of resources like Tuned created by the operator. 

36 numa (dict, optional): Defines options related to topology aware affinities. 

37 real_time_kernel (dict, optional): Defines a set of real time kernel related parameters. 

38 workload_hints (dict, optional): Defines hints for different types of workloads. 

39 """ 

40 

41 super().__init__(**kwargs) 

42 self.additional_kernel_args = additional_kernel_args 

43 self.cpu = cpu 

44 self.globally_disable_irq_load_balancing = globally_disable_irq_load_balancing 

45 self.hugepages = hugepages 

46 self.machine_config_label = machine_config_label 

47 self.machine_config_pool_selector = machine_config_pool_selector 

48 self.net = net 

49 self.node_selector = kwargs.get("node_selector") 

50 self.numa = numa 

51 self.real_time_kernel = real_time_kernel 

52 self.workload_hints = workload_hints 

53 

54 def to_dict(self) -> None: 

55 super().to_dict() 

56 if not self.kind_dict and not self.yaml_file: 

57 if not self.cpu and not self.node_selector: 

58 raise MissingRequiredArgumentError(argument="'cpu' and 'node_selector'") 

59 

60 manifest_spec = { 

61 "cpu": self.cpu, 

62 "nodeSelector": self.node_selector, 

63 } 

64 

65 if self.additional_kernel_args: 

66 manifest_spec["additionalKernelArgs"] = self.additional_kernel_args 

67 

68 if self.globally_disable_irq_load_balancing is not None: 

69 manifest_spec["globallyDisableIrqLoadBalancing"] = self.globally_disable_irq_load_balancing 

70 

71 if self.hugepages: 

72 manifest_spec["hugepages"] = self.hugepages 

73 

74 if self.machine_config_label: 

75 manifest_spec["machineConfigLabel"] = self.machine_config_label 

76 

77 if self.machine_config_pool_selector: 

78 manifest_spec["machineConfigPoolSelector"] = self.machine_config_pool_selector 

79 

80 if self.net: 

81 manifest_spec["net"] = self.net 

82 

83 if self.numa: 

84 manifest_spec["numa"] = self.numa 

85 

86 if self.real_time_kernel: 

87 manifest_spec["realTimeKernel"] = self.real_time_kernel 

88 

89 if self.workload_hints: 

90 manifest_spec["workloadHints"] = self.workload_hints 

91 

92 self.res["spec"] = manifest_spec