Revision da803ff1

b/lib/cmdlib/instance.py
2029 2029
      or we cannot check the node
2030 2030

  
2031 2031
  """
2032
  nodeinfo = lu.rpc.call_node_info(node_uuids, None, hypervisor_specs, None)
2032
  nodeinfo = lu.rpc.call_node_info(node_uuids, None, hypervisor_specs)
2033 2033
  for node_uuid in node_uuids:
2034 2034
    info = nodeinfo[node_uuid]
2035 2035
    node_name = lu.cfg.GetNodeName(node_uuid)
......
2859 2859
      hvspecs = [(self.instance.hypervisor,
2860 2860
                  self.cluster.hvparams[self.instance.hypervisor])]
2861 2861
      nodeinfo = self.rpc.call_node_info(mem_check_list, None,
2862
                                         hvspecs, False)
2862
                                         hvspecs)
2863 2863
      pninfo = nodeinfo[pnode_uuid]
2864 2864
      msg = pninfo.fail_msg
2865 2865
      if msg:
b/lib/cmdlib/instance_migration.py
660 660
    hvspecs = [(self.instance.hypervisor,
661 661
                self.cfg.GetClusterInfo().hvparams[self.instance.hypervisor])]
662 662
    nodeinfo = self.rpc.call_node_info(
663
                 [self.source_node_uuid, self.target_node_uuid], None, hvspecs,
664
                 False)
663
                 [self.source_node_uuid, self.target_node_uuid], None, hvspecs)
665 664
    for ninfo in nodeinfo.values():
666 665
      ninfo.Raise("Unable to retrieve node information from node '%s'" %
667 666
                  ninfo.node)
b/lib/cmdlib/instance_storage.py
892 892
      or we cannot check the node
893 893

  
894 894
  """
895
  es_flags = rpc.GetExclusiveStorageForNodes(lu.cfg, node_uuids)
895
  lvm_storage_units = [(constants.ST_LVM_VG, vg)]
896
  storage_units = rpc.PrepareStorageUnitsForNodes(lu.cfg, lvm_storage_units,
897
                                                  node_uuids)
896 898
  hvname = lu.cfg.GetHypervisorType()
897 899
  hvparams = lu.cfg.GetClusterInfo().hvparams
898
  nodeinfo = lu.rpc.call_node_info(node_uuids, [(constants.ST_LVM_VG, vg)],
899
                                   [(hvname, hvparams[hvname])], es_flags)
900
  nodeinfo = lu.rpc.call_node_info(node_uuids, storage_units,
901
                                   [(hvname, hvparams[hvname])])
900 902
  for node in node_uuids:
901 903
    node_name = lu.cfg.GetNodeName(node)
