Revision 5b11f8db htools/Ganeti/Rpc.hs

b/htools/Ganeti/Rpc.hs
172 172
prepareUrl node call =
173 173
  let node_ip = nodePrimaryIp node
174 174
      port = snd C.daemonsPortsGanetiNoded
175
      path_prefix = "https://" ++ (node_ip) ++ ":" ++ (show port) in
176
  path_prefix ++ "/" ++ rpcCallName call
175
      path_prefix = "https://" ++ node_ip ++ ":" ++ show port
176
  in path_prefix ++ "/" ++ rpcCallName call
177 177

  
178 178
-- | Create HTTP request for a given node provided it is online,
179 179
-- otherwise create empty response.
180 180
prepareHttpRequest ::  (RpcCall a) => Node -> a
181 181
                   -> Either RpcError HttpClientRequest
182 182
prepareHttpRequest node call
183
  | rpcCallAcceptOffline call ||
184
    (not $ nodeOffline node) =
185
      Right $ HttpClientRequest { requestTimeout = rpcCallTimeout call
186
                                , requestUrl = prepareUrl node call
187
                                , requestPostData = rpcCallData node call
188
                                }
183
  | rpcCallAcceptOffline call || not (nodeOffline node) =
184
      Right HttpClientRequest { requestTimeout = rpcCallTimeout call
185
                              , requestUrl = prepareUrl node call
186
                              , requestPostData = rpcCallData node call
187
                              }
189 188
  | otherwise = Left $ OfflineNodeError node
190 189

  
191 190
-- | Parse the response or propagate the error.
......
212 211

  
213 212
-- | AllInstancesInfo
214 213
--   Returns information about all instances on the given nodes
215
$(buildObject "RpcCallAllInstancesInfo" "rpcCallAllInstInfo" $
214
$(buildObject "RpcCallAllInstancesInfo" "rpcCallAllInstInfo"
216 215
  [ simpleField "hypervisors" [t| [Hypervisor] |] ])
217 216

  
218
$(buildObject "InstanceInfo" "instInfo" $
217
$(buildObject "InstanceInfo" "instInfo"
219 218
  [ simpleField "name"   [t| String |]
220 219
  , simpleField "memory" [t| Int|]
221 220
  , simpleField "state"  [t| AdminState |]
......
223 222
  , simpleField "time"   [t| Int |]
224 223
  ])
225 224

  
226
$(buildObject "RpcResultAllInstancesInfo" "rpcResAllInstInfo" $
225
$(buildObject "RpcResultAllInstancesInfo" "rpcResAllInstInfo"
227 226
  [ simpleField "instances" [t| [InstanceInfo] |] ])
228 227

  
229 228
instance RpcCall RpcCallAllInstancesInfo where
......
237 236

  
238 237
-- | InstanceList
239 238
-- Returns the list of running instances on the given nodes.
240
$(buildObject "RpcCallInstanceList" "rpcCallInstList" $
239
$(buildObject "RpcCallInstanceList" "rpcCallInstList"
241 240
  [ simpleField "hypervisors" [t| [Hypervisor] |] ])
242 241

  
243
$(buildObject "RpcResultInstanceList" "rpcResInstList" $
242
$(buildObject "RpcResultInstanceList" "rpcResInstList"
244 243
  [ simpleField "node"      [t| Node |]
245 244
  , simpleField "instances" [t| [String] |]
246 245
  ])
......
256 255

  
257 256
-- | NodeInfo
258 257
-- Return node information.
259
$(buildObject "RpcCallNodeInfo" "rpcCallNodeInfo" $
258
$(buildObject "RpcCallNodeInfo" "rpcCallNodeInfo"
260 259
  [ simpleField "hypervisors" [t| [Hypervisor] |]
261 260
  , simpleField "volume_groups" [t| [String] |]
262 261
  ])
263 262

  
264
$(buildObject "VgInfo" "vgInfo" $
263
$(buildObject "VgInfo" "vgInfo"
265 264
  [ simpleField "name" [t| String |]
266 265
  , simpleField "free" [t| Int |]
267 266
  , simpleField "size" [t| Int |]
268 267
  ])
269 268

  
270 269
-- | We only provide common fields as described in hv_base.py.
271
$(buildObject "HvInfo" "hvInfo" $
270
$(buildObject "HvInfo" "hvInfo"
272 271
  [ simpleField "memory_total" [t| Int |]
273 272
  , simpleField "memory_free" [t| Int |]
274 273
  , simpleField "memory_dom0" [t| Int |]
......
277 276
  , simpleField "cpu_sockets" [t| Int |]
278 277
  ])
279 278

  
280
$(buildObject "RpcResultNodeInfo" "rpcResNodeInfo" $
279
$(buildObject "RpcResultNodeInfo" "rpcResNodeInfo"
281 280
  [ simpleField "boot_id" [t| String |]
282 281
  , simpleField "vg_info" [t| [VgInfo] |]
283 282
  , simpleField "hv_info" [t| [HvInfo] |]

Also available in: Unified diff