Coverage for watcher/decision_engine/goal/goals.py: 92%

133 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1# -*- encoding: utf-8 -*- 

2# Copyright (c) 2016 b<>com 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 

13# implied. 

14# See the License for the specific language governing permissions and 

15# limitations under the License. 

16 

17from watcher._i18n import _ 

18from watcher.decision_engine.goal import base 

19from watcher.decision_engine.goal.efficacy import specs 

20 

21 

22class Dummy(base.Goal): 

23 """Dummy 

24 

25 Reserved goal that is used for testing purposes. 

26 """ 

27 

28 @classmethod 

29 def get_name(cls): 

30 return "dummy" 

31 

32 @classmethod 

33 def get_display_name(cls): 

34 return _("Dummy goal") 

35 

36 @classmethod 

37 def get_translatable_display_name(cls): 

38 return "Dummy goal" 

39 

40 @classmethod 

41 def get_efficacy_specification(cls): 

42 """The efficacy spec for the current goal""" 

43 return specs.Unclassified() 

44 

45 

46class Unclassified(base.Goal): 

47 """Unclassified 

48 

49 This goal is used to ease the development process of a strategy. Containing 

50 no actual indicator specification, this goal can be used whenever a 

51 strategy has yet to be formally associated with an existing goal. If the 

52 goal achieve has been identified but there is no available implementation, 

53 this Goal can also be used as a transitional stage. 

54 """ 

55 

56 @classmethod 

57 def get_name(cls): 

58 return "unclassified" 

59 

60 @classmethod 

61 def get_display_name(cls): 

62 return _("Unclassified") 

63 

64 @classmethod 

65 def get_translatable_display_name(cls): 

66 return "Unclassified" 

67 

68 @classmethod 

69 def get_efficacy_specification(cls): 

70 """The efficacy spec for the current goal""" 

71 return specs.Unclassified() 

72 

73 

74class ServerConsolidation(base.Goal): 

75 """ServerConsolidation 

76 

77 This goal is for efficient usage of compute server resources in order to 

78 reduce the total number of servers. 

79 """ 

80 

81 @classmethod 

82 def get_name(cls): 

83 return "server_consolidation" 

84 

85 @classmethod 

86 def get_display_name(cls): 

87 return _("Server Consolidation") 

88 

89 @classmethod 

90 def get_translatable_display_name(cls): 

91 return "Server Consolidation" 

92 

93 @classmethod 

94 def get_efficacy_specification(cls): 

95 """The efficacy spec for the current goal""" 

96 return specs.ServerConsolidation() 

97 

98 

99class ThermalOptimization(base.Goal): 

100 """ThermalOptimization 

101 

102 This goal is used to balance the temperature across different servers. 

103 """ 

104 

105 @classmethod 

106 def get_name(cls): 

107 return "thermal_optimization" 

108 

109 @classmethod 

110 def get_display_name(cls): 

111 return _("Thermal Optimization") 

112 

113 @classmethod 

114 def get_translatable_display_name(cls): 

115 return "Thermal Optimization" 

116 

117 @classmethod 

118 def get_efficacy_specification(cls): 

119 """The efficacy spec for the current goal""" 

120 return specs.Unclassified() 

121 

122 

123class WorkloadBalancing(base.Goal): 

124 """WorkloadBalancing 

125 

126 This goal is used to evenly distribute workloads across different servers. 

127 """ 

128 

129 @classmethod 

130 def get_name(cls): 

131 return "workload_balancing" 

132 

133 @classmethod 

134 def get_display_name(cls): 

135 return _("Workload Balancing") 

136 

137 @classmethod 

138 def get_translatable_display_name(cls): 

139 return "Workload Balancing" 

140 

141 @classmethod 

142 def get_efficacy_specification(cls): 

143 """The efficacy spec for the current goal""" 

144 return specs.WorkloadBalancing() 

145 

146 

147class AirflowOptimization(base.Goal): 

148 """AirflowOptimization 

149 

150 This goal is used to optimize the airflow within a cloud infrastructure. 

151 """ 

152 

153 @classmethod 

154 def get_name(cls): 

155 return "airflow_optimization" 

156 

157 @classmethod 

158 def get_display_name(cls): 

159 return _("Airflow Optimization") 

160 

161 @classmethod 

162 def get_translatable_display_name(cls): 

163 return "Airflow Optimization" 

164 

165 @classmethod 

166 def get_efficacy_specification(cls): 

167 """The efficacy spec for the current goal""" 

168 return specs.Unclassified() 

169 

170 

171class NoisyNeighborOptimization(base.Goal): 

172 """NoisyNeighborOptimization 

173 

174 This goal is used to identify and migrate a Noisy Neighbor - 

175 a low priority VM that negatively affects performance of a high priority VM 

176 in terms of IPC by over utilizing Last Level Cache. 

177 """ 

178 

179 @classmethod 

180 def get_name(cls): 

181 return "noisy_neighbor" 

182 

183 @classmethod 

184 def get_display_name(cls): 

185 return _("Noisy Neighbor") 

186 

187 @classmethod 

188 def get_translatable_display_name(cls): 

189 return "Noisy Neighbor" 

190 

191 @classmethod 

192 def get_efficacy_specification(cls): 

193 """The efficacy spec for the current goal""" 

194 return specs.Unclassified() 

195 

196 

197class SavingEnergy(base.Goal): 

198 """SavingEnergy 

199 

200 This goal is used to reduce power consumption within a data center. 

201 """ 

202 

203 @classmethod 

204 def get_name(cls): 

205 return "saving_energy" 

206 

207 @classmethod 

208 def get_display_name(cls): 

209 return _("Saving Energy") 

210 

211 @classmethod 

212 def get_translatable_display_name(cls): 

213 return "Saving Energy" 

214 

215 @classmethod 

216 def get_efficacy_specification(cls): 

217 """The efficacy spec for the current goal""" 

218 return specs.Unclassified() 

219 

220 

221class HardwareMaintenance(base.Goal): 

222 """HardwareMaintenance 

223 

224 This goal is to migrate instances and volumes on a set of compute nodes 

225 and storage from nodes under maintenance 

226 """ 

227 

228 @classmethod 

229 def get_name(cls): 

230 return "hardware_maintenance" 

231 

232 @classmethod 

233 def get_display_name(cls): 

234 return _("Hardware Maintenance") 

235 

236 @classmethod 

237 def get_translatable_display_name(cls): 

238 return "Hardware Maintenance" 

239 

240 @classmethod 

241 def get_efficacy_specification(cls): 

242 """The efficacy spec for the current goal""" 

243 return specs.HardwareMaintenance() 

244 

245 

246class ClusterMaintaining(base.Goal): 

247 """ClusterMaintenance 

248 

249 This goal is used to maintain compute nodes 

250 without having the user's application being interrupted. 

251 """ 

252 

253 @classmethod 

254 def get_name(cls): 

255 return "cluster_maintaining" 

256 

257 @classmethod 

258 def get_display_name(cls): 

259 return _("Cluster Maintaining") 

260 

261 @classmethod 

262 def get_translatable_display_name(cls): 

263 return "Cluster Maintaining" 

264 

265 @classmethod 

266 def get_efficacy_specification(cls): 

267 """The efficacy spec for the current goal""" 

268 return specs.Unclassified()