## root / src / Ganeti / Types.hs @ a59d5fa1

History | View | Annotate | Download (15.9 kB)

1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|

2 | |

3 |
{-| Some common Ganeti types. |

4 | |

5 |
This holds types common to both core work, and to htools. Types that |

6 |
are very core specific (e.g. configuration objects) should go in |

7 |
'Ganeti.Objects', while types that are specific to htools in-memory |

8 |
representation should go into 'Ganeti.HTools.Types'. |

9 | |

10 |
-} |

11 | |

12 |
{- |

13 | |

14 |
Copyright (C) 2012, 2013 Google Inc. |

15 | |

16 |
This program is free software; you can redistribute it and/or modify |

17 |
it under the terms of the GNU General Public License as published by |

18 |
the Free Software Foundation; either version 2 of the License, or |

19 |
(at your option) any later version. |

20 | |

21 |
This program is distributed in the hope that it will be useful, but |

22 |
WITHOUT ANY WARRANTY; without even the implied warranty of |

23 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |

24 |
General Public License for more details. |

25 | |

26 |
You should have received a copy of the GNU General Public License |

27 |
along with this program; if not, write to the Free Software |

28 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |

29 |
02110-1301, USA. |

30 | |

31 |
-} |

32 | |

33 |
module Ganeti.Types |

34 |
( AllocPolicy(..) |

35 |
, allocPolicyFromRaw |

36 |
, allocPolicyToRaw |

37 |
, InstanceStatus(..) |

38 |
, instanceStatusFromRaw |

39 |
, instanceStatusToRaw |

40 |
, DiskTemplate(..) |

41 |
, diskTemplateToRaw |

42 |
, diskTemplateFromRaw |

43 |
, NonNegative |

44 |
, fromNonNegative |

45 |
, mkNonNegative |

46 |
, Positive |

47 |
, fromPositive |

48 |
, mkPositive |

49 |
, Negative |

50 |
, fromNegative |

51 |
, mkNegative |

52 |
, NonEmpty |

53 |
, fromNonEmpty |

54 |
, mkNonEmpty |

55 |
, NonEmptyString |

56 |
, MigrationMode(..) |

57 |
, VerifyOptionalChecks(..) |

58 |
, DdmSimple(..) |

59 |
, DdmFull(..) |

60 |
, CVErrorCode(..) |

61 |
, cVErrorCodeToRaw |

62 |
, Hypervisor(..) |

63 |
, OobCommand(..) |

64 |
, StorageType(..) |

65 |
, NodeEvacMode(..) |

66 |
, FileDriver(..) |

67 |
, InstCreateMode(..) |

68 |
, RebootType(..) |

69 |
, ExportMode(..) |

70 |
, IAllocatorTestDir(..) |

71 |
, IAllocatorMode(..) |

72 |
, iAllocatorModeToRaw |

73 |
, NICMode(..) |

74 |
, nICModeToRaw |

75 |
, JobStatus(..) |

76 |
, jobStatusToRaw |

77 |
, jobStatusFromRaw |

78 |
, FinalizedJobStatus(..) |

79 |
, finalizedJobStatusToRaw |

80 |
, JobId |

81 |
, fromJobId |

82 |
, makeJobId |

83 |
, makeJobIdS |

84 |
, RelativeJobId |

85 |
, JobIdDep(..) |

86 |
, JobDependency(..) |

87 |
, OpSubmitPriority(..) |

88 |
, opSubmitPriorityToRaw |

89 |
, parseSubmitPriority |

90 |
, fmtSubmitPriority |

91 |
, OpStatus(..) |

92 |
, opStatusToRaw |

93 |
, opStatusFromRaw |

94 |
, ELogType(..) |

95 |
, InstReasonSrc(..) |

96 |
) where |

97 | |

98 |
import Control.Monad (liftM) |

99 |
import qualified Text.JSON as JSON |

100 |
import Text.JSON (JSON, readJSON, showJSON) |

