Revision 4e6f1cde src/Ganeti/Query/Instance.hs
b/src/Ganeti/Query/Instance.hs | ||
---|---|---|
39 | 39 |
import Ganeti.BasicTypes |
40 | 40 |
import Ganeti.Common |
41 | 41 |
import Ganeti.Config |
42 |
import qualified Ganeti.Constants as C |
|
43 |
import qualified Ganeti.ConstantUtils as C |
|
42 | 44 |
import Ganeti.Errors |
45 |
import Ganeti.JSON |
|
43 | 46 |
import Ganeti.Objects |
44 | 47 |
import Ganeti.Query.Common |
45 | 48 |
import Ganeti.Query.Language |
... | ... | |
106 | 109 |
FieldConfig (getSecondaryNodeGroupAttribute groupUuid), QffNormal) |
107 | 110 |
] ++ |
108 | 111 |
|
112 |
-- Instance parameter fields, whole |
|
113 |
[ (FieldDefinition "hvparams" "HypervisorParameters" QFTOther |
|
114 |
"Hypervisor parameters (merged)", |
|
115 |
FieldConfig ((rsNormal .) . getFilledInstHvParams), QffNormal) |
|
116 |
, (FieldDefinition "beparams" "BackendParameters" QFTOther |
|
117 |
"Backend parameters (merged)", |
|
118 |
FieldConfig ((rsErrorNoData .) . getFilledInstBeParams), QffNormal) |
|
119 |
, (FieldDefinition "osparams" "OpSysParameters" QFTOther |
|
120 |
"Operating system parameters (merged)", |
|
121 |
FieldConfig ((rsNormal .) . getFilledInstOsParams), QffNormal) |
|
122 |
, (FieldDefinition "custom_hvparams" "CustomHypervisorParameters" QFTOther |
|
123 |
"Custom hypervisor parameters", |
|
124 |
FieldSimple (rsNormal . instHvparams), QffNormal) |
|
125 |
, (FieldDefinition "custom_beparams" "CustomBackendParameters" QFTOther |
|
126 |
"Custom backend parameters", |
|
127 |
FieldSimple (rsNormal . instBeparams), QffNormal) |
|
128 |
, (FieldDefinition "custom_osparams" "CustomOpSysParameters" QFTOther |
|
129 |
"Custom operating system parameters", |
|
130 |
FieldSimple (rsNormal . instOsparams), QffNormal) |
|
131 |
] ++ |
|
132 |
|
|
133 |
-- Instance parameter fields, generated |
|
134 |
map (buildBeParamField beParamGetter) allBeParamFields ++ |
|
135 |
map (buildHvParamField hvParamGetter) (C.toList C.hvsParameters) ++ |
|
136 |
|
|
109 | 137 |
-- Live fields using special getters |
110 | 138 |
[ (FieldDefinition "status" "Status" QFTText |
111 | 139 |
statusDocText, |
... | ... | |
132 | 160 |
-- | Get primary node hostname |
133 | 161 |
getPrimaryNodeName :: ConfigData -> Instance -> ResultEntry |
134 | 162 |
getPrimaryNodeName cfg inst = |
135 |
rsErrorNoData $ (J.showJSON . nodeName) <$> getPrimaryNode cfg inst
|
|
163 |
rsErrorNoData $ nodeName <$> getPrimaryNode cfg inst
|
|
136 | 164 |
|
137 | 165 |
-- | Get primary node hostname |
138 | 166 |
getPrimaryNodeGroup :: ConfigData -> Instance -> ResultEntry |
... | ... | |
172 | 200 |
getSecondaryNodeGroupAttribute getter cfg inst = |
173 | 201 |
rsErrorNoData $ map (J.showJSON . getter) <$> getSecondaryNodeGroups cfg inst |
174 | 202 |
|
203 |
-- | Beparam getter builder: given a field, it returns a FieldConfig |
|
204 |
-- getter, that is a function that takes the config and the object and |
|
205 |
-- returns the Beparam field specified when the getter was built. |
|
206 |
beParamGetter :: String -- ^ The field we are building the getter for |
|
207 |
-> ConfigData -- ^ The configuration object |
|
208 |
-> Instance -- ^ The instance configuration object |
|
209 |
-> ResultEntry -- ^ The result |
|
210 |
beParamGetter field config inst = |
|
211 |
case getFilledInstBeParams config inst of |
|
212 |
Ok beParams -> dictFieldGetter field $ Just beParams |
|
213 |
Bad _ -> rsNoData |
|
214 |
|
|
215 |
-- | Hvparam getter builder: given a field, it returns a FieldConfig |
|
216 |
-- getter, that is a function that takes the config and the object and |
|
217 |
-- returns the Hvparam field specified when the getter was built. |
|
218 |
hvParamGetter :: String -- ^ The field we're building the getter for |
|
219 |
-> ConfigData -> Instance -> ResultEntry |
|
220 |
hvParamGetter field cfg inst = |
|
221 |
rsMaybeUnavail . Map.lookup field . fromContainer $ |
|
222 |
getFilledInstHvParams cfg inst |
|
223 |
|
|
175 | 224 |
-- * Live fields functionality |
176 | 225 |
|
177 | 226 |
-- | List of node live fields. |
Also available in: Unified diff