Revision 1b02d7ef
b/lib/constants.py | ||
---|---|---|
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 |
|
|
413 | 401 |
# Storage fields |
414 | 402 |
# first two are valid in LU context only, not passed to backend |
415 | 403 |
SF_NODE = "node" |
... | ... | |
458 | 446 |
DT_RBD = "rbd" |
459 | 447 |
DT_SHARED_FILE = "sharedfile" |
460 | 448 |
|
449 |
# This is used to order determine the default disk template when the list |
|
450 |
# of enabled disk templates is inferred from the current state of the cluster. |
|
451 |
# This only happens on an upgrade from a version of Ganeti that did not |
|
452 |
# support the 'enabled_disk_templates' so far. |
|
453 |
DISK_TEMPLATE_PREFERENCE = [ |
|
454 |
DT_DRBD8, |
|
455 |
DT_PLAIN, |
|
456 |
DT_FILE, |
|
457 |
DT_SHARED_FILE, |
|
458 |
DT_RBD, |
|
459 |
DT_BLOCK, |
|
460 |
DT_DISKLESS, |
|
461 |
DT_EXT |
|
462 |
] |
|
463 |
|
|
464 |
DISK_TEMPLATES = compat.UniqueFrozenset([ |
|
465 |
DT_DISKLESS, |
|
466 |
DT_PLAIN, |
|
467 |
DT_DRBD8, |
|
468 |
DT_FILE, |
|
469 |
DT_SHARED_FILE, |
|
470 |
DT_BLOCK, |
|
471 |
DT_RBD, |
|
472 |
DT_EXT |
|
473 |
]) |
|
474 |
|
|
475 |
# disk templates that are enabled by default |
|
476 |
DEFAULT_ENABLED_DISK_TEMPLATES = compat.UniqueFrozenset([ |
|
477 |
DT_DRBD8, |
|
478 |
DT_PLAIN, |
|
479 |
]) |
|
480 |
|
|
461 | 481 |
# mapping of disk templates to storage types |
462 | 482 |
DISK_TEMPLATES_STORAGE_TYPE = { |
463 | 483 |
DT_BLOCK: ST_BLOCK, |
... | ... | |
645 | 665 |
#: Give child process up to 5 seconds to exit after sending a signal |
646 | 666 |
CHILD_LINGER_TIMEOUT = 5.0 |
647 | 667 |
|
648 |
DISK_TEMPLATES = compat.UniqueFrozenset([ |
|
649 |
DT_DISKLESS, |
|
650 |
DT_PLAIN, |
|
651 |
DT_DRBD8, |
|
652 |
DT_FILE, |
|
653 |
DT_SHARED_FILE, |
|
654 |
DT_BLOCK, |
|
655 |
DT_RBD, |
|
656 |
DT_EXT |
|
657 |
]) |
|
658 |
|
|
659 | 668 |
FILE_DRIVER = compat.UniqueFrozenset([FD_LOOP, FD_BLKTAP]) |
660 | 669 |
|
661 | 670 |
# import/export config options |
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): |
b/src/Ganeti/Objects.hs | ||
---|---|---|
706 | 706 |
, simpleField "primary_ip_family" [t| IpFamily |] |
707 | 707 |
, simpleField "prealloc_wipe_disks" [t| Bool |] |
708 | 708 |
, simpleField "ipolicy" [t| FilledIPolicy |] |
709 |
-- FIXME: Remove enabled storage types once enabled disk templates |
|
710 |
-- is fully implemented. |
|
709 | 711 |
, simpleField "enabled_storage_types" [t| [StorageType] |] |
712 |
, simpleField "enabled_disk_templates" [t| [DiskTemplate] |] |
|
710 | 713 |
] |
711 | 714 |
++ timeStampFields |
712 | 715 |
++ uuidFields |
Also available in: Unified diff