101 |
import Data.Ratio (numerator, denominator) |

102 | |

103 |
import qualified Ganeti.Constants as C |

104 |
import qualified Ganeti.THH as THH |

105 |
import Ganeti.JSON |

106 |
import Ganeti.Utils |

107 | |

108 |
-- * Generic types |

109 | |

110 |
-- | Type that holds a non-negative value. |

111 |
newtype NonNegative a = NonNegative { fromNonNegative :: a } |

112 |
deriving (Show, Eq) |

113 | |

114 |
-- | Smart constructor for 'NonNegative'. |

115 |
mkNonNegative :: (Monad m, Num a, Ord a, Show a) => a -> m (NonNegative a) |

116 |
mkNonNegative i | i >= 0 = return (NonNegative i) |

117 |
| otherwise = fail $ "Invalid value for non-negative type '" ++ |

118 |
show i ++ "'" |

119 | |

120 |
instance (JSON.JSON a, Num a, Ord a, Show a) => JSON.JSON (NonNegative a) where |

121 |
showJSON = JSON.showJSON . fromNonNegative |

122 |
readJSON v = JSON.readJSON v >>= mkNonNegative |

123 | |

124 |
-- | Type that holds a positive value. |

125 |
newtype Positive a = Positive { fromPositive :: a } |

126 |
deriving (Show, Eq) |

127 | |

128 |
-- | Smart constructor for 'Positive'. |

129 |
mkPositive :: (Monad m, Num a, Ord a, Show a) => a -> m (Positive a) |

130 |
mkPositive i | i > 0 = return (Positive i) |

131 |
| otherwise = fail $ "Invalid value for positive type '" ++ |

132 |
show i ++ "'" |

133 | |

134 |
instance (JSON.JSON a, Num a, Ord a, Show a) => JSON.JSON (Positive a) where |

135 |
showJSON = JSON.showJSON . fromPositive |

136 |
readJSON v = JSON.readJSON v >>= mkPositive |

137 | |

138 |
-- | Type that holds a negative value. |

139 |
newtype Negative a = Negative { fromNegative :: a } |

140 |
deriving (Show, Eq) |

141 | |

142 |
-- | Smart constructor for 'Negative'. |

143 |
mkNegative :: (Monad m, Num a, Ord a, Show a) => a -> m (Negative a) |

144 |
mkNegative i | i < 0 = return (Negative i) |

145 |
| otherwise = fail $ "Invalid value for negative type '" ++ |

146 |
show i ++ "'" |

147 | |

148 |
instance (JSON.JSON a, Num a, Ord a, Show a) => JSON.JSON (Negative a) where |

149 |
showJSON = JSON.showJSON . fromNegative |

150 |
readJSON v = JSON.readJSON v >>= mkNegative |

151 | |

152 |
-- | Type that holds a non-null list. |

153 |
newtype NonEmpty a = NonEmpty { fromNonEmpty :: [a] } |

154 |
deriving (Show, Eq) |

155 | |

156 |
-- | Smart constructor for 'NonEmpty'. |

157 |
mkNonEmpty :: (Monad m) => [a] -> m (NonEmpty a) |

158 |
mkNonEmpty [] = fail "Received empty value for non-empty list" |

159 |
mkNonEmpty xs = return (NonEmpty xs) |

160 | |

161 |
instance (JSON.JSON a) => JSON.JSON (NonEmpty a) where |

162 |
showJSON = JSON.showJSON . fromNonEmpty |

163 |
readJSON v = JSON.readJSON v >>= mkNonEmpty |

164 | |

165 |
-- | A simple type alias for non-empty strings. |

166 |
type NonEmptyString = NonEmpty Char |

167 | |

168 |
-- * Ganeti types |

169 | |

170 |
-- | Instance disk template type. |

