Revision 72747d91 src/Ganeti/HTools/Backend/IAlloc.hs
b/src/Ganeti/HTools/Backend/IAlloc.hs | ||
---|---|---|
4 | 4 |
|
5 | 5 |
{- |
6 | 6 |
|
7 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc. |
|
7 |
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
|
|
8 | 8 |
|
9 | 9 |
This program is free software; you can redistribute it and/or modify |
10 | 10 |
it under the terms of the GNU General Public License as published by |
... | ... | |
82 | 82 |
parseInstance ktn n a = do |
83 | 83 |
base <- parseBaseInstance n a |
84 | 84 |
nodes <- fromObj a "nodes" |
85 |
pnode <- if null nodes |
|
86 |
then Bad $ "empty node list for instance " ++ n |
|
87 |
else readEitherString $ head nodes |
|
85 |
(pnode, snodes) <- |
|
86 |
case nodes of |
|
87 |
[] -> Bad $ "empty node list for instance " ++ n |
|
88 |
x:xs -> readEitherString x >>= \x' -> return (x', xs) |
|
88 | 89 |
pidx <- lookupNode ktn n pnode |
89 |
let snodes = tail nodes |
|
90 |
sidx <- if null snodes |
|
91 |
then return Node.noSecondary |
|
92 |
else readEitherString (head snodes) >>= lookupNode ktn n |
|
90 |
sidx <- case snodes of |
|
91 |
[] -> return Node.noSecondary |
|
92 |
x:_ -> readEitherString x >>= lookupNode ktn n |
|
93 | 93 |
return (n, Instance.setBoth (snd base) pidx sidx) |
94 | 94 |
|
95 | 95 |
-- | Parses a node as found in the cluster node list. |
Also available in: Unified diff