Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Query / Group.hs @ 1de58759

History | View | Annotate | Download (3.3 kB)

1
{-| Implementation of the Ganeti Query2 node group queries.
2

    
3
 -}
4

    
5
{-
6

    
7
Copyright (C) 2012, 2013 Google Inc.
8

    
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
13

    
14
This program is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
General Public License for more details.
18

    
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
02110-1301, USA.
23

    
24
-}
25

    
26
module Ganeti.Query.Group
27
  (fieldsMap) where
28

    
29
import qualified Data.Map as Map
30

    
31
import Ganeti.Config
32
import Ganeti.Objects
33
import Ganeti.Query.Language
34
import Ganeti.Query.Common
35
import Ganeti.Query.Types
36
import Ganeti.Utils (niceSort)
37

    
38
groupFields :: FieldList NodeGroup NoDataRuntime
39
groupFields =
40
  [ (FieldDefinition "alloc_policy" "AllocPolicy" QFTText
41
       "Allocation policy for group",
42
     FieldSimple (rsNormal . groupAllocPolicy), QffNormal)
43
  , (FieldDefinition "custom_diskparams" "CustomDiskParameters" QFTOther
44
       "Custom disk parameters",
45
     FieldSimple (rsNormal . groupDiskparams), QffNormal)
46
  , (FieldDefinition "custom_ipolicy" "CustomInstancePolicy" QFTOther
47
       "Custom instance policy limitations",
48
     FieldSimple (rsNormal . groupIpolicy), QffNormal)
49
  , (FieldDefinition "custom_ndparams" "CustomNDParams" QFTOther
50
       "Custom node parameters",
51
     FieldSimple (rsNormal . groupNdparams), QffNormal)
52
  , (FieldDefinition "diskparams" "DiskParameters" QFTOther
53
       "Disk parameters (merged)",
54
     FieldConfig (\cfg -> rsNormal . getGroupDiskParams cfg), QffNormal)
55
  , (FieldDefinition "ipolicy" "InstancePolicy" QFTOther
56
       "Instance policy limitations (merged)",
57
     FieldConfig (\cfg ng -> rsNormal (getGroupIpolicy cfg ng)), QffNormal)
58
  , (FieldDefinition "name" "Group" QFTText "Group name",
59
     FieldSimple (rsNormal . groupName), QffNormal)
60
  , (FieldDefinition "ndparams" "NDParams" QFTOther "Node parameters",
61
     FieldConfig (\cfg ng -> rsNormal (getGroupNdParams cfg ng)), QffNormal)
62
  , (FieldDefinition "node_cnt" "Nodes" QFTNumber "Number of nodes",
63
     FieldConfig (\cfg -> rsNormal . length . getGroupNodes cfg . groupUuid),
64
     QffNormal)
65
  , (FieldDefinition "node_list" "NodeList" QFTOther "List of nodes",
66
     FieldConfig (\cfg -> rsNormal . map nodeName .
67
                          getGroupNodes cfg . groupUuid), QffNormal)
68
  , (FieldDefinition "pinst_cnt" "Instances" QFTNumber
69
       "Number of primary instances",
70
     FieldConfig
71
       (\cfg -> rsNormal . length . fst . getGroupInstances cfg . groupUuid),
72
     QffNormal)
73
  , (FieldDefinition "pinst_list" "InstanceList" QFTOther
74
       "List of primary instances",
75
     FieldConfig (\cfg -> rsNormal . niceSort . map instName . fst .
76
                          getGroupInstances cfg . groupUuid), QffNormal)
77
  ] ++
78
  map buildNdParamField allNDParamFields ++
79
  timeStampFields ++
80
  uuidFields "Group" ++
81
  serialFields "Group" ++
82
  tagsFields
83

    
84
-- | The group fields map.
85
fieldsMap :: FieldMap NodeGroup NoDataRuntime
86
fieldsMap =
87
  Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) groupFields