Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-ganeti
Commits
b3f0710c
Commit
b3f0710c
authored
Nov 19, 2010
by
Iustin Pop
Browse files
Luxi loader: split parsing from loading
parent
748bfcc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Ganeti/HTools/Luxi.hs
View file @
b3f0710c
...
...
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module
Ganeti.HTools.Luxi
(
loadData
,
parseData
)
where
import
qualified
Control.Exception
as
E
...
...
@@ -145,9 +146,9 @@ getClusterTags v = do
-- * Main loader functionality
-- | Builds the cluster data from an URL.
lo
adData
::
String
-- ^ Unix socket to use as source
->
IO
(
Result
(
Node
.
AssocList
,
Instance
.
AssocList
,
[
String
])
)
lo
adData
master
=
re
adData
::
String
-- ^ Unix socket to use as source
->
IO
(
Result
JSValue
,
Result
JSValue
,
Result
JSValue
)
re
adData
master
=
E
.
bracket
(
L
.
getClient
master
)
L
.
closeClient
...
...
@@ -155,11 +156,20 @@ loadData master =
nodes
<-
queryNodes
s
instances
<-
queryInstances
s
cinfo
<-
queryClusterInfo
s
return
$
do
-- Result monad
node_data
<-
nodes
>>=
getNodes
let
(
node_names
,
node_idx
)
=
assignIndices
node_data
inst_data
<-
instances
>>=
getInstances
node_names
let
(
_
,
inst_idx
)
=
assignIndices
inst_data
ctags
<-
cinfo
>>=
getClusterTags
return
(
node_idx
,
inst_idx
,
ctags
)
return
(
nodes
,
instances
,
cinfo
)
)
parseData
::
(
Result
JSValue
,
Result
JSValue
,
Result
JSValue
)
->
Result
(
Node
.
AssocList
,
Instance
.
AssocList
,
[
String
])
parseData
(
nodes
,
instances
,
cinfo
)
=
do
node_data
<-
nodes
>>=
getNodes
let
(
node_names
,
node_idx
)
=
assignIndices
node_data
inst_data
<-
instances
>>=
getInstances
node_names
let
(
_
,
inst_idx
)
=
assignIndices
inst_data
ctags
<-
cinfo
>>=
getClusterTags
return
(
node_idx
,
inst_idx
,
ctags
)
-- | Top level function for data loading
loadData
::
String
-- ^ Unix socket to use as source
->
IO
(
Result
(
Node
.
AssocList
,
Instance
.
AssocList
,
[
String
]))
loadData
master
=
readData
master
>>=
return
.
parseData
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment