Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Query / Group.hs @ c92b4671

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 Ganeti.Config
30
import Ganeti.Objects
31
import Ganeti.Query.Language
32
import Ganeti.Query.Common
33
import Ganeti.Query.Types
34
import Ganeti.Utils (niceSort)
35

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

    
82
-- | The group fields map.
83
fieldsMap :: FieldMap NodeGroup NoDataRuntime
84
fieldsMap = fieldListToFieldMap groupFields