Revision cd3b4ff4 lib/objects.py
b/lib/objects.py | ||
---|---|---|
418 | 418 |
def HasAnyDiskOfType(self, dev_type): |
419 | 419 |
"""Check if in there is at disk of the given type in the configuration. |
420 | 420 |
|
421 |
@type dev_type: L{constants.LDS_BLOCK}
|
|
421 |
@type dev_type: L{constants.DTS_BLOCK}
|
|
422 | 422 |
@param dev_type: the type to look for |
423 | 423 |
@rtype: boolean |
424 | 424 |
@return: boolean indicating if a disk of the given type was found or not |
... | ... | |
447 | 447 |
# To decide if we set an helper let's check if at least one instance has |
448 | 448 |
# a DRBD disk. This does not cover all the possible scenarios but it |
449 | 449 |
# gives a good approximation. |
450 |
if self.HasAnyDiskOfType(constants.LD_DRBD8):
|
|
450 |
if self.HasAnyDiskOfType(constants.DT_DRBD8):
|
|
451 | 451 |
self.cluster.drbd_usermode_helper = constants.DEFAULT_DRBD_HELPER |
452 | 452 |
if self.networks is None: |
453 | 453 |
self.networks = {} |
... | ... | |
511 | 511 |
|
512 | 512 |
def CreateOnSecondary(self): |
513 | 513 |
"""Test if this device needs to be created on a secondary node.""" |
514 |
return self.dev_type in (constants.LD_DRBD8, constants.LD_LV)
|
|
514 |
return self.dev_type in (constants.DT_DRBD8, constants.DT_PLAIN)
|
|
515 | 515 |
|
516 | 516 |
def AssembleOnSecondary(self): |
517 | 517 |
"""Test if this device needs to be assembled on a secondary node.""" |
518 |
return self.dev_type in (constants.LD_DRBD8, constants.LD_LV)
|
|
518 |
return self.dev_type in (constants.DT_DRBD8, constants.DT_PLAIN)
|
|
519 | 519 |
|
520 | 520 |
def OpenOnSecondary(self): |
521 | 521 |
"""Test if this device needs to be opened on a secondary node.""" |
522 |
return self.dev_type in (constants.LD_LV,)
|
|
522 |
return self.dev_type in (constants.DT_PLAIN,)
|
|
523 | 523 |
|
524 | 524 |
def StaticDevPath(self): |
525 | 525 |
"""Return the device path if this device type has a static one. |
... | ... | |
532 | 532 |
should check that it is a valid path. |
533 | 533 |
|
534 | 534 |
""" |
535 |
if self.dev_type == constants.LD_LV:
|
|
535 |
if self.dev_type == constants.DT_PLAIN:
|
|
536 | 536 |
return "/dev/%s/%s" % (self.logical_id[0], self.logical_id[1]) |
537 |
elif self.dev_type == constants.LD_BLOCKDEV:
|
|
537 |
elif self.dev_type == constants.DT_BLOCK:
|
|
538 | 538 |
return self.logical_id[1] |
539 |
elif self.dev_type == constants.LD_RBD:
|
|
539 |
elif self.dev_type == constants.DT_RBD:
|
|
540 | 540 |
return "/dev/%s/%s" % (self.logical_id[0], self.logical_id[1]) |
541 | 541 |
return None |
542 | 542 |
|
... | ... | |
552 | 552 |
-1. |
553 | 553 |
|
554 | 554 |
""" |
555 |
if self.dev_type == constants.LD_DRBD8:
|
|
555 |
if self.dev_type == constants.DT_DRBD8:
|
|
556 | 556 |
return 0 |
557 | 557 |
return -1 |
558 | 558 |
|
559 | 559 |
def IsBasedOnDiskType(self, dev_type): |
560 | 560 |
"""Check if the disk or its children are based on the given type. |
561 | 561 |
|
562 |
@type dev_type: L{constants.LDS_BLOCK}
|
|
562 |
@type dev_type: L{constants.DTS_BLOCK}
|
|
563 | 563 |
@param dev_type: the type to look for |
564 | 564 |
@rtype: boolean |
565 | 565 |
@return: boolean indicating if a device of the given type was found or not |
... | ... | |
580 | 580 |
devices needs to (or can) be assembled. |
581 | 581 |
|
582 | 582 |
""" |
583 |
if self.dev_type in [constants.LD_LV, constants.LD_FILE,
|
|
584 |
constants.LD_BLOCKDEV, constants.LD_RBD,
|
|
585 |
constants.LD_EXT]:
|
|
583 |
if self.dev_type in [constants.DT_PLAIN, constants.DT_FILE,
|
|
584 |
constants.DT_BLOCK, constants.DT_RBD,
|
|
585 |
constants.DT_EXT, constants.DT_SHARED_FILE]:
|
|
586 | 586 |
result = [node_uuid] |
587 | 587 |
elif self.dev_type in constants.LDS_DRBD: |
588 | 588 |
result = [self.logical_id[0], self.logical_id[1]] |
... | ... | |
638 | 638 |
@return: a dictionary of volume-groups and the required size |
639 | 639 |
|
640 | 640 |
""" |
641 |
if self.dev_type == constants.LD_LV:
|
|
641 |
if self.dev_type == constants.DT_PLAIN:
|
|
642 | 642 |
return {self.logical_id[0]: amount} |
643 |
elif self.dev_type == constants.LD_DRBD8:
|
|
643 |
elif self.dev_type == constants.DT_DRBD8:
|
|
644 | 644 |
if self.children: |
645 | 645 |
return self.children[0].ComputeGrowth(amount) |
646 | 646 |
else: |
... | ... | |
657 | 657 |
actual algorithms from bdev. |
658 | 658 |
|
659 | 659 |
""" |
660 |
if self.dev_type in (constants.LD_LV, constants.LD_FILE, |
|
661 |
constants.LD_RBD, constants.LD_EXT): |
|
660 |
if self.dev_type in (constants.DT_PLAIN, constants.DT_FILE, |
|
661 |
constants.DT_RBD, constants.DT_EXT, |
|
662 |
constants.DT_SHARED_FILE): |
|
662 | 663 |
self.size += amount |
663 |
elif self.dev_type == constants.LD_DRBD8:
|
|
664 |
elif self.dev_type == constants.DT_DRBD8:
|
|
664 | 665 |
if self.children: |
665 | 666 |
self.children[0].RecordGrow(amount) |
666 | 667 |
self.size += amount |
... | ... | |
672 | 673 |
"""Apply changes to size, spindles and mode. |
673 | 674 |
|
674 | 675 |
""" |
675 |
if self.dev_type == constants.LD_DRBD8:
|
|
676 |
if self.dev_type == constants.DT_DRBD8:
|
|
676 | 677 |
if self.children: |
677 | 678 |
self.children[0].Update(size=size, mode=mode) |
678 | 679 |
else: |
... | ... | |
775 | 776 |
"""Custom str() formatter for disks. |
776 | 777 |
|
777 | 778 |
""" |
778 |
if self.dev_type == constants.LD_LV:
|
|
779 |
if self.dev_type == constants.DT_PLAIN:
|
|
779 | 780 |
val = "<LogicalVolume(/dev/%s/%s" % self.logical_id |
780 | 781 |
elif self.dev_type in constants.LDS_DRBD: |
781 | 782 |
node_a, node_b, port, minor_a, minor_b = self.logical_id[:5] |
... | ... | |
851 | 852 |
result = list() |
852 | 853 |
dt_params = disk_params[disk_template] |
853 | 854 |
if disk_template == constants.DT_DRBD8: |
854 |
result.append(FillDict(constants.DISK_LD_DEFAULTS[constants.LD_DRBD8], {
|
|
855 |
result.append(FillDict(constants.DISK_DT_DEFAULTS[constants.DT_DRBD8], {
|
|
855 | 856 |
constants.LDP_RESYNC_RATE: dt_params[constants.DRBD_RESYNC_RATE], |
856 | 857 |
constants.LDP_BARRIERS: dt_params[constants.DRBD_DISK_BARRIERS], |
857 | 858 |
constants.LDP_NO_META_FLUSH: dt_params[constants.DRBD_META_BARRIERS], |
... | ... | |
868 | 869 |
})) |
869 | 870 |
|
870 | 871 |
# data LV |
871 |
result.append(FillDict(constants.DISK_LD_DEFAULTS[constants.LD_LV], {
|
|
872 |
result.append(FillDict(constants.DISK_DT_DEFAULTS[constants.DT_PLAIN], {
|
|
872 | 873 |
constants.LDP_STRIPES: dt_params[constants.DRBD_DATA_STRIPES], |
873 | 874 |
})) |
874 | 875 |
|
875 | 876 |
# metadata LV |
876 |
result.append(FillDict(constants.DISK_LD_DEFAULTS[constants.LD_LV], {
|
|
877 |
result.append(FillDict(constants.DISK_DT_DEFAULTS[constants.DT_PLAIN], {
|
|
877 | 878 |
constants.LDP_STRIPES: dt_params[constants.DRBD_META_STRIPES], |
878 | 879 |
})) |
879 | 880 |
|
880 | 881 |
elif disk_template in (constants.DT_FILE, constants.DT_SHARED_FILE): |
881 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_FILE])
|
|
882 |
result.append(constants.DISK_DT_DEFAULTS[disk_template])
|
|
882 | 883 |
|
883 | 884 |
elif disk_template == constants.DT_PLAIN: |
884 |
result.append(FillDict(constants.DISK_LD_DEFAULTS[constants.LD_LV], {
|
|
885 |
result.append(FillDict(constants.DISK_DT_DEFAULTS[constants.DT_PLAIN], {
|
|
885 | 886 |
constants.LDP_STRIPES: dt_params[constants.LV_STRIPES], |
886 | 887 |
})) |
887 | 888 |
|
888 | 889 |
elif disk_template == constants.DT_BLOCK: |
889 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_BLOCKDEV])
|
|
890 |
result.append(constants.DISK_DT_DEFAULTS[constants.DT_BLOCK])
|
|
890 | 891 |
|
891 | 892 |
elif disk_template == constants.DT_RBD: |
892 |
result.append(FillDict(constants.DISK_LD_DEFAULTS[constants.LD_RBD], {
|
|
893 |
result.append(FillDict(constants.DISK_DT_DEFAULTS[constants.DT_RBD], {
|
|
893 | 894 |
constants.LDP_POOL: dt_params[constants.RBD_POOL], |
894 | 895 |
})) |
895 | 896 |
|
896 | 897 |
elif disk_template == constants.DT_EXT: |
897 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_EXT])
|
|
898 |
result.append(constants.DISK_DT_DEFAULTS[constants.DT_EXT])
|
|
898 | 899 |
|
899 | 900 |
return result |
900 | 901 |
|
... | ... | |
1140 | 1141 |
devs = self.disks |
1141 | 1142 |
|
1142 | 1143 |
for dev in devs: |
1143 |
if dev.dev_type == constants.LD_LV:
|
|
1144 |
if dev.dev_type == constants.DT_PLAIN:
|
|
1144 | 1145 |
lvmap[node_uuid].append(dev.logical_id[0] + "/" + dev.logical_id[1]) |
1145 | 1146 |
|
1146 | 1147 |
elif dev.dev_type in constants.LDS_DRBD: |
Also available in: Unified diff