902 904

  
b/lib/cmdlib/instance_utils.py
483 483

  
484 484
  """
485 485
  node_name = lu.cfg.GetNodeName(node_uuid)
486
  nodeinfo = lu.rpc.call_node_info([node_uuid], None, [(hvname, hvparams)],
487
                                   False)
486
  nodeinfo = lu.rpc.call_node_info([node_uuid], None, [(hvname, hvparams)])
488 487
  nodeinfo[node_uuid].Raise("Can't get data from node %s" % node_name,
489 488
                            prereq=True, ecode=errors.ECODE_ENVIRON)
490 489
  (_, _, (hv_info, )) = nodeinfo[node_uuid].payload
b/lib/cmdlib/node.py
1183 1183
      # filter out non-vm_capable nodes
1184 1184
      toquery_node_uuids = [node.uuid for node in all_info.values()
1185 1185
                            if node.vm_capable and node.uuid in node_uuids]
1186

  
1187
      es_flags = rpc.GetExclusiveStorageForNodes(lu.cfg, toquery_node_uuids)
1188
      # FIXME: This currently maps everything to lvm, this should be more
1189
      # flexible
1186
      # FIXME: this per default asks for storage space information for all
1187
      # enabled disk templates. Fix this by making it possible to specify
1188
      # space report fields for specific disk templates.
1189
      raw_storage_units = utils.storage.GetStorageUnitsOfCluster(
1190
          lu.cfg, include_spindles=True)
1191
      storage_units = rpc.PrepareStorageUnitsForNodes(
1192
          lu.cfg, raw_storage_units, toquery_node_uuids)
1190 1193
      lvm_enabled = utils.storage.IsLvmEnabled(
1191 1194
          lu.cfg.GetClusterInfo().enabled_disk_templates)
1192
      storage_units = utils.storage.GetStorageUnitsOfCluster(
1193
          lu.cfg, include_spindles=True)
1194 1195
      default_hypervisor = lu.cfg.GetHypervisorType()
1195 1196
      hvparams = lu.cfg.GetClusterInfo().hvparams[default_hypervisor]
1196 1197
      hvspecs = [(default_hypervisor, hvparams)]
1197 1198
      node_data = lu.rpc.call_node_info(toquery_node_uuids, storage_units,
1198
                                        hvspecs, es_flags)
1199
                                        hvspecs)
1199 1200
      live_data = dict(
1200 1201
          (uuid, rpc.MakeLegacyNodeInfo(nresult.payload,
1201 1202
                                        require_vg_info=lvm_enabled))
b/lib/masterd/iallocator.py
413 413
    @return: the result of the node info RPC call
414 414

  
415 415
    """
416
    es_flags = rpc.GetExclusiveStorageForNodes(self.cfg, node_list)
