Coverage for ocp_resources/kubevirt.py: 0%

62 statements  

« 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 

2 

3from typing import Any, Dict, List, Optional 

4from ocp_resources.resource import NamespacedResource 

5 

6 

7class KubeVirt(NamespacedResource): 

8 """ 

9 KubeVirt represents the object deploying all KubeVirt resources 

10 """ 

11 

12 api_group: str = NamespacedResource.ApiGroup.KUBEVIRT_IO 

13 

14 def __init__( 

15 self, 

16 certificate_rotate_strategy: Optional[Dict[str, Any]] = None, 

17 configuration: Optional[Dict[str, Any]] = None, 

18 customize_components: Optional[Dict[str, Any]] = None, 

19 image_pull_policy: Optional[str] = "", 

20 image_pull_secrets: Optional[List[Any]] = None, 

21 image_registry: Optional[str] = "", 

22 image_tag: Optional[str] = "", 

23 infra: Optional[Dict[str, Any]] = None, 

24 monitor_account: Optional[str] = "", 

25 monitor_namespace: Optional[str] = "", 

26 product_component: Optional[str] = "", 

27 product_name: Optional[str] = "", 

28 product_version: Optional[str] = "", 

29 service_monitor_namespace: Optional[str] = "", 

30 uninstall_strategy: Optional[str] = "", 

31 workload_update_strategy: Optional[Dict[str, Any]] = None, 

32 workloads: Optional[Dict[str, Any]] = None, 

33 **kwargs: Any, 

34 ) -> None: 

35 """ 

36 Args: 

37 certificate_rotate_strategy (Dict[str, Any]): No field description from API; please add description 

38 

39 configuration (Dict[str, Any]): holds kubevirt configurations. same as the virt-configMap 

40 

41 customize_components (Dict[str, Any]): No field description from API; please add description 

42 

43 image_pull_policy (str): The ImagePullPolicy to use. 

44 

45 image_pull_secrets (List[Any]): The imagePullSecrets to pull the container images from Defaults to 

46 none 

47 

48 image_registry (str): The image registry to pull the container images from Defaults to the 

49 same registry the operator's container image is pulled from. 

50 

51 image_tag (str): The image tag to use for the continer images installed. Defaults to 

52 the same tag as the operator's container image. 

53 

54 infra (Dict[str, Any]): selectors and tolerations that should apply to KubeVirt infrastructure 

55 components 

56 

57 monitor_account (str): The name of the Prometheus service account that needs read-access to 

58 KubeVirt endpoints Defaults to prometheus-k8s 

59 

60 monitor_namespace (str): The namespace Prometheus is deployed in Defaults to openshift-monitor 

61 

62 product_component (str): Designate the apps.kubevirt.io/component label for KubeVirt 

63 components. Useful if KubeVirt is included as part of a product. 

64 If ProductComponent is not specified, the component label default 

65 value is kubevirt. 

66 

67 product_name (str): Designate the apps.kubevirt.io/part-of label for KubeVirt components. 

68 Useful if KubeVirt is included as part of a product. If 

69 ProductName is not specified, the part-of label will be omitted. 

70 

71 product_version (str): Designate the apps.kubevirt.io/version label for KubeVirt components. 

72 Useful if KubeVirt is included as part of a product. If 

73 ProductVersion is not specified, KubeVirt's version will be used. 

74 

75 service_monitor_namespace (str): The namespace the service monitor will be deployed When 

76 ServiceMonitorNamespace is set, then we'll install the service 

77 monitor object in that namespace otherwise we will use the 

78 monitoring namespace. 

79 

80 uninstall_strategy (str): Specifies if kubevirt can be deleted if workloads are still present. 

81 This is mainly a precaution to avoid accidental data loss 

82 

83 workload_update_strategy (Dict[str, Any]): WorkloadUpdateStrategy defines at the cluster level how to handle 

84 automated workload updates 

85 

86 workloads (Dict[str, Any]): selectors and tolerations that should apply to KubeVirt workloads 

87 

88 """ 

89 super().__init__(**kwargs) 

90 

91 self.certificate_rotate_strategy = certificate_rotate_strategy 

92 self.configuration = configuration 

93 self.customize_components = customize_components 

94 self.image_pull_policy = image_pull_policy 

95 self.image_pull_secrets = image_pull_secrets 

96 self.image_registry = image_registry 

97 self.image_tag = image_tag 

98 self.infra = infra 

99 self.monitor_account = monitor_account 

100 self.monitor_namespace = monitor_namespace 

101 self.product_component = product_component 

102 self.product_name = product_name 

103 self.product_version = product_version 

104 self.service_monitor_namespace = service_monitor_namespace 

105 self.uninstall_strategy = uninstall_strategy 

106 self.workload_update_strategy = workload_update_strategy 

107 self.workloads = workloads 

108 

109 def to_dict(self) -> None: 

110 super().to_dict() 

111 

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

113 self.res["spec"] = {} 

114 _spec = self.res["spec"] 

115 

116 if self.certificate_rotate_strategy: 

117 _spec["certificateRotateStrategy"] = self.certificate_rotate_strategy 

118 

119 if self.configuration: 

120 _spec["configuration"] = self.configuration 

121 

122 if self.customize_components: 

123 _spec["customizeComponents"] = self.customize_components 

124 

125 if self.image_pull_policy: 

126 _spec["imagePullPolicy"] = self.image_pull_policy 

127 

128 if self.image_pull_secrets: 

129 _spec["imagePullSecrets"] = self.image_pull_secrets 

130 

131 if self.image_registry: 

132 _spec["imageRegistry"] = self.image_registry 

133 

134 if self.image_tag: 

135 _spec["imageTag"] = self.image_tag 

136 

137 if self.infra: 

138 _spec["infra"] = self.infra 

139 

140 if self.monitor_account: 

141 _spec["monitorAccount"] = self.monitor_account 

142 

143 if self.monitor_namespace: 

144 _spec["monitorNamespace"] = self.monitor_namespace 

145 

146 if self.product_component: 

147 _spec["productComponent"] = self.product_component 

148 

149 if self.product_name: 

150 _spec["productName"] = self.product_name 

151 

152 if self.product_version: 

153 _spec["productVersion"] = self.product_version 

154 

155 if self.service_monitor_namespace: 

156 _spec["serviceMonitorNamespace"] = self.service_monitor_namespace 

157 

158 if self.uninstall_strategy: 

159 _spec["uninstallStrategy"] = self.uninstall_strategy 

160 

161 if self.workload_update_strategy: 

162 _spec["workloadUpdateStrategy"] = self.workload_update_strategy 

163 

164 if self.workloads: 

165 _spec["workloads"] = self.workloads 

166 

167 # End of generated code