Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Query / Group.hs @ 3e02cd3c

History | View | Annotate | Download (3.4 kB)

1 40246fa0 Agata Murawska
{-| Implementation of the Ganeti Query2 node group queries.
2 40246fa0 Agata Murawska
3 40246fa0 Agata Murawska
 -}
4 40246fa0 Agata Murawska
5 40246fa0 Agata Murawska
{-
6 40246fa0 Agata Murawska
7 40246fa0 Agata Murawska
Copyright (C) 2012 Google Inc.
8 40246fa0 Agata Murawska
9 40246fa0 Agata Murawska
This program is free software; you can redistribute it and/or modify
10 40246fa0 Agata Murawska
it under the terms of the GNU General Public License as published by
11 40246fa0 Agata Murawska
the Free Software Foundation; either version 2 of the License, or
12 40246fa0 Agata Murawska
(at your option) any later version.
13 40246fa0 Agata Murawska
14 40246fa0 Agata Murawska
This program is distributed in the hope that it will be useful, but
15 40246fa0 Agata Murawska
WITHOUT ANY WARRANTY; without even the implied warranty of
16 40246fa0 Agata Murawska
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 40246fa0 Agata Murawska
General Public License for more details.
18 40246fa0 Agata Murawska
19 40246fa0 Agata Murawska
You should have received a copy of the GNU General Public License
20 40246fa0 Agata Murawska
along with this program; if not, write to the Free Software
21 40246fa0 Agata Murawska
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 40246fa0 Agata Murawska
02110-1301, USA.
23 40246fa0 Agata Murawska
24 40246fa0 Agata Murawska
-}
25 40246fa0 Agata Murawska
26 40246fa0 Agata Murawska
module Ganeti.Query.Group
27 40246fa0 Agata Murawska
  ( GroupRuntime(..)
28 40246fa0 Agata Murawska
  , groupFieldsMap
29 40246fa0 Agata Murawska
  ) where
30 40246fa0 Agata Murawska
31 40246fa0 Agata Murawska
import qualified Data.Map as Map
32 40246fa0 Agata Murawska
33 40246fa0 Agata Murawska
import Ganeti.Config
34 40246fa0 Agata Murawska
import Ganeti.Objects
35 40246fa0 Agata Murawska
import Ganeti.Query.Language
36 40246fa0 Agata Murawska
import Ganeti.Query.Common
37 40246fa0 Agata Murawska
import Ganeti.Query.Types
38 40246fa0 Agata Murawska
39 40246fa0 Agata Murawska
-- | There is no runtime.
40 40246fa0 Agata Murawska
data GroupRuntime = GroupRuntime
41 40246fa0 Agata Murawska
42 40246fa0 Agata Murawska
groupFields :: FieldList NodeGroup GroupRuntime
43 40246fa0 Agata Murawska
groupFields =
44 40246fa0 Agata Murawska
  [ (FieldDefinition "alloc_policy" "AllocPolicy" QFTText
45 40246fa0 Agata Murawska
       "Allocation policy for group",
46 f94a9680 Iustin Pop
     FieldSimple (rsNormal . groupAllocPolicy), QffNormal)
47 40246fa0 Agata Murawska
  , (FieldDefinition "custom_diskparams" "CustomDiskParameters" QFTOther
48 40246fa0 Agata Murawska
       "Custom disk parameters",
49 f94a9680 Iustin Pop
     FieldSimple (rsNormal . groupDiskparams), QffNormal)
50 40246fa0 Agata Murawska
  , (FieldDefinition "custom_ipolicy" "CustomInstancePolicy" QFTOther
51 40246fa0 Agata Murawska
       "Custom instance policy limitations",
52 f94a9680 Iustin Pop
     FieldSimple (rsNormal . groupIpolicy), QffNormal)
53 40246fa0 Agata Murawska
  , (FieldDefinition "custom_ndparams" "CustomNDParams" QFTOther
54 40246fa0 Agata Murawska
       "Custom node parameters",
55 f94a9680 Iustin Pop
     FieldSimple (rsNormal . groupNdparams), QffNormal)
56 40246fa0 Agata Murawska
  , (FieldDefinition "diskparams" "DiskParameters" QFTOther
57 90d033ef Iustin Pop
       "Disk parameters (merged)",
58 f94a9680 Iustin Pop
     FieldConfig (\cfg -> rsNormal . getGroupDiskParams cfg), QffNormal)
59 40246fa0 Agata Murawska
  , (FieldDefinition "ipolicy" "InstancePolicy" QFTOther
60 40246fa0 Agata Murawska
       "Instance policy limitations (merged)",
61 f94a9680 Iustin Pop
     FieldConfig (\cfg ng -> rsNormal (getGroupIpolicy cfg ng)), QffNormal)
62 40246fa0 Agata Murawska
  , (FieldDefinition "name" "Group" QFTText "Group name",
63 f94a9680 Iustin Pop
     FieldSimple (rsNormal . groupName), QffNormal)
64 40246fa0 Agata Murawska
  , (FieldDefinition "ndparams" "NDParams" QFTOther "Node parameters",
65 f94a9680 Iustin Pop
     FieldConfig (\cfg ng -> rsNormal (getGroupNdParams cfg ng)), QffNormal)
66 40246fa0 Agata Murawska
  , (FieldDefinition "node_cnt" "Nodes" QFTNumber "Number of nodes",
67 f94a9680 Iustin Pop
     FieldConfig (\cfg -> rsNormal . length . getGroupNodes cfg . groupName),
68 f94a9680 Iustin Pop
     QffNormal)
69 40246fa0 Agata Murawska
  , (FieldDefinition "node_list" "NodeList" QFTOther "List of nodes",
70 40246fa0 Agata Murawska
     FieldConfig (\cfg -> rsNormal . map nodeName .
71 f94a9680 Iustin Pop
                          getGroupNodes cfg . groupName), QffNormal)
72 40246fa0 Agata Murawska
  , (FieldDefinition "pinst_cnt" "Instances" QFTNumber
73 40246fa0 Agata Murawska
       "Number of primary instances",
74 40246fa0 Agata Murawska
     FieldConfig
75 f94a9680 Iustin Pop
       (\cfg -> rsNormal . length . fst . getGroupInstances cfg . groupName),
76 f94a9680 Iustin Pop
     QffNormal)
77 40246fa0 Agata Murawska
  , (FieldDefinition "pinst_list" "InstanceList" QFTOther
78 40246fa0 Agata Murawska
       "List of primary instances",
79 40246fa0 Agata Murawska
     FieldConfig (\cfg -> rsNormal . map instName . fst .
80 f94a9680 Iustin Pop
                          getGroupInstances cfg . groupName), QffNormal)
81 40246fa0 Agata Murawska
  ] ++
82 40246fa0 Agata Murawska
  map buildNdParamField allNDParamFields ++
83 40246fa0 Agata Murawska
  timeStampFields ++
84 40246fa0 Agata Murawska
  uuidFields "Group" ++
85 40246fa0 Agata Murawska
  serialFields "Group" ++
86 40246fa0 Agata Murawska
  tagsFields
87 40246fa0 Agata Murawska
88 40246fa0 Agata Murawska
-- | The group fields map.
89 40246fa0 Agata Murawska
groupFieldsMap :: FieldMap NodeGroup GroupRuntime
90 f94a9680 Iustin Pop
groupFieldsMap =
91 f94a9680 Iustin Pop
  Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) groupFields