Revision f94a9680 htools/Ganeti/Query/Node.hs

b/htools/Ganeti/Query/Node.hs
105 105
                     -> FieldData Node NodeRuntime
106 106
nodeLiveFieldBuilder (fname, ftitle, ftype, _, fdoc) =
107 107
  ( FieldDefinition fname ftitle ftype fdoc
108
  , FieldRuntime $ nodeLiveRpcCall fname)
108
  , FieldRuntime $ nodeLiveRpcCall fname
109
  , QffNormal)
109 110

  
110 111
-- | The docstring for the node role. Note that we use 'reverse in
111 112
-- order to keep the same order as Python.
......
130 131
nodeFields :: FieldList Node NodeRuntime
131 132
nodeFields =
132 133
  [ (FieldDefinition "drained" "Drained" QFTBool "Whether node is drained",
133
     FieldSimple (rsNormal . nodeDrained))
134
     FieldSimple (rsNormal . nodeDrained), QffNormal)
134 135
  , (FieldDefinition "master_candidate" "MasterC" QFTBool
135 136
       "Whether node is a master candidate",
136
     FieldSimple (rsNormal . nodeMasterCandidate))
137
     FieldSimple (rsNormal . nodeMasterCandidate), QffNormal)
137 138
  , (FieldDefinition "master_capable" "MasterCapable" QFTBool
138 139
       "Whether node can become a master candidate",
139
     FieldSimple (rsNormal . nodeMasterCapable))
140
     FieldSimple (rsNormal . nodeMasterCapable), QffNormal)
140 141
  , (FieldDefinition "name" "Node" QFTText "Node name",
141
     FieldSimple (rsNormal . nodeName))
142
     FieldSimple (rsNormal . nodeName), QffNormal)
142 143
  , (FieldDefinition "offline" "Offline" QFTBool
143 144
       "Whether node is marked offline",
144
     FieldSimple (rsNormal . nodeOffline))
145
     FieldSimple (rsNormal . nodeOffline), QffNormal)
145 146
  , (FieldDefinition "vm_capable" "VMCapable" QFTBool
146 147
       "Whether node can host instances",
147
     FieldSimple (rsNormal . nodeVmCapable))
148
     FieldSimple (rsNormal . nodeVmCapable), QffNormal)
148 149
  , (FieldDefinition "pip" "PrimaryIP" QFTText "Primary IP address",
149
     FieldSimple (rsNormal . nodePrimaryIp))
150
     FieldSimple (rsNormal . nodePrimaryIp), QffNormal)
150 151
  , (FieldDefinition "sip" "SecondaryIP" QFTText "Secondary IP address",
151
     FieldSimple (rsNormal . nodeSecondaryIp))
152
     FieldSimple (rsNormal . nodeSecondaryIp), QffNormal)
152 153
  , (FieldDefinition "master" "IsMaster" QFTBool "Whether node is master",
153 154
     FieldConfig (\cfg node ->
154 155
                    rsNormal (nodeName node ==
155
                              clusterMasterNode (configCluster cfg))))
156
                              clusterMasterNode (configCluster cfg))),
157
     QffNormal)
156 158
  , (FieldDefinition "group" "Group" QFTText "Node group",
157 159
     FieldConfig (\cfg node ->
158
                    rsMaybe (groupName <$> getGroupOfNode cfg node)))
160
                    rsMaybe (groupName <$> getGroupOfNode cfg node)),
161
     QffNormal)
159 162
  , (FieldDefinition "group.uuid" "GroupUUID" QFTText "UUID of node group",
160
     FieldSimple (rsNormal . nodeGroup))
163
     FieldSimple (rsNormal . nodeGroup), QffNormal)
161 164
  ,  (FieldDefinition "ndparams" "NodeParameters" QFTOther
162 165
        "Merged node parameters",
163
      FieldConfig ((rsMaybe .) . getNodeNdParams))
166
      FieldConfig ((rsMaybe .) . getNodeNdParams), QffNormal)
164 167
  , (FieldDefinition "custom_ndparams" "CustomNodeParameters" QFTOther
165 168
                       "Custom node parameters",
166
     FieldSimple (rsNormal . nodeNdparams))
169
     FieldSimple (rsNormal . nodeNdparams), QffNormal)
167 170
  -- FIXME: the below could be generalised a bit, like in Python
168 171
  , (FieldDefinition "pinst_cnt" "Pinst" QFTNumber
169 172
       "Number of instances with this node as primary",
170 173
     FieldConfig (\cfg ->
171
                    rsNormal . length . fst . getNodeInstances cfg . nodeName))
174
                    rsNormal . length . fst . getNodeInstances cfg . nodeName),
175
     QffNormal)
172 176
  , (FieldDefinition "sinst_cnt" "Sinst" QFTNumber
173 177
       "Number of instances with this node as secondary",
174 178
     FieldConfig (\cfg ->
175
                    rsNormal . length . snd . getNodeInstances cfg . nodeName))
179
                    rsNormal . length . snd . getNodeInstances cfg . nodeName),
180
     QffNormal)
176 181
  , (FieldDefinition "pinst_list" "PriInstances" QFTOther
177 182
       "List of instances with this node as primary",
178 183
     FieldConfig (\cfg -> rsNormal . map instName . fst .
179
                          getNodeInstances cfg . nodeName))
184
                          getNodeInstances cfg . nodeName), QffNormal)
180 185
  , (FieldDefinition "sinst_list" "SecInstances" QFTOther
181 186
       "List of instances with this node as secondary",
182 187
     FieldConfig (\cfg -> rsNormal . map instName . snd .
183
                          getNodeInstances cfg . nodeName))
188
                          getNodeInstances cfg . nodeName), QffNormal)
184 189
  , (FieldDefinition "role" "Role" QFTText nodeRoleDoc,
185
     FieldConfig ((rsNormal .) . getNodeRole))
190
     FieldConfig ((rsNormal .) . getNodeRole), QffNormal)
186 191
  , (FieldDefinition "powered" "Powered" QFTBool
187 192
       "Whether node is thought to be powered on",
188
     FieldConfig getNodePower)
193
     FieldConfig getNodePower, QffNormal)
189 194
  -- FIXME: the two fields below are incomplete in Python, part of the
190 195
  -- non-implemented node resource model; they are declared just for
191 196
  -- parity, but are not functional
192 197
  , (FieldDefinition "hv_state" "HypervisorState" QFTOther "Hypervisor state",
193
     missingRuntime)
198
     missingRuntime, QffNormal)
194 199
  , (FieldDefinition "disk_state" "DiskState" QFTOther "Disk state",
195
     missingRuntime)
200
     missingRuntime, QffNormal)
196 201
  ] ++
197 202
  map nodeLiveFieldBuilder nodeLiveFieldsDefs ++
198 203
  map buildNdParamField allNDParamFields ++
......
203 208

  
204 209
-- | The node fields map.
205 210
nodeFieldsMap :: FieldMap Node NodeRuntime
206
nodeFieldsMap = Map.fromList $ map (\v -> (fdefName (fst v), v)) nodeFields
211
nodeFieldsMap =
212
  Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) nodeFields

Also available in: Unified diff