Revision 5183e8be htools/Ganeti/Confd/Server.hs
b/htools/Ganeti/Confd/Server.hs | ||
---|---|---|
45 | 45 |
import System.INotify |
46 | 46 |
|
47 | 47 |
import Ganeti.BasicTypes |
48 |
import Ganeti.Errors |
|
48 | 49 |
import Ganeti.Daemon |
49 | 50 |
import Ganeti.JSON |
50 | 51 |
import Ganeti.Objects |
... | ... | |
130 | 131 |
TOD ctime _ <- getClockTime |
131 | 132 |
return ctime |
132 | 133 |
|
134 |
-- | Converter from specific error to a string format. |
|
135 |
gntErrorToResult :: ErrorResult a -> Result a |
|
136 |
gntErrorToResult (Bad err) = Bad (show err) |
|
137 |
gntErrorToResult (Ok x) = Ok x |
|
138 |
|
|
133 | 139 |
-- * Confd base functionality |
134 | 140 |
|
135 | 141 |
-- | Computes the node role. |
... | ... | |
170 | 176 |
EmptyQuery -> return (ReplyStatusOk, J.showJSON master_name) |
171 | 177 |
PlainQuery _ -> return queryArgumentError |
172 | 178 |
DictQuery reqq -> do |
173 |
mnode <- getNode cfg master_name |
|
174 |
let fvals =map (\field -> case field of |
|
175 |
ReqFieldName -> master_name |
|
176 |
ReqFieldIp -> clusterMasterIp cluster |
|
177 |
ReqFieldMNodePip -> nodePrimaryIp mnode |
|
178 |
) (confdReqQFields reqq) |
|
179 |
mnode <- gntErrorToResult $ getNode cfg master_name
|
|
180 |
let fvals = map (\field -> case field of
|
|
181 |
ReqFieldName -> master_name
|
|
182 |
ReqFieldIp -> clusterMasterIp cluster
|
|
183 |
ReqFieldMNodePip -> nodePrimaryIp mnode
|
|
184 |
) (confdReqQFields reqq)
|
|
179 | 185 |
return (ReplyStatusOk, J.showJSON fvals) |
180 | 186 |
where master_name = clusterMasterNode cluster |
181 | 187 |
cluster = configCluster cfg |
... | ... | |
231 | 237 |
node_name <- case confdRqQuery req of |
232 | 238 |
PlainQuery str -> return str |
233 | 239 |
_ -> fail $ "Invalid query type " ++ show (confdRqQuery req) |
234 |
node <- getNode cfg node_name |
|
240 |
node <- gntErrorToResult $ getNode cfg node_name
|
|
235 | 241 |
let minors = concatMap (getInstMinorsForNode (nodeName node)) . |
236 | 242 |
M.elems . fromContainer . configInstances $ cfg |
237 | 243 |
encoded = [J.JSArray [J.showJSON a, J.showJSON b, J.showJSON c, |
Also available in: Unified diff