171 |
$(THH.declareSADT "DiskTemplate" |

172 |
[ ("DTDiskless", 'C.dtDiskless) |

173 |
, ("DTFile", 'C.dtFile) |

174 |
, ("DTSharedFile", 'C.dtSharedFile) |

175 |
, ("DTPlain", 'C.dtPlain) |

176 |
, ("DTBlock", 'C.dtBlock) |

177 |
, ("DTDrbd8", 'C.dtDrbd8) |

178 |
, ("DTRbd", 'C.dtRbd) |

179 |
, ("DTExt", 'C.dtExt) |

180 |
]) |

181 |
$(THH.makeJSONInstance ''DiskTemplate) |

182 | |

183 |
instance HasStringRepr DiskTemplate where |

184 |
fromStringRepr = diskTemplateFromRaw |

185 |
toStringRepr = diskTemplateToRaw |

186 | |

187 |
-- | The Group allocation policy type. |

188 |
-- |

189 |
-- Note that the order of constructors is important as the automatic |

190 |
-- Ord instance will order them in the order they are defined, so when |

191 |
-- changing this data type be careful about the interaction with the |

192 |
-- desired sorting order. |

193 |
$(THH.declareSADT "AllocPolicy" |

194 |
[ ("AllocPreferred", 'C.allocPolicyPreferred) |

195 |
, ("AllocLastResort", 'C.allocPolicyLastResort) |

196 |
, ("AllocUnallocable", 'C.allocPolicyUnallocable) |

197 |
]) |

198 |
$(THH.makeJSONInstance ''AllocPolicy) |

199 | |

200 |
-- | The Instance real state type. FIXME: this could be improved to |

201 |
-- just wrap a /NormalState AdminStatus | ErrorState ErrorCondition/. |

202 |
$(THH.declareSADT "InstanceStatus" |

203 |
[ ("StatusDown", 'C.inststAdmindown) |

204 |
, ("StatusOffline", 'C.inststAdminoffline) |

205 |
, ("ErrorDown", 'C.inststErrordown) |

206 |
, ("ErrorUp", 'C.inststErrorup) |

207 |
, ("NodeDown", 'C.inststNodedown) |

208 |
, ("NodeOffline", 'C.inststNodeoffline) |

209 |
, ("Running", 'C.inststRunning) |

210 |
, ("WrongNode", 'C.inststWrongnode) |

211 |
]) |

212 |
$(THH.makeJSONInstance ''InstanceStatus) |

213 | |

214 |
-- | Migration mode. |

215 |
$(THH.declareSADT "MigrationMode" |

216 |
[ ("MigrationLive", 'C.htMigrationLive) |

217 |
, ("MigrationNonLive", 'C.htMigrationNonlive) |

218 |
]) |

219 |
$(THH.makeJSONInstance ''MigrationMode) |

220 | |

221 |
-- | Verify optional checks. |

222 |
$(THH.declareSADT "VerifyOptionalChecks" |

223 |
[ ("VerifyNPlusOneMem", 'C.verifyNplusoneMem) |

224 |
]) |

225 |
$(THH.makeJSONInstance ''VerifyOptionalChecks) |

226 | |

227 |
-- | Cluster verify error codes. |

228 |
$(THH.declareSADT "CVErrorCode" |

229 |
[ ("CvECLUSTERCFG", 'C.cvEclustercfgCode) |

230 |
, ("CvECLUSTERCERT", 'C.cvEclustercertCode) |

231 |
, ("CvECLUSTERFILECHECK", 'C.cvEclusterfilecheckCode) |

232 |
, ("CvECLUSTERDANGLINGNODES", 'C.cvEclusterdanglingnodesCode) |

233 |
, ("CvECLUSTERDANGLINGINST", 'C.cvEclusterdanglinginstCode) |

234 |
, ("CvEINSTANCEBADNODE", 'C.cvEinstancebadnodeCode) |

235 |
, ("CvEINSTANCEDOWN", 'C.cvEinstancedownCode) |

236 |
, ("CvEINSTANCELAYOUT", 'C.cvEinstancelayoutCode) |

237 |
, ("CvEINSTANCEMISSINGDISK", 'C.cvEinstancemissingdiskCode) |

238 |
, ("CvEINSTANCEFAULTYDISK", 'C.cvEinstancefaultydiskCode) |

239 |
, ("CvEINSTANCEWRONGNODE", 'C.cvEinstancewrongnodeCode) |

240 |
, ("CvEINSTANCESPLITGROUPS", 'C.cvEinstancesplitgroupsCode) |

241 |
, ("CvEINSTANCEPOLICY", 'C.cvEinstancepolicyCode) |

242 |
, ("CvENODEDRBD", 'C.cvEnodedrbdCode) |

243 |
, ("CvENODEDRBDHELPER", 'C.cvEnodedrbdhelperCode) |

244 |
, ("CvENODEFILECHECK", 'C.cvEnodefilecheckCode) |

245 |
, ("CvENODEHOOKS", 'C.cvEnodehooksCode) |

246 |
, ("CvENODEHV", 'C.cvEnodehvCode) |

247 |
, ("CvENODELVM", 'C.cvEnodelvmCode) |

248 |
, ("CvENODEN1", 'C.cvEnoden1Code) |

249 |
, ("CvENODENET", 'C.cvEnodenetCode) |

250 |
, ("CvENODEOS", 'C.cvEnodeosCode) |

251 |
, ("CvENODEORPHANINSTANCE", 'C.cvEnodeorphaninstanceCode) |

252 |
, ("CvENODEORPHANLV", 'C.cvEnodeorphanlvCode) |

253 |
, ("CvENODERPC", 'C.cvEnoderpcCode) |

254 |
, ("CvENODESSH", 'C.cvEnodesshCode) |

255 |
, ("CvENODEVERSION", 'C.cvEnodeversionCode) |

256 |
, ("CvENODESETUP", 'C.cvEnodesetupCode) |

257 |
, ("CvENODETIME", 'C.cvEnodetimeCode) |

258 |
, ("CvENODEOOBPATH", 'C.cvEnodeoobpathCode) |

259 |
, ("CvENODEUSERSCRIPTS", 'C.cvEnodeuserscriptsCode) |

260 |
, ("CvENODEFILESTORAGEPATHS", 'C.cvEnodefilestoragepathsCode) |

261 |
]) |

262 |
$(THH.makeJSONInstance ''CVErrorCode) |

263 | |

264 |
-- | Dynamic device modification, just add\/remove version. |

265 |
$(THH.declareSADT "DdmSimple" |

266 |
[ ("DdmSimpleAdd", 'C.ddmAdd) |

267 |
, ("DdmSimpleRemove", 'C.ddmRemove) |

268 |
]) |

269 |
$(THH.makeJSONInstance ''DdmSimple) |

270 | |

271 |
-- | Dynamic device modification, all operations version. |

272 |
$(THH.declareSADT "DdmFull" |

273 |
[ ("DdmFullAdd", 'C.ddmAdd) |

274 |
, ("DdmFullRemove", 'C.ddmRemove) |

275 |
, ("DdmFullModify", 'C.ddmModify) |

276 |
]) |

277 |
$(THH.makeJSONInstance ''DdmFull) |

278 | |

279 |
-- | Hypervisor type definitions. |

280 |
$(THH.declareSADT "Hypervisor" |

281 |
[ ( "Kvm", 'C.htKvm ) |

282 |
, ( "XenPvm", 'C.htXenPvm ) |

283 |
, ( "Chroot", 'C.htChroot ) |

284 |
, ( "XenHvm", 'C.htXenHvm ) |

285 |
, ( "Lxc", 'C.htLxc ) |

286 |
, ( "Fake", 'C.htFake ) |

287 |
]) |

288 |
$(THH.makeJSONInstance ''Hypervisor) |

289 | |

290 |
-- | Oob command type. |

291 |
$(THH.declareSADT "OobCommand" |

292 |
[ ("OobHealth", 'C.oobHealth) |

293 |
, ("OobPowerCycle", 'C.oobPowerCycle) |

294 |
, ("OobPowerOff", 'C.oobPowerOff) |

295 |
, ("OobPowerOn", 'C.oobPowerOn) |

296 |
, ("OobPowerStatus", 'C.oobPowerStatus) |

297 |
]) |

298 |
$(THH.makeJSONInstance ''OobCommand) |

299 | |

300 |
-- | Storage type. |

301 |
$(THH.declareSADT "StorageType" |

302 |
[ ("StorageFile", 'C.stFile) |

303 |
, ("StorageLvmPv", 'C.stLvmPv) |

304 |
, ("StorageLvmVg", 'C.stLvmVg) |

305 |
]) |

306 |
$(THH.makeJSONInstance ''StorageType) |

307 | |

308 |
-- | Node evac modes. |

309 |
$(THH.declareSADT "NodeEvacMode" |

310 |
[ ("NEvacPrimary", 'C.iallocatorNevacPri) |

311 |
, ("NEvacSecondary", 'C.iallocatorNevacSec) |

312 |
, ("NEvacAll", 'C.iallocatorNevacAll) |

313 |
]) |

314 |
$(THH.makeJSONInstance ''NodeEvacMode) |

315 | |

316 |
-- | The file driver type. |

317 |
$(THH.declareSADT "FileDriver" |

318 |
[ ("FileLoop", 'C.fdLoop) |

319 |
, ("FileBlktap", 'C.fdBlktap) |

320 |
]) |

321 |
$(THH.makeJSONInstance ''FileDriver) |

322 | |

323 |
-- | The instance create mode. |

324 |
$(THH.declareSADT "InstCreateMode" |

325 |
[ ("InstCreate", 'C.instanceCreate) |

326 |
, ("InstImport", 'C.instanceImport) |

327 |
, ("InstRemoteImport", 'C.instanceRemoteImport) |

328 |
]) |

329 |
$(THH.makeJSONInstance ''InstCreateMode) |

330 | |

331 |
-- | Reboot type. |

332 |
$(THH.declareSADT "RebootType" |

333 |
[ ("RebootSoft", 'C.instanceRebootSoft) |

334 |
, ("RebootHard", 'C.instanceRebootHard) |

335 |
, ("RebootFull", 'C.instanceRebootFull) |

336 |
]) |

337 |
$(THH.makeJSONInstance ''RebootType) |

338 | |

339 |
-- | Export modes. |

340 |
$(THH.declareSADT "ExportMode" |

341 |
[ ("ExportModeLocal", 'C.exportModeLocal) |

342 |
, ("ExportModeRemove", 'C.exportModeRemote) |

343 |
]) |

344 |
$(THH.makeJSONInstance ''ExportMode) |

345 | |

346 |
-- | IAllocator run types (OpTestIAllocator). |

347 |
$(THH.declareSADT "IAllocatorTestDir" |

348 |
[ ("IAllocatorDirIn", 'C.iallocatorDirIn) |

349 |
, ("IAllocatorDirOut", 'C.iallocatorDirOut) |

350 |
]) |

351 |
$(THH.makeJSONInstance ''IAllocatorTestDir) |

352 | |

353 |
-- | IAllocator mode. FIXME: use this in "HTools.Backend.IAlloc". |

354 |
$(THH.declareSADT "IAllocatorMode" |

355 |
[ ("IAllocatorAlloc", 'C.iallocatorModeAlloc) |

356 |
, ("IAllocatorMultiAlloc", 'C.iallocatorModeMultiAlloc) |

357 |
, ("IAllocatorReloc", 'C.iallocatorModeReloc) |

358 |
, ("IAllocatorNodeEvac", 'C.iallocatorModeNodeEvac) |

359 |
, ("IAllocatorChangeGroup", 'C.iallocatorModeChgGroup) |

360 |
]) |

361 |
$(THH.makeJSONInstance ''IAllocatorMode) |

362 | |

363 |
-- | Network mode. |

364 |
$(THH.declareSADT "NICMode" |

365 |
[ ("NMBridged", 'C.nicModeBridged) |

366 |
, ("NMRouted", 'C.nicModeRouted) |

367 |
, ("NMOvs", 'C.nicModeOvs) |

368 |
]) |

369 |
$(THH.makeJSONInstance ''NICMode) |

370 | |

371 |
-- | The JobStatus data type. Note that this is ordered especially |

372 |
-- such that greater\/lesser comparison on values of this type makes |

373 |
-- sense. |

374 |
$(THH.declareSADT "JobStatus" |

375 |
[ ("JOB_STATUS_QUEUED", 'C.jobStatusQueued) |

376 |
, ("JOB_STATUS_WAITING", 'C.jobStatusWaiting) |

377 |
, ("JOB_STATUS_CANCELING", 'C.jobStatusCanceling) |

378 |
, ("JOB_STATUS_RUNNING", 'C.jobStatusRunning) |

379 |
, ("JOB_STATUS_CANCELED", 'C.jobStatusCanceled) |

380 |
, ("JOB_STATUS_SUCCESS", 'C.jobStatusSuccess) |

381 |
, ("JOB_STATUS_ERROR", 'C.jobStatusError) |

382 |
]) |

383 |
$(THH.makeJSONInstance ''JobStatus) |

384 | |

385 |
-- | Finalized job status. |

386 |
$(THH.declareSADT "FinalizedJobStatus" |

387 |
[ ("JobStatusCanceled", 'C.jobStatusCanceled) |

388 |
, ("JobStatusSuccessful", 'C.jobStatusSuccess) |

389 |
, ("JobStatusFailed", 'C.jobStatusError) |

390 |
]) |

391 |
$(THH.makeJSONInstance ''FinalizedJobStatus) |

392 | |

393 |
-- | The Ganeti job type. |

394 |
newtype JobId = JobId { fromJobId :: Int } |

395 |
deriving (Show, Eq) |

396 | |

397 |
-- | Builds a job ID. |

398 |
makeJobId :: (Monad m) => Int -> m JobId |

399 |
makeJobId i | i >= 0 = return $ JobId i |

400 |
| otherwise = fail $ "Invalid value for job ID ' " ++ show i ++ "'" |

401 | |

402 |
-- | Builds a job ID from a string. |

403 |
makeJobIdS :: (Monad m) => String -> m JobId |

404 |
makeJobIdS s = tryRead "parsing job id" s >>= makeJobId |

405 | |

406 |
-- | Parses a job ID. |

407 |
parseJobId :: (Monad m) => JSON.JSValue -> m JobId |

408 |
parseJobId (JSON.JSString x) = makeJobIdS $ JSON.fromJSString x |

409 |
parseJobId (JSON.JSRational _ x) = |

410 |
if denominator x /= 1 |

411 |
then fail $ "Got fractional job ID from master daemon?! Value:" ++ show x |

412 |
-- FIXME: potential integer overflow here on 32-bit platforms |

413 |
else makeJobId . fromIntegral . numerator $ x |

414 |
parseJobId x = fail $ "Wrong type/value for job id: " ++ show x |

415 | |

416 |
instance JSON.JSON JobId where |

417 |
showJSON = JSON.showJSON . fromJobId |

418 |
readJSON = parseJobId |

419 | |

420 |
-- | Relative job ID type alias. |

421 |
type RelativeJobId = Negative Int |

422 | |

423 |
-- | Job ID dependency. |

424 |
data JobIdDep = JobDepRelative RelativeJobId |

425 |
| JobDepAbsolute JobId |

426 |
deriving (Show, Eq) |

427 | |

428 |
instance JSON.JSON JobIdDep where |

429 |
showJSON (JobDepRelative i) = showJSON i |

430 |
showJSON (JobDepAbsolute i) = showJSON i |

431 |
readJSON v = |

432 |
case JSON.readJSON v::JSON.Result (Negative Int) of |

433 |
-- first try relative dependency, usually most common |

434 |
JSON.Ok r -> return $ JobDepRelative r |

435 |
JSON.Error _ -> liftM JobDepAbsolute (parseJobId v) |

436 | |

437 |
-- | Job Dependency type. |

438 |
data JobDependency = JobDependency JobIdDep [FinalizedJobStatus] |

439 |
deriving (Show, Eq) |

440 | |

441 |
instance JSON JobDependency where |

442 |
showJSON (JobDependency dep status) = showJSON (dep, status) |

443 |
readJSON = liftM (uncurry JobDependency) . readJSON |

444 | |

445 |
-- | Valid opcode priorities for submit. |

446 |
$(THH.declareIADT "OpSubmitPriority" |

447 |
[ ("OpPrioLow", 'C.opPrioLow) |

448 |
, ("OpPrioNormal", 'C.opPrioNormal) |

449 |
, ("OpPrioHigh", 'C.opPrioHigh) |

450 |
]) |

451 |
$(THH.makeJSONInstance ''OpSubmitPriority) |

452 | |

453 |
-- | Parse submit priorities from a string. |

454 |
parseSubmitPriority :: (Monad m) => String -> m OpSubmitPriority |

455 |
parseSubmitPriority "low" = return OpPrioLow |

456 |
parseSubmitPriority "normal" = return OpPrioNormal |

457 |
parseSubmitPriority "high" = return OpPrioHigh |

458 |
parseSubmitPriority str = fail $ "Unknown priority '" ++ str ++ "'" |

459 | |

460 |
-- | Format a submit priority as string. |

461 |
fmtSubmitPriority :: OpSubmitPriority -> String |

462 |
fmtSubmitPriority OpPrioLow = "low" |

463 |
fmtSubmitPriority OpPrioNormal = "normal" |

464 |
fmtSubmitPriority OpPrioHigh = "high" |

465 | |

466 |
-- | Our ADT for the OpCode status at runtime (while in a job). |

467 |
$(THH.declareSADT "OpStatus" |

468 |
[ ("OP_STATUS_QUEUED", 'C.opStatusQueued) |

469 |
, ("OP_STATUS_WAITING", 'C.opStatusWaiting) |

470 |
, ("OP_STATUS_CANCELING", 'C.opStatusCanceling) |

471 |
, ("OP_STATUS_RUNNING", 'C.opStatusRunning) |

472 |
, ("OP_STATUS_CANCELED", 'C.opStatusCanceled) |

473 |
, ("OP_STATUS_SUCCESS", 'C.opStatusSuccess) |

474 |
, ("OP_STATUS_ERROR", 'C.opStatusError) |

475 |
]) |

476 |
$(THH.makeJSONInstance ''OpStatus) |

477 | |

478 |
-- | Type for the job message type. |

479 |
$(THH.declareSADT "ELogType" |

480 |
[ ("ELogMessage", 'C.elogMessage) |

481 |
, ("ELogRemoteImport", 'C.elogRemoteImport) |

482 |
, ("ELogJqueueTest", 'C.elogJqueueTest) |

483 |
]) |

484 |
$(THH.makeJSONInstance ''ELogType) |

485 | |

486 |
-- | Type for the source of the state change of instances. |

487 |
$(THH.declareSADT "InstReasonSrc" |

488 |
[ ("IRSCli", 'C.instanceReasonSourceCli) |

489 |
, ("IRSRapi", 'C.instanceReasonSourceRapi) |

490 |
]) |

491 |
$(THH.makeJSONInstance ''InstReasonSrc) |

492 | |

493 |