Revision c66d8987

b/NEWS
11 11
- The :doc:`Remote API <rapi>` daemon now supports a command line flag
12 12
  to always require authentication, ``--require-authentication``. It can
13 13
  be specified in ``$sysconfdir/default/ganeti``.
14
- A new cluster attribute 'enabled_storage_types' is introduced. It will
15
  be used to manage the storage types to be used by instances in the cluster.
16
  Initially, it will be set to a list that includes lvm, file and sharedfile
17
  if those are enabled. Additionally, it will include all storage types that
18
  are currently used by instances. The order of storage types will be based
19
  on Ganeti's history of supporting them. In the future, the first entry of
20
  the list will be used as a default storage type on instance creation.
14 21

  
15 22

  
16 23
Version 2.7.0 beta1
b/lib/constants.py
373 373
HKR_SUCCESS = 2
374 374

  
375 375
# Storage types
376
ST_BLOCK = "blockdev"
377
ST_DISKLESS = "diskless"
378
ST_EXT = "ext"
376 379
ST_FILE = "file"
377 380
ST_LVM_PV = "lvm-pv"
378 381
ST_LVM_VG = "lvm-vg"
379
ST_DISKLESS = "diskless"
380
ST_SHARED_FILE = "sharedfile"
381
ST_BLOCK = "blockdev"
382 382
ST_RADOS = "rados"
383
ST_EXT = "ext"
383
ST_SHARED_FILE = "sharedfile"
384 384

  
385 385
VALID_STORAGE_TYPES = compat.UniqueFrozenset([
386
  ST_BLOCK,
387
  ST_DISKLESS,
388
  ST_EXT,
386 389
  ST_FILE,
387 390
  ST_LVM_PV,
388 391
  ST_LVM_VG,
389
  ST_DISKLESS,
390
  ST_SHARED_FILE,
391
  ST_BLOCK,
392 392
  ST_RADOS,
393
  ST_EXT,
393
  ST_SHARED_FILE,
394 394
  ])
395 395

  
396 396
# Per default, only lvm is enabled.
......
398 398
  ST_LVM_VG,
399 399
  ])
400 400

  
401
# This is used to order determine the default storage type when the list
402
# of enabled storage types is inferred from the current state of the cluster.
403
# This only happens on an upgrade from a version of Ganeti that did not
404
# support the 'enabled_storage_methods' so far.
405
STORAGE_TYPES_PREFERENCE = [
406
  ST_LVM_VG,
407
  ST_FILE,
408
  ST_SHARED_FILE,
409
  ST_RADOS,
410
  ST_BLOCK,
411
  ]
412

  
401 413
# Storage fields
402 414
# first two are valid in LU context only, not passed to backend
403 415
SF_NODE = "node"
......
437 449
 LDS_FAULTY) = range(1, 4)
438 450

  
439 451
# disk template types
452
DT_BLOCK = "blockdev"
440 453
DT_DISKLESS = "diskless"
441
DT_PLAIN = "plain"
442 454
DT_DRBD8 = "drbd"
455
DT_EXT = "ext"
443 456
DT_FILE = "file"
444
DT_SHARED_FILE = "sharedfile"
445
DT_BLOCK = "blockdev"
457
DT_PLAIN = "plain"
446 458
DT_RBD = "rbd"
447
DT_EXT = "ext"
459
DT_SHARED_FILE = "sharedfile"
460

  
461
# mapping of disk templates to storage types
462
DISK_TEMPLATES_STORAGE_TYPE = {
463
  DT_BLOCK: ST_BLOCK,
464
  DT_DISKLESS: ST_DISKLESS,
465
  DT_DRBD8: ST_LVM_VG,
466
  DT_EXT: ST_EXT,
467
  DT_FILE: ST_FILE,
468
  DT_PLAIN: ST_LVM_VG,
469
  DT_RBD: ST_RADOS,
470
  DT_SHARED_FILE: ST_SHARED_FILE,
471
  }
448 472

  
449 473
# the set of network-mirrored disk templates
450 474
DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
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