Revision 6a28e02c
b/htest/Test/Ganeti/Types.hs | ||
---|---|---|
72 | 72 |
|
73 | 73 |
$(genArbitrary ''Hypervisor) |
74 | 74 |
|
75 |
$(genArbitrary ''OobCommand) |
|
76 |
|
|
75 | 77 |
$(genArbitrary ''StorageType) |
76 | 78 |
|
79 |
$(genArbitrary ''NodeEvacMode) |
|
80 |
|
|
77 | 81 |
instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where |
78 | 82 |
arbitrary = do |
79 | 83 |
QuickCheck.NonEmpty lst <- arbitrary |
... | ... | |
160 | 164 |
prop_Hypervisor_serialisation :: Hypervisor -> Property |
161 | 165 |
prop_Hypervisor_serialisation = testSerialisation |
162 | 166 |
|
167 |
-- | Test 'OobCommand' serialisation. |
|
168 |
prop_OobCommand_serialisation :: OobCommand -> Property |
|
169 |
prop_OobCommand_serialisation = testSerialisation |
|
170 |
|
|
163 | 171 |
-- | Test 'StorageType' serialisation. |
164 | 172 |
prop_StorageType_serialisation :: StorageType -> Property |
165 | 173 |
prop_StorageType_serialisation = testSerialisation |
166 | 174 |
|
175 |
-- | Test 'NodeEvacMode' serialisation. |
|
176 |
prop_NodeEvacMode_serialisation :: NodeEvacMode -> Property |
|
177 |
prop_NodeEvacMode_serialisation = testSerialisation |
|
178 |
|
|
167 | 179 |
testSuite "Types" |
168 | 180 |
[ 'prop_AllocPolicy_serialisation |
169 | 181 |
, 'prop_DiskTemplate_serialisation |
... | ... | |
180 | 192 |
, 'prop_CVErrorCode_serialisation |
181 | 193 |
, 'case_CVErrorCode_pyequiv |
182 | 194 |
, 'prop_Hypervisor_serialisation |
195 |
, 'prop_OobCommand_serialisation |
|
183 | 196 |
, 'prop_StorageType_serialisation |
197 |
, 'prop_NodeEvacMode_serialisation |
|
184 | 198 |
] |
b/htools/Ganeti/Types.hs | ||
---|---|---|
49 | 49 |
, NonEmpty |
50 | 50 |
, fromNonEmpty |
51 | 51 |
, mkNonEmpty |
52 |
, NonEmptyString |
|
52 | 53 |
, MigrationMode(..) |
53 | 54 |
, VerifyOptionalChecks(..) |
54 | 55 |
, DdmSimple(..) |
55 | 56 |
, CVErrorCode(..) |
56 | 57 |
, cVErrorCodeToRaw |
57 | 58 |
, Hypervisor(..) |
59 |
, OobCommand(..) |
|
58 | 60 |
, StorageType(..) |
61 |
, NodeEvacMode(..) |
|
59 | 62 |
) where |
60 | 63 |
|
61 | 64 |
import qualified Text.JSON as JSON |
... | ... | |
107 | 110 |
showJSON = JSON.showJSON . fromNonEmpty |
108 | 111 |
readJSON v = JSON.readJSON v >>= mkNonEmpty |
109 | 112 |
|
113 |
-- | A simple type alias for non-empty strings. |
|
114 |
type NonEmptyString = NonEmpty Char |
|
115 |
|
|
110 | 116 |
-- * Ganeti types |
111 | 117 |
|
112 | 118 |
-- | Instance disk template type. |
... | ... | |
220 | 226 |
]) |
221 | 227 |
$(THH.makeJSONInstance ''Hypervisor) |
222 | 228 |
|
229 |
-- | Oob command type. |
|
230 |
$(THH.declareSADT "OobCommand" |
|
231 |
[ ("OobHealth", 'C.oobHealth) |
|
232 |
, ("OobPowerCycle", 'C.oobPowerCycle) |
|
233 |
, ("OobPowerOff", 'C.oobPowerOff) |
|
234 |
, ("OobPowerOn", 'C.oobPowerOn) |
|
235 |
, ("OobPowerStatus", 'C.oobPowerStatus) |
|
236 |
]) |
|
237 |
$(THH.makeJSONInstance ''OobCommand) |
|
238 |
|
|
223 | 239 |
-- | Storage type. |
224 | 240 |
$(THH.declareSADT "StorageType" |
225 | 241 |
[ ("StorageFile", 'C.stFile) |
... | ... | |
227 | 243 |
, ("StorageLvmVg", 'C.stLvmVg) |
228 | 244 |
]) |
229 | 245 |
$(THH.makeJSONInstance ''StorageType) |
246 |
|
|
247 |
-- | Node evac modes. |
|
248 |
$(THH.declareSADT "NodeEvacMode" |
|
249 |
[ ("NEvacPrimary", 'C.iallocatorNevacPri) |
|
250 |
, ("NEvacSecondary", 'C.iallocatorNevacSec) |
|
251 |
, ("NEvacAll", 'C.iallocatorNevacAll) |
|
252 |
]) |
|
253 |
$(THH.makeJSONInstance ''NodeEvacMode) |
Also available in: Unified diff