Revision c66d8987 lib/objects.py

b/lib/objects.py
463 463
      self.networks = {}
464 464
    for network in self.networks.values():
465 465
      network.UpgradeConfig()
466
    self._UpgradeStorageTypes()
467

  
468
  def _UpgradeStorageTypes(self):
469
    """Upgrade the cluster's enabled storage types by inspecting the currently
470
       enabled and/or used storage types.
471

  
472
    """
473
    # enabled_storage_types in the cluster config were introduced in 2.8. Remove
474
    # this code once upgrading from earlier versions is deprecated.
475
    if not self.cluster.enabled_storage_types:
476
      storage_type_set = \
477
        set([constants.DISK_TEMPLATES_STORAGE_TYPE[inst.disk_template]
478
               for inst in self.instances.values()])
479
      # Add lvm, file and shared file storage, if they are enabled, even though
480
      # they might currently not be used.
481
      if self.cluster.volume_group_name:
482
        storage_type_set.add(constants.ST_LVM_VG)
483
      # FIXME: Adapt this when dis/enabling at configure time is removed.
484
      if constants.ENABLE_FILE_STORAGE:
485
        storage_type_set.add(constants.ST_FILE)
486
      if constants.ENABLE_SHARED_FILE_STORAGE:
487
        storage_type_set.add(constants.ST_SHARED_FILE)
488
      # Set enabled_storage_types to the inferred storage types. Order them
489
      # according to a preference list that is based on Ganeti's history of
490
      # supported storage types.
491
      self.cluster.enabled_storage_types = []
492
      for preferred_type in constants.STORAGE_TYPES_PREFERENCE:
493
        if preferred_type in storage_type_set:
494
          self.cluster.enabled_storage_types.append(preferred_type)
495
          storage_type_set.remove(preferred_type)
496
      self.cluster.enabled_storage_types.extend(list(storage_type_set))
466 497

  
467 498

  
468 499
class NIC(ConfigObject):

Also available in: Unified diff