Revision f22b987a
b/src/Ganeti/DataCollectors/Lv.hs | ||
---|---|---|
48 | 48 |
import Ganeti.DataCollectors.CLI |
49 | 49 |
import Ganeti.DataCollectors.Types |
50 | 50 |
import Ganeti.Storage.Lvm.LVParser |
51 |
import Ganeti.Storage.Lvm.Types |
|
51 | 52 |
import Ganeti.Utils |
52 | 53 |
|
53 | 54 |
|
... | ... | |
94 | 95 |
arguments :: [ArgCompletion] |
95 | 96 |
arguments = [ArgCompletion OptComplFile 0 (Just 0)] |
96 | 97 |
|
97 |
-- | This function computes the JSON representation of the LV status |
|
98 |
buildJsonReport :: Maybe FilePath -> IO J.JSValue |
|
99 |
buildJsonReport inputFile = do |
|
98 |
-- | Get information about logical volumes from file (if specified) or |
|
99 |
-- by actually running the command to get it from a live cluster. |
|
100 |
getLvInfo :: Maybe FilePath -> IO [LVInfo] |
|
101 |
getLvInfo inputFile = do |
|
100 | 102 |
let cmd = lvCommand |
101 | 103 |
params = lvParams |
102 | 104 |
fromLvs = |
... | ... | |
106 | 108 |
maybe fromLvs (\fn -> ((E.try $ readFile fn) :: IO (Either IOError String)) |
107 | 109 |
>>= exitIfBad "reading from file" . either (BT.Bad . show) BT.Ok) |
108 | 110 |
inputFile |
109 |
lvInfo <- |
|
110 |
case A.parse lvParser $ pack contents of |
|
111 |
A.Fail unparsedText contexts errorMessage -> exitErr $ |
|
112 |
show (Prelude.take defaultCharNum $ unpack unparsedText) ++ "\n" |
|
113 |
++ show contexts ++ "\n" ++ errorMessage |
|
114 |
A.Done _ lvinfoD -> return lvinfoD |
|
111 |
case A.parse lvParser $ pack contents of |
|
112 |
A.Fail unparsedText contexts errorMessage -> exitErr $ |
|
113 |
show (Prelude.take defaultCharNum $ unpack unparsedText) ++ "\n" |
|
114 |
++ show contexts ++ "\n" ++ errorMessage |
|
115 |
A.Done _ lvinfoD -> return lvinfoD |
|
116 |
|
|
117 |
-- | This function computes the JSON representation of the LV status |
|
118 |
buildJsonReport :: Maybe FilePath -> IO J.JSValue |
|
119 |
buildJsonReport inputFile = do |
|
120 |
lvInfo <- getLvInfo inputFile |
|
115 | 121 |
return $ J.showJSON lvInfo |
116 | 122 |
|
117 | 123 |
-- | This function computes the DCReport for the logical volumes. |
Also available in: Unified diff