Revision 1b02d7ef lib/objects.py

b/lib/objects.py
477 477
      self.networks = {}
478 478
    for network in self.networks.values():
479 479
      network.UpgradeConfig()
480
    self._UpgradeStorageTypes()
480
    self._UpgradeEnabledDiskTemplates()
481 481

  
482
  def _UpgradeStorageTypes(self):
483
    """Upgrade the cluster's enabled storage types by inspecting the currently
484
       enabled and/or used storage types.
482
  def _UpgradeEnabledDiskTemplates(self):
483
    """Upgrade the cluster's enabled disk templates by inspecting the currently
484
       enabled and/or used disk templates.
485 485

  
486 486
    """
487
    # enabled_storage_types in the cluster config were introduced in 2.8. Remove
488
    # this code once upgrading from earlier versions is deprecated.
489
    if not self.cluster.enabled_storage_types:
490
      storage_type_set = \
491
        set([constants.DISK_TEMPLATES_STORAGE_TYPE[inst.disk_template]
492
               for inst in self.instances.values()])
493
      # Add lvm, file and shared file storage, if they are enabled, even though
494
      # they might currently not be used.
487
    # enabled_disk_templates in the cluster config were introduced in 2.8.
488
    # Remove this code once upgrading from earlier versions is deprecated.
489
    if not self.cluster.enabled_disk_templates:
490
      template_set = \
491
        set([inst.disk_template for inst in self.instances.values()])
492
      # Add drbd and plain, if lvm is enabled (by specifying a volume group)
495 493
      if self.cluster.volume_group_name:
496
        storage_type_set.add(constants.ST_LVM_VG)
494
        template_set.add(constants.DT_DRBD8)
495
        template_set.add(constants.DT_PLAIN)
497 496
      # FIXME: Adapt this when dis/enabling at configure time is removed.
497
      # Enable 'file' and 'sharedfile', if they are enabled, even though they
498
      # might currently not be used.
498 499
      if constants.ENABLE_FILE_STORAGE:
499
        storage_type_set.add(constants.ST_FILE)
500
        template_set.add(constants.DT_FILE)
500 501
      if constants.ENABLE_SHARED_FILE_STORAGE:
501
        storage_type_set.add(constants.ST_SHARED_FILE)
502
      # Set enabled_storage_types to the inferred storage types. Order them
502
        template_set.add(constants.DT_SHARED_FILE)
503
      # Set enabled_disk_templates to the inferred disk templates. Order them
503 504
      # according to a preference list that is based on Ganeti's history of
504
      # supported storage types.
505
      self.cluster.enabled_storage_types = []
506
      for preferred_type in constants.STORAGE_TYPES_PREFERENCE:
507
        if preferred_type in storage_type_set:
508
          self.cluster.enabled_storage_types.append(preferred_type)
509
          storage_type_set.remove(preferred_type)
510
      self.cluster.enabled_storage_types.extend(list(storage_type_set))
505
      # supported disk templates.
506
      self.cluster.enabled_disk_templates = []
507
      for preferred_template in constants.DISK_TEMPLATE_PREFERENCE:
508
        if preferred_template in template_set:
509
          self.cluster.enabled_disk_templates.append(preferred_template)
510
          template_set.remove(preferred_template)
511
      self.cluster.enabled_disk_templates.extend(list(template_set))
511 512

  
512 513

  
513 514
class NIC(ConfigObject):
......
1540 1541
    "prealloc_wipe_disks",
1541 1542
    "hv_state_static",
1542 1543
    "disk_state_static",
1544
    # Keeping this in temporarily to not break the build between patches of
1545
    # this series. Remove after 'enabled_disk_templates' is fully implemented.
1543 1546
    "enabled_storage_types",
1547
    "enabled_disk_templates",
1544 1548
    ] + _TIMESTAMPS + _UUID
1545 1549

  
1546 1550
  def UpgradeConfig(self):

Also available in: Unified diff