Revision 030ab01a

b/lib/cmdlib/instance_storage.py
891 891
  es_flags = rpc.GetExclusiveStorageForNodeNames(lu.cfg, nodenames)
892 892
  # FIXME: This maps everything to storage type 'lvm-vg' to maintain
893 893
  # the current functionality. Refactor to make it more flexible.
894
  nodeinfo = lu.rpc.call_node_info(nodenames, [(constants.ST_LVM_VG, vg)], None,
895
                                   es_flags)
894
  hvname = lu.cfg.GetHypervisorType()
895
  hvparams = lu.cfg.GetClusterInfo().hvparams
896
  nodeinfo = lu.rpc.call_node_info(nodenames, [(constants.ST_LVM_VG, vg)],
897
                                   [(hvname, hvparams[hvname])], es_flags)
896 898
  for node in nodenames:
897 899
    info = nodeinfo[node]
898 900
    info.Raise("Cannot get current information from node %s" % node,
b/lib/rpc_defs.py
468 468
    ("storage_units", None,
469 469
     "List of tuples '<storage_type>,<key>' to ask for disk space"
470 470
     " information"),
471
    ("hv_names", None,
472
     "Names of the hypervisors to ask for node information"),
471
    ("hv_specs", None,
472
     "List of hypervisor specification (name, hvparams) to ask for node "
473
     "information"),
473 474
    ("exclusive_storage", None,
474 475
     "Whether exclusive storage is enabled"),
475 476
    ], _NodeInfoPreProc, None, "Return node information"),
b/lib/server/noded.py
721 721
    """Query node information.
722 722

  
723 723
    """
724
    (storage_units, hv_names, excl_stor) = params
725
    return backend.GetNodeInfo(storage_units, hv_names, excl_stor)
724
    (storage_units, hv_specs, excl_stor) = params
725
    return backend.GetNodeInfo(storage_units, hv_specs, excl_stor)
726 726

  
727 727
  @staticmethod
728 728
  def perspective_etc_hosts_modify(params):
b/src/Ganeti/Query/Node.hs
39 39
import Ganeti.Objects
40 40
import Ganeti.JSON
41 41
import Ganeti.Rpc
42
import Ganeti.Types
42 43
import Ganeti.Query.Language
43 44
import Ganeti.Query.Common
44 45
import Ganeti.Query.Types
......
236 237
      -- FIXME: This currently sets every storage unit to LVM
237 238
      storage_units = zip (repeat T.StorageLvmVg) vgs ++
238 239
                      zip (repeat T.StorageLvmPv) vgs
239
      hvs = [getDefaultHypervisor cfg]
240
      hvs = [getDefaultHypervisorSpec cfg]
240 241
      step n (bn, gn, em) =
241 242
        let ndp' = getNodeNdParams cfg n
242 243
        in case ndp' of
......
249 250
  -- FIXME: The order of nodes in the result could be different from the input
250 251
  return $ zip bnodes (repeat $ Left (RpcResultError "Broken configuration"))
251 252
           ++ rpcres
253

  
254
-- | Looks up the default hypervisor and it's hvparams
255
getDefaultHypervisorSpec :: ConfigData -> (Hypervisor, HvParams)
256
getDefaultHypervisorSpec cfg = (hv, getHvParamsFromCluster cfg hv)
257
  where hv = getDefaultHypervisor cfg
258

  
259
-- | Looks up the cluster's hvparams of the given hypervisor
260
getHvParamsFromCluster :: ConfigData -> Hypervisor -> HvParams
261
getHvParamsFromCluster cfg hv =
262
  fromMaybe (GenericContainer (Map.fromList []))
263
    (Map.lookup (show hv)
264
       (fromContainer (clusterHvparams (configCluster cfg))))
b/src/Ganeti/Rpc.hs
337 337
-- | NodeInfo
338 338
-- Return node information.
339 339
$(buildObject "RpcCallNodeInfo" "rpcCallNodeInfo"
340
  [ simpleField "storage_units" [t| [ (StorageType,String) ] |]
341
  , simpleField "hypervisors" [t| [Hypervisor] |]
340
  [ simpleField "storage_units" [t| [ (StorageType, String) ] |]
341
  , simpleField "hypervisors" [t| [ (Hypervisor, HvParams) ] |]
342 342
  , simpleField "exclusive_storage" [t| Map.Map String Bool |]
343 343
  ])
344 344

  
b/test/hs/Test/Ganeti/Rpc.hs
40 40

  
41 41
import qualified Ganeti.Rpc as Rpc
42 42
import qualified Ganeti.Objects as Objects
43
import qualified Ganeti.Types as Types
44
import qualified Ganeti.JSON as JSON
43 45

  
44 46
instance Arbitrary Rpc.RpcCallAllInstancesInfo where
45 47
  arbitrary = Rpc.RpcCallAllInstancesInfo <$> arbitrary
......
48 50
  arbitrary = Rpc.RpcCallInstanceList <$> arbitrary
49 51

  
50 52
instance Arbitrary Rpc.RpcCallNodeInfo where
51
  arbitrary = Rpc.RpcCallNodeInfo <$> arbitrary <*> arbitrary <*>
53
  arbitrary = Rpc.RpcCallNodeInfo <$> arbitrary <*> genHvSpecs <*>
52 54
                pure Map.empty
53 55

  
56
-- | Generate hypervisor specifications to be used for the NodeInfo call
57
genHvSpecs :: Gen [ (Types.Hypervisor, Objects.HvParams) ]
58
genHvSpecs = do
59
  numhv <- choose (0, 5)
60
  hvs <- vectorOf numhv arbitrary
61
  hvparams <- vectorOf numhv genHvParams
62
  let specs = zip hvs hvparams
63
  return specs
64

  
65
-- FIXME: Generate more interesting hvparams
66
-- | Generate Hvparams
67
genHvParams :: Gen Objects.HvParams
68
genHvParams = return $ JSON.GenericContainer Map.empty
69

  
54 70
-- | Monadic check that, for an offline node and a call that does not
55 71
-- offline nodes, we get a OfflineNodeError response.
56 72
-- FIXME: We need a way of generalizing this, running it for

Also available in: Unified diff