Revision 05ff7a00
b/htools/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
286 | 286 |
when (snode == pnode) $ |
287 | 287 |
fail "Internal error: selected primary as new secondary?!" |
288 | 288 |
|
289 |
nodes' <- if (nodes == [pnode, snode])
|
|
289 |
nodes' <- if nodes == [pnode, snode]
|
|
290 | 290 |
then return [snode] -- only the new secondary is needed |
291 | 291 |
else fail $ "Internal error: inconsistent node list (" ++ |
292 | 292 |
show nodes ++ ") versus instance nodes (" ++ show pnode ++ |
b/htools/Ganeti/HTools/Loader.hs | ||
---|---|---|
146 | 146 |
prefixMatch :: String -- ^ Lookup |
147 | 147 |
-> String -- ^ Full name |
148 | 148 |
-> Bool -- ^ Whether there is a prefix match |
149 |
prefixMatch lkp = isPrefixOf (lkp ++ ".")
|
|
149 |
prefixMatch = isPrefixOf . (++ ".")
|
|
150 | 150 |
|
151 | 151 |
-- | Is the lookup priority a "good" one? |
152 | 152 |
goodMatchPriority :: MatchPriority -> Bool |
... | ... | |
178 | 178 |
select (min new old) |
179 | 179 |
-- special cases: |
180 | 180 |
-- short circuit if the new result is an exact match |
181 |
[ ((lrMatchPriority new) == ExactMatch, new)
|
|
181 |
[ (lrMatchPriority new == ExactMatch, new)
|
|
182 | 182 |
-- if both are partial matches generate a multiple match |
183 | 183 |
, (partial2, LookupResult MultipleMatch lkp) |
184 | 184 |
] where new = compareNameComponent cstr lkp |
b/htools/Ganeti/HTools/Node.hs | ||
---|---|---|
223 | 223 |
|
224 | 224 |
-- | Conversion formula from mDsk\/tDsk to loDsk. |
225 | 225 |
mDskToloDsk :: Double -> Double -> Int |
226 |
mDskToloDsk mval tdsk = floor (mval * tdsk)
|
|
226 |
mDskToloDsk mval = floor . (mval *)
|
|
227 | 227 |
|
228 | 228 |
-- | Conversion formula from mCpu\/tCpu to hiCpu. |
229 | 229 |
mCpuTohiCpu :: Double -> Double -> Int |
230 |
mCpuTohiCpu mval tcpu = floor (mval * tcpu)
|
|
230 |
mCpuTohiCpu mval = floor . (mval *)
|
|
231 | 231 |
|
232 | 232 |
-- | Changes the index. |
233 | 233 |
-- |
b/htools/Ganeti/HTools/QCHelper.hs | ||
---|---|---|
41 | 41 |
tests <- mapM (\n -> [| (run $(varE n), $(litE . StringL . nameBase $ n)) |]) |
42 | 42 |
tdef |
43 | 43 |
sigtype <- [t| (String, [(Args -> IO Result, String)]) |] |
44 |
return $ [ SigD fullname sigtype |
|
45 |
, ValD (VarP fullname) (NormalB (TupE [LitE (StringL tsname), |
|
46 |
ListE tests])) [] |
|
47 |
] |
|
44 |
return [ SigD fullname sigtype |
|
45 |
, ValD (VarP fullname) (NormalB (TupE [LitE (StringL tsname), |
|
46 |
ListE tests])) [] |
|
47 |
] |
b/htools/Ganeti/HTools/Utils.hs | ||
---|---|---|
72 | 72 |
|
73 | 73 |
-- | Show the first parameter before returning the second one. |
74 | 74 |
debugXy :: Show a => a -> b -> b |
75 |
debugXy a b = debug a `seq` b
|
|
75 |
debugXy = seq . debug
|
|
76 | 76 |
|
77 | 77 |
-- * Miscellaneous |
78 | 78 |
|
b/htools/Ganeti/Luxi.hs | ||
---|---|---|
132 | 132 |
[ ("flag", [t| Bool |], [| id |]) ], |
133 | 133 |
[| J.showJSON |]) |
134 | 134 |
, ("SetWatcherPause", |
135 |
[ ("duration", [t| Double |], [| \x -> [x] |]) ],
|
|
135 |
[ ("duration", [t| Double |], [| (: []) |]) ],
|
|
136 | 136 |
[| J.showJSON |]) |
137 | 137 |
]) |
138 | 138 |
|
b/htools/Ganeti/THH.hs | ||
---|---|---|
227 | 227 |
deCamelCase = |
228 | 228 |
intercalate "_" . map (map toUpper) . groupBy (\_ b -> not $ isUpper b) |
229 | 229 |
|
230 |
-- | Computes the name of a given constructor |
|
230 |
-- | Computes the name of a given constructor.
|
|
231 | 231 |
constructorName :: Con -> Q Name |
232 | 232 |
constructorName (NormalC name _) = return name |
233 | 233 |
constructorName (RecC name _) = return name |
... | ... | |
255 | 255 |
genOpID :: Name -> String -> Q [Dec] |
256 | 256 |
genOpID = genConstrToStr deCamelCase |
257 | 257 |
|
258 |
-- | OpCode parameter (field) type |
|
258 |
-- | OpCode parameter (field) type.
|
|
259 | 259 |
type OpParam = (String, Q Type, Q Exp) |
260 | 260 |
|
261 | 261 |
-- | Generates the OpCode data type. |
... | ... | |
292 | 292 |
(loadsig, loadfn) <- genLoadOpCode cons |
293 | 293 |
return [declD, loadsig, loadfn, savesig, savefn] |
294 | 294 |
|
295 |
-- | Checks whether a given parameter is options |
|
295 |
-- | Checks whether a given parameter is options.
|
|
296 | 296 |
-- |
297 | 297 |
-- This requires that it's a 'Maybe'. |
298 | 298 |
isOptional :: Type -> Bool |
b/htools/htools.hs | ||
---|---|---|
56 | 56 |
|
57 | 57 |
main :: IO () |
58 | 58 |
main = do |
59 |
binary <- getEnv "HTOOLS" `catch` (\_ -> getProgName)
|
|
59 |
binary <- getEnv "HTOOLS" `catch` const getProgName
|
|
60 | 60 |
let name = map toLower binary |
61 | 61 |
boolnames = map (\(x, y) -> (x == name, y)) personalities |
62 | 62 |
select (usage name) boolnames |
Also available in: Unified diff