417
    storage_units = utils.storage.GetStorageUnitsOfCluster(
416
    storage_units_raw = utils.storage.GetStorageUnitsOfCluster(
418 417
        self.cfg, include_spindles=True)
418
    storage_units = rpc.PrepareStorageUnitsForNodes(self.cfg, storage_units_raw,
419
                                                    node_list)
419 420
    hvspecs = [(hypervisor_name, cluster_info.hvparams[hypervisor_name])]
420
    return self.rpc.call_node_info(node_list, storage_units, hvspecs, es_flags)
421
    return self.rpc.call_node_info(node_list, storage_units, hvspecs)
421 422

  
422 423
  def _ComputeClusterData(self):
423 424
    """Compute the generic allocator input data.
b/lib/rpc.py
718 718
  return [annotation_fn(disk.Copy(), ld_params) for disk in disks]
719 719

  
720 720

  
721
def _GetESFlag(cfg, node_uuid):
721
def _GetExclusiveStorageFlag(cfg, node_uuid):
722 722
  ni = cfg.GetNodeInfo(node_uuid)
723 723
  if ni is None:
724 724
    raise errors.OpPrereqError("Invalid node name %s" % node_uuid,
......
726 726
  return cfg.GetNdParams(ni)[constants.ND_EXCLUSIVE_STORAGE]
727 727

  
728 728

  
729
def _AddExclusiveStorageFlagToLvmStorageUnits(storage_units, es_flag):
730
  """Adds the exclusive storage flag to lvm units.
731

  
732
  This function creates a copy of the storage_units lists, with the
733
  es_flag being added to all lvm storage units.
734

  
735
  @type storage_units: list of pairs (string, string)
736
  @param storage_units: list of 'raw' storage units, consisting only of
737
    (storage_type, storage_key)
738
  @type es_flag: boolean
739
  @param es_flag: exclusive storage flag
740
  @rtype: list of tuples (string, string, list)
741
  @return: list of storage units (storage_type, storage_key, params) with
742
    the params containing the es_flag for lvm-vg storage units
743

  
744
  """
745
  result = []
746
  for (storage_type, storage_key) in storage_units:
747
    if storage_type == constants.ST_LVM_VG:
748
      result.append((storage_type, storage_key, es_flag))
749
    else:
750
      result.append((storage_type, storage_key, []))
751
  return result
752

  
753

  
729 754
def GetExclusiveStorageForNodes(cfg, node_uuids):
730 755
  """Return the exclusive storage flag for all the given nodes.
731 756

  
......
734 759
  @type node_uuids: list or tuple
735 760
  @param node_uuids: node UUIDs for which to read the flag
736 761
  @rtype: dict
737
  @return: mapping from node names to exclusive storage flags
762
  @return: mapping from node uuids to exclusive storage flags
738 763
  @raise errors.OpPrereqError: if any given node name has no corresponding
739 764
  node
740 765

  
741 766
  """
742
  getflag = lambda n: _GetESFlag(cfg, n)
767
  getflag = lambda n: _GetExclusiveStorageFlag(cfg, n)
743 768
  flags = map(getflag, node_uuids)
744 769
  return dict(zip(node_uuids, flags))
745 770

  
746 771

  
772
def PrepareStorageUnitsForNodes(cfg, storage_units, node_uuids):
773
  """Return the lvm storage unit for all the given nodes.
774

  
775
  Main purpose of this function is to map the exclusive storage flag, which
776
  can be different for each node, to the default LVM storage unit.
777

  
778
  @type cfg: L{config.ConfigWriter}
779
  @param cfg: cluster configuration
780
  @type storage_units: list of pairs (string, string)
781
  @param storage_units: list of 'raw' storage units, e.g. pairs of
782
    (storage_type, storage_key)
783
  @type node_uuids: list or tuple
784
  @param node_uuids: node UUIDs for which to read the flag
785
  @rtype: dict
786
  @return: mapping from node uuids to a list of storage units which include
787
    the exclusive storage flag for lvm storage
788
  @raise errors.OpPrereqError: if any given node name has no corresponding
789
  node
790

  
791
  """
792
  getunit = lambda n: _AddExclusiveStorageFlagToLvmStorageUnits(
793
      storage_units, _GetExclusiveStorageFlag(cfg, n))
794
  flags = map(getunit, node_uuids)
795
  return dict(zip(node_uuids, flags))
796

  
797

  
747 798
#: Generic encoders
748 799
_ENCODERS = {
749 800
  rpc_defs.ED_OBJECT_DICT: _ObjectToDict,
b/lib/rpc_defs.py
132 132

  
133 133

  
134 134
def _NodeInfoPreProc(node, args):
135
  """Prepare the exclusive_storage argument for node_info calls."""
136
  assert len(args) == 3
137
  # The third argument is either a dictionary with one value for each node, or
138
  # a fixed value to be used for all the nodes
139
  if type(args[2]) is dict:
140
    return [args[0], args[1], args[2][node]]
135
  """Prepare the storage_units argument for node_info calls."""
136
  assert len(args) == 2
137
  # The storage_units argument is either a dictionary with one value for each
138
  # node, or a fixed value to be used for all the nodes
139
  if type(args[0]) is dict:
140
    return [args[0][node], args[1]]
141 141
  else:
142 142
    return args
143 143

  
......
476 476
    ], None, None, "Checks if a node has the given IP address"),
477 477
  ("node_info", MULTI, None, constants.RPC_TMO_URGENT, [
478 478
    ("storage_units", None,
479
     "List of tuples '<storage_type>,<key>' to ask for disk space"
480
     " information"),
479
     "List of tuples '<storage_type>,<key>,[<param>]' to ask for disk space"
480
     " information; the parameter list varies depending on the storage_type"),
481 481
    ("hv_specs", None,
482 482
     "List of hypervisor specification (name, hvparams) to ask for node "
483 483
     "information"),
484
    ("exclusive_storage", None,
485
     "Whether exclusive storage is enabled"),
486 484
    ], _NodeInfoPreProc, None, "Return node information"),
487 485
  ("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [
488 486
    ("checkdict", None, "What to verify"),

Also available in: Unified diff