Revision 82c54b5b lib/config.py

b/lib/config.py
133 133
  return utils.MatchNameComponent(short_name, names, case_sensitive=False)
134 134

  
135 135

  
136
def _CheckInstanceDiskIvNames(disks):
137
  """Checks if instance's disks' C{iv_name} attributes are in order.
138

  
139
  @type disks: list of L{objects.Disk}
140
  @param disks: List of disks
141
  @rtype: list of tuples; (int, string, string)
142
  @return: List of wrongly named disks, each tuple contains disk index,
143
    expected and actual name
144

  
145
  """
146
  result = []
147

  
148
  for (idx, disk) in enumerate(disks):
149
    exp_iv_name = "disk/%s" % idx
150
    if disk.iv_name != exp_iv_name:
151
      result.append((idx, exp_iv_name, disk.iv_name))
152

  
153
  return result
154

  
155

  
136 156
class ConfigWriter:
137 157
  """The interface to the cluster configuration.
138 158

  
......
510 530
                       (instance.name, idx, msg) for msg in disk.Verify()])
511 531
        result.extend(self._CheckDiskIDs(disk, seen_lids, seen_pids))
512 532

  
533
      wrong_names = _CheckInstanceDiskIvNames(instance.disks)
534
      if wrong_names:
535
        tmp = "; ".join(("name of disk %s should be '%s', but is '%s'" %
536
                         (idx, exp_name, actual_name))
537
                        for (idx, exp_name, actual_name) in wrong_names)
538

  
539
        result.append("Instance '%s' has wrongly named disks: %s" %
540
                      (instance.name, tmp))
541

  
513 542
    # cluster-wide pool of free ports
514 543
    for free_port in cluster.tcpudp_port_pool:
515 544
      if free_port not in ports:

Also available in: Unified diff