root / src / Ganeti / Query / Group.hs @ 3add7574
History | View | Annotate | Download (3.4 kB)
1 |
{-| Implementation of the Ganeti Query2 node group queries. |
---|---|
2 |
|
3 |
-} |
4 |
|
5 |
{- |
6 |
|
7 |
Copyright (C) 2012 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 |
( GroupRuntime(..) |
28 |
, groupFieldsMap |
29 |
) where |
30 |
|
31 |
import qualified Data.Map as Map |
32 |
|
33 |
import Ganeti.Config |
34 |
import Ganeti.Objects |
35 |
import Ganeti.Query.Language |
36 |
import Ganeti.Query.Common |
37 |
import Ganeti.Query.Types |
38 |
|
39 |
-- | There is no runtime. |
40 |
data GroupRuntime = GroupRuntime |
41 |
|
42 |
groupFields :: FieldList NodeGroup GroupRuntime |
43 |
groupFields = |
44 |
[ (FieldDefinition "alloc_policy" "AllocPolicy" QFTText |
45 |
"Allocation policy for group", |
46 |
FieldSimple (rsNormal . groupAllocPolicy), QffNormal) |
47 |
, (FieldDefinition "custom_diskparams" "CustomDiskParameters" QFTOther |
48 |
"Custom disk parameters", |
49 |
FieldSimple (rsNormal . groupDiskparams), QffNormal) |
50 |
, (FieldDefinition "custom_ipolicy" "CustomInstancePolicy" QFTOther |
51 |
"Custom instance policy limitations", |
52 |
FieldSimple (rsNormal . groupIpolicy), QffNormal) |
53 |
, (FieldDefinition "custom_ndparams" "CustomNDParams" QFTOther |
54 |
"Custom node parameters", |
55 |
FieldSimple (rsNormal . groupNdparams), QffNormal) |
56 |
, (FieldDefinition "diskparams" "DiskParameters" QFTOther |
57 |
"Disk parameters (merged)", |
58 |
FieldConfig (\cfg -> rsNormal . getGroupDiskParams cfg), QffNormal) |
59 |
, (FieldDefinition "ipolicy" "InstancePolicy" QFTOther |
60 |
"Instance policy limitations (merged)", |
61 |
FieldConfig (\cfg ng -> rsNormal (getGroupIpolicy cfg ng)), QffNormal) |
62 |
, (FieldDefinition "name" "Group" QFTText "Group name", |
63 |
FieldSimple (rsNormal . groupName), QffNormal) |
64 |
, (FieldDefinition "ndparams" "NDParams" QFTOther "Node parameters", |
65 |
FieldConfig (\cfg ng -> rsNormal (getGroupNdParams cfg ng)), QffNormal) |
66 |
, (FieldDefinition "node_cnt" "Nodes" QFTNumber "Number of nodes", |
67 |
FieldConfig (\cfg -> rsNormal . length . getGroupNodes cfg . groupName), |
68 |
QffNormal) |
69 |
, (FieldDefinition "node_list" "NodeList" QFTOther "List of nodes", |
70 |
FieldConfig (\cfg -> rsNormal . map nodeName . |
71 |
getGroupNodes cfg . groupName), QffNormal) |
72 |
, (FieldDefinition "pinst_cnt" "Instances" QFTNumber |
73 |
"Number of primary instances", |
74 |
FieldConfig |
75 |
(\cfg -> rsNormal . length . fst . getGroupInstances cfg . groupName), |
76 |
QffNormal) |
77 |
, (FieldDefinition "pinst_list" "InstanceList" QFTOther |
78 |
"List of primary instances", |
79 |
FieldConfig (\cfg -> rsNormal . map instName . fst . |
80 |
getGroupInstances cfg . groupName), QffNormal) |
81 |
] ++ |
82 |
map buildNdParamField allNDParamFields ++ |
83 |
timeStampFields ++ |
84 |
uuidFields "Group" ++ |
85 |
serialFields "Group" ++ |
86 |
tagsFields |
87 |
|
88 |
-- | The group fields map. |
89 |
groupFieldsMap :: FieldMap NodeGroup GroupRuntime |
90 |
groupFieldsMap = |
91 |
Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) groupFields |