5 module Ganeti.HTools.Types
8 import qualified Ganeti.HTools.Container as Container
9 import qualified Ganeti.HTools.Instance as Instance
10 import qualified Ganeti.HTools.Node as Node
12 type NodeList = Container.Container Node.Node
13 type InstanceList = Container.Container Instance.Instance
15 -- | The type used to hold idx-to-name mappings
16 type NameList = [(Int, String)]
18 -- | The type used to hold name-to-idx mappings
19 type NameAssoc = [(String, Int)]
21 type IdxNode = [(Int, Node.Node)]
22 type IdxInstance = [(Int, Instance.Instance)]
26 This is similar to the JSON library Result type - *very* similar, but
27 we want to use it in multiple places, so we abstract it into a
37 instance Monad Result where
38 (>>=) (Bad x) _ = Bad x
39 (>>=) (Ok x) fn = fn x
43 -- | A generic class for nodes and instances
47 setName :: a -> String -> a
48 setIdx :: a -> Int -> a
50 -- Let's make nodes elements of the cluster
51 instance Element Node.Node where
54 setName = Node.setName
58 instance Element Instance.Instance where
61 setName = Instance.setName
62 setIdx = Instance.setIdx