Revision 277a2ec9 htools/Ganeti/Objects.hs
b/htools/Ganeti/Objects.hs | ||
---|---|---|
229 | 229 |
, ("LD_FILE", 'C.ldFile) |
230 | 230 |
, ("LD_BLOCKDEV", 'C.ldBlockdev) |
231 | 231 |
, ("LD_RADOS", 'C.ldRbd) |
232 |
, ("LD_EXT", 'C.ldExt) |
|
232 | 233 |
]) |
233 | 234 |
$(makeJSONInstance ''DiskType) |
234 | 235 |
|
... | ... | |
253 | 254 |
| LIDFile FileDriver String -- ^ Driver, path |
254 | 255 |
| LIDBlockDev BlockDriver String -- ^ Driver, path (must be under /dev) |
255 | 256 |
| LIDRados String String -- ^ Unused, path |
257 |
| LIDExt String String -- ^ ExtProvider, unique name |
|
256 | 258 |
deriving (Show, Eq) |
257 | 259 |
|
258 | 260 |
-- | Mapping from a logical id to a disk type. |
... | ... | |
262 | 264 |
lidDiskType (LIDFile {}) = LD_FILE |
263 | 265 |
lidDiskType (LIDBlockDev {}) = LD_BLOCKDEV |
264 | 266 |
lidDiskType (LIDRados {}) = LD_RADOS |
267 |
lidDiskType (LIDExt {}) = LD_EXT |
|
265 | 268 |
|
266 | 269 |
-- | Builds the extra disk_type field for a given logical id. |
267 | 270 |
lidEncodeType :: DiskLogicalId -> [(String, JSValue)] |
... | ... | |
276 | 279 |
encodeDLId (LIDRados pool name) = JSArray [showJSON pool, showJSON name] |
277 | 280 |
encodeDLId (LIDFile driver name) = JSArray [showJSON driver, showJSON name] |
278 | 281 |
encodeDLId (LIDBlockDev driver name) = JSArray [showJSON driver, showJSON name] |
282 |
encodeDLId (LIDExt extprovider name) = JSArray [showJSON extprovider, showJSON name] |
|
279 | 283 |
|
280 | 284 |
-- | Custom encoder for DiskLogicalId, composing both the logical id |
281 | 285 |
-- and the extra disk_type field. |
... | ... | |
327 | 331 |
path' <- readJSON path |
328 | 332 |
return $ LIDRados driver' path' |
329 | 333 |
_ -> fail "Can't read logical_id for rdb type" |
334 |
LD_EXT -> |
|
335 |
case lid of |
|
336 |
JSArray [extprovider, name] -> do |
|
337 |
extprovider' <- readJSON extprovider |
|
338 |
name' <- readJSON name |
|
339 |
return $ LIDExt extprovider' name' |
|
340 |
_ -> fail "Can't read logical_id for extstorage type" |
|
330 | 341 |
|
331 | 342 |
-- | Disk data structure. |
332 | 343 |
-- |
Also available in: Unified diff