Revision 51cb1581 lib/objects.py

b/lib/objects.py
340 340
    obj.instances = cls._ContainerFromDicts(obj.instances, dict, Instance)
341 341
    return obj
342 342

  
343
  def HasAnyDiskOfType(self, dev_type):
344
    """Check if in there is at disk of the given type in the configuration.
345

  
346
    @type dev_type: L{constants.LDS_BLOCK}
347
    @param dev_type: the type to look for
348
    @rtype: boolean
349
    @return: boolean indicating if a disk of the given type was found or not
350

  
351
    """
352
    for instance in self.instances.values():
353
      for disk in instance.disks:
354
        if disk.IsBasedOnDiskType(dev_type):
355
          return True
356
    return False
357

  
343 358
  def UpgradeConfig(self):
344 359
    """Fill defaults for missing configuration values.
345 360

  
......
437 452
      return 0
438 453
    return -1
439 454

  
455
  def IsBasedOnDiskType(self, dev_type):
456
    """Check if the disk or its children are based on the given type.
457

  
458
    @type dev_type: L{constants.LDS_BLOCK}
459
    @param dev_type: the type to look for
460
    @rtype: boolean
461
    @return: boolean indicating if a device of the given type was found or not
462

  
463
    """
464
    if self.children:
465
      for child in self.children:
466
        if child.IsBasedOnDiskType(dev_type):
467
          return True
468
    return self.dev_type == dev_type
469

  
440 470
  def GetNodes(self, node):
441 471
    """This function returns the nodes this device lives on.
442 472

  

Also available in: Unified diff