root / htools / Ganeti / OpCodes.hs @ c66f09f5
History | View | Annotate | Download (5.4 kB)
1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|
2 |
|
3 |
{-| Implementation of the opcodes. |
4 |
|
5 |
-} |
6 |
|
7 |
{- |
8 |
|
9 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc. |
10 |
|
11 |
This program is free software; you can redistribute it and/or modify |
12 |
it under the terms of the GNU General Public License as published by |
13 |
the Free Software Foundation; either version 2 of the License, or |
14 |
(at your option) any later version. |
15 |
|
16 |
This program is distributed in the hope that it will be useful, but |
17 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 |
General Public License for more details. |
20 |
|
21 |
You should have received a copy of the GNU General Public License |
22 |
along with this program; if not, write to the Free Software |
23 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
24 |
02110-1301, USA. |
25 |
|
26 |
-} |
27 |
|
28 |
module Ganeti.OpCodes |
29 |
( OpCode(..) |
30 |
, TagObject(..) |
31 |
, tagObjectFrom |
32 |
, encodeTagObject |
33 |
, decodeTagObject |
34 |
, ReplaceDisksMode(..) |
35 |
, DiskIndex |
36 |
, mkDiskIndex |
37 |
, unDiskIndex |
38 |
, opID |
39 |
, allOpIDs |
40 |
) where |
41 |
|
42 |
import Text.JSON (readJSON, showJSON, JSON()) |
43 |
|
44 |
import Ganeti.THH |
45 |
|
46 |
import Ganeti.OpParams |
47 |
|
48 |
-- | OpCode representation. |
49 |
-- |
50 |
-- We only implement a subset of Ganeti opcodes: those which are actually used |
51 |
-- in the htools codebase. |
52 |
$(genOpCode "OpCode" |
53 |
[ ("OpTestDelay", |
54 |
[ simpleField "duration" [t| Double |] |
55 |
, simpleField "on_master" [t| Bool |] |
56 |
, simpleField "on_nodes" [t| [String] |] |
57 |
]) |
58 |
, ("OpInstanceReplaceDisks", |
59 |
[ pInstanceName |
60 |
, pRemoteNode |
61 |
, simpleField "mode" [t| ReplaceDisksMode |] |
62 |
, simpleField "disks" [t| [DiskIndex] |] |
63 |
, pIallocator |
64 |
]) |
65 |
, ("OpInstanceFailover", |
66 |
[ pInstanceName |
67 |
, simpleField "ignore_consistency" [t| Bool |] |
68 |
, pMigrationTargetNode |
69 |
]) |
70 |
, ("OpInstanceMigrate", |
71 |
[ pInstanceName |
72 |
, simpleField "live" [t| Bool |] |
73 |
, simpleField "cleanup" [t| Bool |] |
74 |
, defaultField [| False |] $ simpleField "allow_failover" [t| Bool |] |
75 |
, pMigrationTargetNode |
76 |
]) |
77 |
, ("OpTagsSet", |
78 |
[ pTagsObject |
79 |
, pTagsList |
80 |
]) |
81 |
, ("OpTagsDel", |
82 |
[ pTagsObject |
83 |
, pTagsList |
84 |
]) |
85 |
, ("OpClusterPostInit", []) |
86 |
, ("OpClusterDestroy", []) |
87 |
, ("OpClusterQuery", []) |
88 |
, ("OpClusterVerify", |
89 |
[ pDebugSimulateErrors |
90 |
, pErrorCodes |
91 |
, pSkipChecks |
92 |
, pIgnoreErrors |
93 |
, pVerbose |
94 |
, pOptGroupName |
95 |
]) |
96 |
, ("OpClusterVerifyConfig", |
97 |
[ pDebugSimulateErrors |
98 |
, pErrorCodes |
99 |
, pIgnoreErrors |
100 |
, pVerbose |
101 |
]) |
102 |
, ("OpClusterVerifyGroup", |
103 |
[ pGroupName |
104 |
, pDebugSimulateErrors |
105 |
, pErrorCodes |
106 |
, pSkipChecks |
107 |
, pIgnoreErrors |
108 |
, pVerbose |
109 |
]) |
110 |
, ("OpClusterVerifyDisks", []) |
111 |
, ("OpGroupVerifyDisks", |
112 |
[ pGroupName |
113 |
]) |
114 |
, ("OpClusterRepairDiskSizes", |
115 |
[ pInstances |
116 |
]) |
117 |
, ("OpClusterConfigQuery", |
118 |
[ pOutputFields |
119 |
]) |
120 |
, ("OpClusterRename", |
121 |
[ pName |
122 |
]) |
123 |
, ("OpClusterSetParams", |
124 |
[ pHvState |
125 |
, pDiskState |
126 |
, pVgName |
127 |
, pEnabledHypervisors |
128 |
, pClusterHvParams |
129 |
, pClusterBeParams |
130 |
, pOsHvp |
131 |
, pOsParams |
132 |
, pDiskParams |
133 |
, pCandidatePoolSize |
134 |
, pUidPool |
135 |
, pAddUids |
136 |
, pRemoveUids |
137 |
, pMaintainNodeHealth |
138 |
, pPreallocWipeDisks |
139 |
, pNicParams |
140 |
, pNdParams |
141 |
, pIpolicy |
142 |
, pDrbdHelper |
143 |
, pDefaultIAllocator |
144 |
, pMasterNetdev |
145 |
, pReservedLvs |
146 |
, pHiddenOs |
147 |
, pBlacklistedOs |
148 |
, pUseExternalMipScript |
149 |
]) |
150 |
, ("OpClusterRedistConf", []) |
151 |
, ("OpClusterActivateMasterIp", []) |
152 |
, ("OpClusterDeactivateMasterIp", []) |
153 |
, ("OpQuery", |
154 |
[ pQueryWhat |
155 |
, pUseLocking |
156 |
, pQueryFields |
157 |
, pQueryFilter |
158 |
]) |
159 |
, ("OpQueryFields", |
160 |
[ pQueryWhat |
161 |
, pQueryFields |
162 |
]) |
163 |
, ("OpOobCommand", |
164 |
[ pNodeNames |
165 |
, pOobCommand |
166 |
, pOobTimeout |
167 |
, pIgnoreStatus |
168 |
, pPowerDelay |
169 |
]) |
170 |
, ("OpNodeRemove", [ pNodeName ]) |
171 |
, ("OpNodeAdd", |
172 |
[ pNodeName |
173 |
, pHvState |
174 |
, pDiskState |
175 |
, pPrimaryIp |
176 |
, pSecondaryIp |
177 |
, pReadd |
178 |
, pNodeGroup |
179 |
, pMasterCapable |
180 |
, pVmCapable |
181 |
, pNdParams |
182 |
]) |
183 |
, ("OpNodeQuery", |
184 |
[ pOutputFields |
185 |
, pUseLocking |
186 |
, pNames |
187 |
]) |
188 |
, ("OpNodeQueryvols", |
189 |
[ pOutputFields |
190 |
, pNodes |
191 |
]) |
192 |
, ("OpNodeQueryStorage", |
193 |
[ pOutputFields |
194 |
, pStorageType |
195 |
, pNodes |
196 |
, pStorageName |
197 |
]) |
198 |
, ("OpNodeModifyStorage", |
199 |
[ pNodeName |
200 |
, pStorageType |
201 |
, pStorageName |
202 |
, pStorageChanges |
203 |
]) |
204 |
, ("OpRepairNodeStorage", |
205 |
[ pNodeName |
206 |
, pStorageType |
207 |
, pStorageName |
208 |
, pIgnoreConsistency |
209 |
]) |
210 |
, ("OpNodeSetParams", |
211 |
[ pNodeName |
212 |
, pForce |
213 |
, pHvState |
214 |
, pDiskState |
215 |
, pMasterCandidate |
216 |
, pOffline |
217 |
, pDrained |
218 |
, pAutoPromote |
219 |
, pMasterCapable |
220 |
, pVmCapable |
221 |
, pSecondaryIp |
222 |
, pNdParams |
223 |
]) |
224 |
, ("OpNodePowercycle", |
225 |
[ pNodeName |
226 |
, pForce |
227 |
]) |
228 |
, ("OpNodeMigrate", |
229 |
[ pNodeName |
230 |
, pMigrationMode |
231 |
, pMigrationLive |
232 |
, pMigrationTargetNode |
233 |
, pAllowRuntimeChgs |
234 |
, pIgnoreIpolicy |
235 |
, pIallocator |
236 |
]) |
237 |
, ("OpNodeEvacuate", |
238 |
[ pEarlyRelease |
239 |
, pNodeName |
240 |
, pRemoteNode |
241 |
, pIallocator |
242 |
, pEvacMode |
243 |
]) |
244 |
]) |
245 |
|
246 |
-- | Returns the OP_ID for a given opcode value. |
247 |
$(genOpID ''OpCode "opID") |
248 |
|
249 |
-- | A list of all defined/supported opcode IDs. |
250 |
$(genAllOpIDs ''OpCode "allOpIDs") |
251 |
|
252 |
instance JSON OpCode where |
253 |
readJSON = loadOpCode |
254 |
showJSON = saveOpCode |