Revision cd3b4ff4
b/doc/design-resource-model.rst | ||
---|---|---|
895 | 895 |
which are queried directly on the node (without hypervisor |
896 | 896 |
involvment). The are stored in a separate attribute (``disk_state``), |
897 | 897 |
which is indexed per storage type and name; currently this will be just |
898 |
``LD_LV`` and the volume name as key.
|
|
898 |
``DT_PLAIN`` and the volume name as key.
|
|
899 | 899 |
|
900 | 900 |
+-------------+-------------------------+--------------------+--------+ |
901 | 901 |
|Name |Description |Current state |Type | |
b/lib/backend.py | ||
---|---|---|
2845 | 2845 |
if constants.HV_DISK_TYPE in instance.hvparams: |
2846 | 2846 |
result["DISK_%d_FRONTEND_TYPE" % idx] = \ |
2847 | 2847 |
instance.hvparams[constants.HV_DISK_TYPE] |
2848 |
if disk.dev_type in constants.LDS_BLOCK:
|
|
2848 |
if disk.dev_type in constants.DTS_BLOCK:
|
|
2849 | 2849 |
result["DISK_%d_BACKEND_TYPE" % idx] = "block" |
2850 |
elif disk.dev_type == constants.LD_FILE:
|
|
2850 |
elif disk.dev_type in [constants.DT_FILE, constants.DT_SHARED_FILE]:
|
|
2851 | 2851 |
result["DISK_%d_BACKEND_TYPE" % idx] = \ |
2852 | 2852 |
"file:%s" % disk.physical_id[0] |
2853 | 2853 |
|
... | ... | |
2969 | 2969 |
@return: snapshot disk ID as (vg, lv) |
2970 | 2970 |
|
2971 | 2971 |
""" |
2972 |
if disk.dev_type == constants.LD_DRBD8:
|
|
2972 |
if disk.dev_type == constants.DT_DRBD8:
|
|
2973 | 2973 |
if not disk.children: |
2974 | 2974 |
_Fail("DRBD device '%s' without backing storage cannot be snapshotted", |
2975 | 2975 |
disk.unique_id) |
2976 | 2976 |
return BlockdevSnapshot(disk.children[0]) |
2977 |
elif disk.dev_type == constants.LD_LV:
|
|
2977 |
elif disk.dev_type == constants.DT_PLAIN:
|
|
2978 | 2978 |
r_dev = _RecursiveFindBD(disk) |
2979 | 2979 |
if r_dev is not None: |
2980 | 2980 |
# FIXME: choose a saner value for the snapshot size |
b/lib/client/gnt_instance.py | ||
---|---|---|
919 | 919 |
"""Formats the logical_id of a disk. |
920 | 920 |
|
921 | 921 |
""" |
922 |
if dev_type == constants.LD_DRBD8:
|
|
922 |
if dev_type == constants.DT_DRBD8:
|
|
923 | 923 |
drbd_info = dev["drbd_info"] |
924 | 924 |
data = [ |
925 | 925 |
("nodeA", "%s, minor=%s" % |
... | ... | |
933 | 933 |
("port", str(compat.TryToRoman(drbd_info["port"], convert=roman))), |
934 | 934 |
("auth key", str(drbd_info["secret"])), |
935 | 935 |
] |
936 |
elif dev_type == constants.LD_LV:
|
|
936 |
elif dev_type == constants.DT_PLAIN:
|
|
937 | 937 |
vg_name, lv_name = dev["logical_id"] |
938 | 938 |
data = ["%s/%s" % (vg_name, lv_name)] |
939 | 939 |
else: |
... | ... | |
968 | 968 |
"""Format one line for physical device status. |
969 | 969 |
|
970 | 970 |
@type dtype: str |
971 |
@param dtype: a constant from the L{constants.LDS_BLOCK} set
|
|
971 |
@param dtype: a constant from the L{constants.DTS_BLOCK} set
|
|
972 | 972 |
@type status: tuple |
973 | 973 |
@param status: a tuple as returned from L{backend.FindBlockDevice} |
974 | 974 |
@return: the string representing the status |
... | ... | |
989 | 989 |
minor_string = str(compat.TryToRoman(minor, convert=roman)) |
990 | 990 |
|
991 | 991 |
txt += ("%s (%s:%s)" % (path, major_string, minor_string)) |
992 |
if dtype in (constants.LD_DRBD8, ):
|
|
992 |
if dtype in (constants.DT_DRBD8, ):
|
|
993 | 993 |
if syncp is not None: |
994 | 994 |
sync_text = "*RECOVERING* %5.2f%%," % syncp |
995 | 995 |
if estt: |
... | ... | |
1009 | 1009 |
else: |
1010 | 1010 |
ldisk_text = "" |
1011 | 1011 |
txt += (" %s, status %s%s" % (sync_text, degr_text, ldisk_text)) |
1012 |
elif dtype == constants.LD_LV:
|
|
1012 |
elif dtype == constants.DT_PLAIN:
|
|
1013 | 1013 |
if ldisk_status == constants.LDS_FAULTY: |
1014 | 1014 |
ldisk_text = " *FAILED* (failed drive?)" |
1015 | 1015 |
else: |
b/lib/cmdlib/backup.py | ||
---|---|---|
341 | 341 |
# instance disk type verification |
342 | 342 |
# TODO: Implement export support for file-based disks |
343 | 343 |
for disk in self.instance.disks: |
344 |
if disk.dev_type == constants.LD_FILE:
|
|
344 |
if disk.dev_type in [constants.DT_FILE, constants.DT_SHARED_FILE]:
|
|
345 | 345 |
raise errors.OpPrereqError("Export not supported for instances with" |
346 | 346 |
" file-based disks", errors.ECODE_INVAL) |
347 | 347 |
|
b/lib/cmdlib/cluster.py | ||
---|---|---|
495 | 495 |
@param disk: an L{ganeti.objects.Disk} object |
496 | 496 |
|
497 | 497 |
""" |
498 |
if disk.dev_type == constants.LD_DRBD8:
|
|
498 |
if disk.dev_type == constants.DT_DRBD8:
|
|
499 | 499 |
assert disk.children, "Empty children for DRBD8?" |
500 | 500 |
fchild = disk.children[0] |
501 | 501 |
mismatch = fchild.size < disk.size |
... | ... | |
757 | 757 |
" enabling lvm-based disk-templates.") |
758 | 758 |
|
759 | 759 |
if self.op.vg_name is not None and not self.op.vg_name: |
760 |
if self.cfg.HasAnyDiskOfType(constants.LD_LV):
|
|
760 |
if self.cfg.HasAnyDiskOfType(constants.DT_PLAIN):
|
|
761 | 761 |
raise errors.OpPrereqError("Cannot disable lvm storage while lvm-based" |
762 | 762 |
" instances exist", errors.ECODE_INVAL) |
763 | 763 |
|
... | ... | |
859 | 859 |
|
860 | 860 |
""" |
861 | 861 |
if self.op.drbd_helper is not None and not self.op.drbd_helper: |
862 |
if self.cfg.HasAnyDiskOfType(constants.LD_DRBD8):
|
|
862 |
if self.cfg.HasAnyDiskOfType(constants.DT_DRBD8):
|
|
863 | 863 |
raise errors.OpPrereqError("Cannot disable drbd helper while" |
864 | 864 |
" drbd-based instances exist", |
865 | 865 |
errors.ECODE_INVAL) |
b/lib/cmdlib/instance.py | ||
---|---|---|
1705 | 1705 |
bep = self.cfg.GetClusterInfo().FillBE(self.instance) |
1706 | 1706 |
|
1707 | 1707 |
for idx, dsk in enumerate(self.instance.disks): |
1708 |
if dsk.dev_type not in (constants.LD_LV, constants.LD_FILE): |
|
1708 |
if dsk.dev_type not in (constants.DT_PLAIN, constants.DT_FILE, |
|
1709 |
constants.DT_SHARED_FILE): |
|
1709 | 1710 |
raise errors.OpPrereqError("Instance disk %d has a complex layout," |
1710 | 1711 |
" cannot copy" % idx, errors.ECODE_STATE) |
1711 | 1712 |
|
b/lib/cmdlib/instance_storage.py | ||
---|---|---|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
|
58 |
_DISK_TEMPLATE_DEVICE_TYPE = { |
|
59 |
constants.DT_PLAIN: constants.LD_LV, |
|
60 |
constants.DT_FILE: constants.LD_FILE, |
|
61 |
constants.DT_SHARED_FILE: constants.LD_FILE, |
|
62 |
constants.DT_BLOCK: constants.LD_BLOCKDEV, |
|
63 |
constants.DT_RBD: constants.LD_RBD, |
|
64 |
constants.DT_EXT: constants.LD_EXT, |
|
65 |
} |
|
66 |
|
|
67 |
|
|
68 | 58 |
def CreateSingleBlockDev(lu, node_uuid, instance, device, info, force_open, |
69 | 59 |
excl_stor): |
70 | 60 |
"""Create a single block device on a given node. |
... | ... | |
390 | 380 |
port = lu.cfg.AllocatePort() |
391 | 381 |
shared_secret = lu.cfg.GenerateDRBDSecret(lu.proc.GetECId()) |
392 | 382 |
|
393 |
dev_data = objects.Disk(dev_type=constants.LD_LV, size=size,
|
|
383 |
dev_data = objects.Disk(dev_type=constants.DT_PLAIN, size=size,
|
|
394 | 384 |
logical_id=(vgnames[0], names[0]), |
395 | 385 |
params={}) |
396 | 386 |
dev_data.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId()) |
397 |
dev_meta = objects.Disk(dev_type=constants.LD_LV,
|
|
387 |
dev_meta = objects.Disk(dev_type=constants.DT_PLAIN,
|
|
398 | 388 |
size=constants.DRBD_META_SIZE, |
399 | 389 |
logical_id=(vgnames[1], names[1]), |
400 | 390 |
params={}) |
401 | 391 |
dev_meta.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId()) |
402 |
drbd_dev = objects.Disk(dev_type=constants.LD_DRBD8, size=size,
|
|
392 |
drbd_dev = objects.Disk(dev_type=constants.DT_DRBD8, size=size,
|
|
403 | 393 |
logical_id=(primary_uuid, secondary_uuid, port, |
404 | 394 |
p_minor, s_minor, |
405 | 395 |
shared_secret), |
... | ... | |
493 | 483 |
else: |
494 | 484 |
raise errors.ProgrammerError("Unknown disk template '%s'" % template_name) |
495 | 485 |
|
496 |
dev_type = _DISK_TEMPLATE_DEVICE_TYPE[template_name]
|
|
486 |
dev_type = template_name
|
|
497 | 487 |
|
498 | 488 |
for idx, disk in enumerate(disk_info): |
499 | 489 |
params = {} |
... | ... | |
819 | 809 |
continue |
820 | 810 |
|
821 | 811 |
# update secondaries for disks, if needed |
822 |
if self.op.node_uuids and disk.dev_type == constants.LD_DRBD8:
|
|
812 |
if self.op.node_uuids and disk.dev_type == constants.DT_DRBD8:
|
|
823 | 813 |
# need to update the nodes and minors |
824 | 814 |
assert len(self.op.node_uuids) == 2 |
825 | 815 |
assert len(disk.logical_id) == 6 # otherwise disk internals |
... | ... | |
840 | 830 |
for idx, new_id, changes in mods: |
841 | 831 |
disk = self.instance.disks[idx] |
842 | 832 |
if new_id is not None: |
843 |
assert disk.dev_type == constants.LD_DRBD8
|
|
833 |
assert disk.dev_type == constants.DT_DRBD8
|
|
844 | 834 |
disk.logical_id = new_id |
845 | 835 |
if changes: |
846 | 836 |
disk.Update(size=changes.get(constants.IDISK_SIZE, None), |
... | ... | |
2261 | 2251 |
|
2262 | 2252 |
(data_disk, meta_disk) = dev.children |
2263 | 2253 |
vg_data = data_disk.logical_id[0] |
2264 |
lv_data = objects.Disk(dev_type=constants.LD_LV, size=dev.size,
|
|
2254 |
lv_data = objects.Disk(dev_type=constants.DT_PLAIN, size=dev.size,
|
|
2265 | 2255 |
logical_id=(vg_data, names[0]), |
2266 | 2256 |
params=data_disk.params) |
2267 | 2257 |
vg_meta = meta_disk.logical_id[0] |
2268 |
lv_meta = objects.Disk(dev_type=constants.LD_LV,
|
|
2258 |
lv_meta = objects.Disk(dev_type=constants.DT_PLAIN,
|
|
2269 | 2259 |
size=constants.DRBD_META_SIZE, |
2270 | 2260 |
logical_id=(vg_meta, names[1]), |
2271 | 2261 |
params=meta_disk.params) |
... | ... | |
2541 | 2531 |
iv_names[idx] = (dev, dev.children, new_net_id) |
2542 | 2532 |
logging.debug("Allocated new_minor: %s, new_logical_id: %s", new_minor, |
2543 | 2533 |
new_net_id) |
2544 |
new_drbd = objects.Disk(dev_type=constants.LD_DRBD8,
|
|
2534 |
new_drbd = objects.Disk(dev_type=constants.DT_DRBD8,
|
|
2545 | 2535 |
logical_id=new_alone_id, |
2546 | 2536 |
children=dev.children, |
2547 | 2537 |
size=dev.size, |
b/lib/config.py | ||
---|---|---|
891 | 891 |
|
892 | 892 |
if disk.logical_id is None and disk.physical_id is not None: |
893 | 893 |
return |
894 |
if disk.dev_type == constants.LD_DRBD8:
|
|
894 |
if disk.dev_type == constants.DT_DRBD8:
|
|
895 | 895 |
pnode, snode, port, pminor, sminor, secret = disk.logical_id |
896 | 896 |
if node_uuid not in (pnode, snode): |
897 | 897 |
raise errors.ConfigurationError("DRBD device not knowing node %s" % |
... | ... | |
981 | 981 |
""" |
982 | 982 |
def _AppendUsedMinors(get_node_name_fn, instance, disk, used): |
983 | 983 |
duplicates = [] |
984 |
if disk.dev_type == constants.LD_DRBD8 and len(disk.logical_id) >= 5:
|
|
984 |
if disk.dev_type == constants.DT_DRBD8 and len(disk.logical_id) >= 5:
|
|
985 | 985 |
node_a, node_b, _, minor_a, minor_b = disk.logical_id[:5] |
986 | 986 |
for node_uuid, minor in ((node_a, minor_a), (node_b, minor_b)): |
987 | 987 |
assert node_uuid in used, \ |
... | ... | |
1570 | 1570 |
inst.name = new_name |
1571 | 1571 |
|
1572 | 1572 |
for (idx, disk) in enumerate(inst.disks): |
1573 |
if disk.dev_type == constants.LD_FILE:
|
|
1573 |
if disk.dev_type in [constants.DT_FILE, constants.DT_SHARED_FILE]:
|
|
1574 | 1574 |
# rename the file paths in logical and physical id |
1575 | 1575 |
file_storage_dir = os.path.dirname(os.path.dirname(disk.logical_id[1])) |
1576 | 1576 |
disk.logical_id = (disk.logical_id[0], |
b/lib/constants.py | ||
---|---|---|
564 | 564 |
DT_EXT, |
565 | 565 |
]) |
566 | 566 |
|
567 |
# logical disk types |
|
568 |
LD_LV = "lvm" |
|
569 |
LD_DRBD8 = "drbd8" |
|
570 |
LD_FILE = "file" |
|
571 |
LD_BLOCKDEV = "blockdev" |
|
572 |
LD_RBD = "rbd" |
|
573 |
LD_EXT = "ext" |
|
574 |
LOGICAL_DISK_TYPES = compat.UniqueFrozenset([ |
|
575 |
LD_LV, |
|
576 |
LD_DRBD8, |
|
577 |
LD_FILE, |
|
578 |
LD_BLOCKDEV, |
|
579 |
LD_RBD, |
|
580 |
LD_EXT, |
|
581 |
]) |
|
582 |
|
|
583 |
LDS_BLOCK = compat.UniqueFrozenset([ |
|
584 |
LD_LV, |
|
585 |
LD_DRBD8, |
|
586 |
LD_BLOCKDEV, |
|
587 |
LD_RBD, |
|
588 |
LD_EXT, |
|
567 |
DTS_BLOCK = compat.UniqueFrozenset([ |
|
568 |
DT_PLAIN, |
|
569 |
DT_DRBD8, |
|
570 |
DT_BLOCK, |
|
571 |
DT_RBD, |
|
572 |
DT_EXT, |
|
589 | 573 |
]) |
590 | 574 |
|
591 | 575 |
# drbd constants |
... | ... | |
623 | 607 |
FD_BLKTAP = "blktap" |
624 | 608 |
|
625 | 609 |
# the set of drbd-like disk types |
626 |
LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
|
|
610 |
LDS_DRBD = compat.UniqueFrozenset([DT_DRBD8])
|
|
627 | 611 |
|
628 | 612 |
# disk access mode |
629 | 613 |
DISK_RDONLY = "ro" |
... | ... | |
1119 | 1103 |
} |
1120 | 1104 |
|
1121 | 1105 |
DSS_PARAMETERS = frozenset(DSS_PARAMETER_TYPES.keys()) |
1122 |
DS_VALID_TYPES = compat.UniqueFrozenset([LD_LV])
|
|
1106 |
DS_VALID_TYPES = compat.UniqueFrozenset([DT_PLAIN])
|
|
1123 | 1107 |
|
1124 | 1108 |
# Backend parameter names |
1125 | 1109 |
BE_MEMORY = "memory" # deprecated and replaced by max and min mem |
... | ... | |
2203 | 2187 |
ND_EXCLUSIVE_STORAGE, |
2204 | 2188 |
]) |
2205 | 2189 |
|
2206 |
DISK_LD_DEFAULTS = {
|
|
2207 |
LD_DRBD8: {
|
|
2190 |
DISK_DT_DEFAULTS = {
|
|
2191 |
DT_DRBD8: {
|
|
2208 | 2192 |
LDP_RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED, |
2209 | 2193 |
LDP_BARRIERS: _autoconf.DRBD_BARRIERS, |
2210 | 2194 |
LDP_NO_META_FLUSH: _autoconf.DRBD_NO_META_FLUSH, |
... | ... | |
2225 | 2209 |
LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s |
2226 | 2210 |
LDP_MIN_RATE: 4 * 1024, # KiB/s |
2227 | 2211 |
}, |
2228 |
LD_LV: {
|
|
2212 |
DT_PLAIN: {
|
|
2229 | 2213 |
LDP_STRIPES: _autoconf.LVM_STRIPECOUNT |
2230 | 2214 |
}, |
2231 |
LD_FILE: {}, |
|
2232 |
LD_BLOCKDEV: {}, |
|
2233 |
LD_RBD: { |
|
2215 |
DT_FILE: {}, |
|
2216 |
DT_SHARED_FILE: {}, |
|
2217 |
DT_BLOCK: {}, |
|
2218 |
DT_RBD: { |
|
2234 | 2219 |
LDP_POOL: "rbd" |
2235 | 2220 |
}, |
2236 |
LD_EXT: {},
|
|
2221 |
DT_EXT: {},
|
|
2237 | 2222 |
} |
2238 | 2223 |
|
2239 | 2224 |
# readability shortcuts |
2240 |
_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
|
|
2241 |
_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
|
|
2225 |
_LV_DEFAULTS = DISK_DT_DEFAULTS[DT_PLAIN]
|
|
2226 |
_DRBD_DEFAULTS = DISK_DT_DEFAULTS[DT_DRBD8]
|
|
2242 | 2227 |
|
2243 | 2228 |
DISK_DT_DEFAULTS = { |
2244 | 2229 |
DT_PLAIN: { |
2245 |
LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
|
|
2230 |
LV_STRIPES: DISK_DT_DEFAULTS[DT_PLAIN][LDP_STRIPES],
|
|
2246 | 2231 |
}, |
2247 | 2232 |
DT_DRBD8: { |
2248 | 2233 |
DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE], |
... | ... | |
2266 | 2251 |
DT_SHARED_FILE: {}, |
2267 | 2252 |
DT_BLOCK: {}, |
2268 | 2253 |
DT_RBD: { |
2269 |
RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
|
|
2254 |
RBD_POOL: DISK_DT_DEFAULTS[DT_RBD][LDP_POOL]
|
|
2270 | 2255 |
}, |
2271 | 2256 |
DT_EXT: {}, |
2272 | 2257 |
} |
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
295 | 295 |
else: |
296 | 296 |
mode = "r" |
297 | 297 |
|
298 |
if cfdev.dev_type == constants.LD_FILE:
|
|
298 |
if cfdev.dev_type in [constants.DT_FILE, constants.DT_SHARED_FILE]:
|
|
299 | 299 |
driver = _FILE_DRIVER_MAP[cfdev.physical_id[0]] |
300 | 300 |
else: |
301 | 301 |
driver = "phy" |
b/lib/masterd/instance.py | ||
---|---|---|
1184 | 1184 |
" result '%s'", idx, src_node, result.payload) |
1185 | 1185 |
else: |
1186 | 1186 |
disk_id = tuple(result.payload) |
1187 |
disk_params = constants.DISK_LD_DEFAULTS[constants.LD_LV].copy()
|
|
1188 |
new_dev = objects.Disk(dev_type=constants.LD_LV, size=disk.size,
|
|
1187 |
disk_params = constants.DISK_DT_DEFAULTS[constants.DT_PLAIN].copy()
|
|
1188 |
new_dev = objects.Disk(dev_type=constants.DT_PLAIN, size=disk.size,
|
|
1189 | 1189 |
logical_id=disk_id, physical_id=disk_id, |
1190 | 1190 |
iv_name=disk.iv_name, |
1191 | 1191 |
params=disk_params) |
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: |
b/lib/rpc.py | ||
---|---|---|
662 | 662 |
"""Annotates just DRBD disks layouts. |
663 | 663 |
|
664 | 664 |
""" |
665 |
assert disk.dev_type == constants.LD_DRBD8
|
|
665 |
assert disk.dev_type == constants.DT_DRBD8
|
|
666 | 666 |
|
667 | 667 |
disk.params = objects.FillDict(drbd_params, disk.params) |
668 | 668 |
(dev_data, dev_meta) = disk.children |
... | ... | |
676 | 676 |
"""Generic disk parameter annotation routine. |
677 | 677 |
|
678 | 678 |
""" |
679 |
assert disk.dev_type != constants.LD_DRBD8
|
|
679 |
assert disk.dev_type != constants.DT_DRBD8
|
|
680 | 680 |
|
681 | 681 |
disk.params = objects.FillDict(params, disk.params) |
682 | 682 |
|
b/lib/storage/bdev.py | ||
---|---|---|
1718 | 1718 |
|
1719 | 1719 |
|
1720 | 1720 |
DEV_MAP = { |
1721 |
constants.LD_LV: LogicalVolume, |
|
1722 |
constants.LD_DRBD8: drbd.DRBD8Dev, |
|
1723 |
constants.LD_BLOCKDEV: PersistentBlockDevice, |
|
1724 |
constants.LD_RBD: RADOSBlockDevice, |
|
1725 |
constants.LD_EXT: ExtStorageDevice, |
|
1726 |
constants.LD_FILE: FileStorage, |
|
1721 |
constants.DT_PLAIN: LogicalVolume, |
|
1722 |
constants.DT_DRBD8: drbd.DRBD8Dev, |
|
1723 |
constants.DT_BLOCK: PersistentBlockDevice, |
|
1724 |
constants.DT_RBD: RADOSBlockDevice, |
|
1725 |
constants.DT_EXT: ExtStorageDevice, |
|
1726 |
constants.DT_FILE: FileStorage, |
|
1727 |
constants.DT_SHARED_FILE: FileStorage, |
|
1727 | 1728 |
} |
1728 | 1729 |
|
1729 | 1730 |
|
... | ... | |
1736 | 1737 |
"""Verifies if all disk parameters are set. |
1737 | 1738 |
|
1738 | 1739 |
""" |
1739 |
missing = set(constants.DISK_LD_DEFAULTS[disk.dev_type]) - set(disk.params)
|
|
1740 |
missing = set(constants.DISK_DT_DEFAULTS[disk.dev_type]) - set(disk.params)
|
|
1740 | 1741 |
if missing: |
1741 | 1742 |
raise errors.ProgrammerError("Block device is missing disk parameters: %s" % |
1742 | 1743 |
missing) |
b/qa/qa_instance.py | ||
---|---|---|
95 | 95 |
drbd_min = {} |
96 | 96 |
for (count, diskinfo) in enumerate(info["Disks"]): |
97 | 97 |
(dtype, _) = diskinfo["disk/%s" % count].split(",", 1) |
98 |
if dtype == constants.LD_DRBD8:
|
|
98 |
if dtype == constants.DT_DRBD8:
|
|
99 | 99 |
for child in diskinfo["child devices"]: |
100 | 100 |
vols.append(child["logical_id"]) |
101 | 101 |
for key in ["nodeA", "nodeB"]: |
... | ... | |
106 | 106 |
minor = int(m.group(2)) |
107 | 107 |
minorlist = drbd_min.setdefault(node, []) |
108 | 108 |
minorlist.append(minor) |
109 |
elif dtype == constants.LD_LV:
|
|
109 |
elif dtype == constants.DT_PLAIN:
|
|
110 | 110 |
vols.append(diskinfo["logical_id"]) |
111 | 111 |
|
112 | 112 |
assert nodes |
b/src/Ganeti/Objects.hs | ||
---|---|---|
41 | 41 |
, FileDriver(..) |
42 | 42 |
, BlockDriver(..) |
43 | 43 |
, DiskMode(..) |
44 |
, DiskType(..) |
|
45 | 44 |
, DiskLogicalId(..) |
46 | 45 |
, Disk(..) |
47 | 46 |
, includesLogicalId |
... | ... | |
303 | 302 |
]) |
304 | 303 |
$(makeJSONInstance ''DiskMode) |
305 | 304 |
|
306 |
$(declareSADT "DiskType" |
|
307 |
[ ("LD_LV", 'C.ldLv) |
|
308 |
, ("LD_DRBD8", 'C.ldDrbd8) |
|
309 |
, ("LD_FILE", 'C.ldFile) |
|
310 |
, ("LD_BLOCKDEV", 'C.ldBlockdev) |
|
311 |
, ("LD_RADOS", 'C.ldRbd) |
|
312 |
, ("LD_EXT", 'C.ldExt) |
|
313 |
]) |
|
314 |
$(makeJSONInstance ''DiskType) |
|
315 |
|
|
316 | 305 |
-- | The persistent block driver type. Currently only one type is allowed. |
317 | 306 |
$(declareSADT "BlockDriver" |
318 | 307 |
[ ("BlockDrvManual", 'C.blockdevDriverManual) |
... | ... | |
332 | 321 |
| LIDDrbd8 String String Int Int Int String |
333 | 322 |
-- ^ NodeA, NodeB, Port, MinorA, MinorB, Secret |
334 | 323 |
| LIDFile FileDriver String -- ^ Driver, path |
324 |
| LIDSharedFile FileDriver String -- ^ Driver, path |
|
335 | 325 |
| LIDBlockDev BlockDriver String -- ^ Driver, path (must be under /dev) |
336 | 326 |
| LIDRados String String -- ^ Unused, path |
337 | 327 |
| LIDExt String String -- ^ ExtProvider, unique name |
338 | 328 |
deriving (Show, Eq) |
339 | 329 |
|
340 | 330 |
-- | Mapping from a logical id to a disk type. |
341 |
lidDiskType :: DiskLogicalId -> DiskType |
|
342 |
lidDiskType (LIDPlain {}) = LD_LV |
|
343 |
lidDiskType (LIDDrbd8 {}) = LD_DRBD8 |
|
344 |
lidDiskType (LIDFile {}) = LD_FILE |
|
345 |
lidDiskType (LIDBlockDev {}) = LD_BLOCKDEV |
|
346 |
lidDiskType (LIDRados {}) = LD_RADOS |
|
347 |
lidDiskType (LIDExt {}) = LD_EXT |
|
331 |
lidDiskType :: DiskLogicalId -> DiskTemplate |
|
332 |
lidDiskType (LIDPlain {}) = DTPlain |
|
333 |
lidDiskType (LIDDrbd8 {}) = DTDrbd8 |
|
334 |
lidDiskType (LIDFile {}) = DTFile |
|
335 |
lidDiskType (LIDSharedFile {}) = DTSharedFile |
|
336 |
lidDiskType (LIDBlockDev {}) = DTBlock |
|
337 |
lidDiskType (LIDRados {}) = DTRbd |
|
338 |
lidDiskType (LIDExt {}) = DTExt |
|
348 | 339 |
|
349 | 340 |
-- | Builds the extra disk_type field for a given logical id. |
350 | 341 |
lidEncodeType :: DiskLogicalId -> [(String, JSValue)] |
... | ... | |
358 | 349 |
, showJSON minorA, showJSON minorB, showJSON key ] |
359 | 350 |
encodeDLId (LIDRados pool name) = JSArray [showJSON pool, showJSON name] |
360 | 351 |
encodeDLId (LIDFile driver name) = JSArray [showJSON driver, showJSON name] |
352 |
encodeDLId (LIDSharedFile driver name) = |
|
353 |
JSArray [showJSON driver, showJSON name] |
|
361 | 354 |
encodeDLId (LIDBlockDev driver name) = JSArray [showJSON driver, showJSON name] |
362 | 355 |
encodeDLId (LIDExt extprovider name) = |
363 | 356 |
JSArray [showJSON extprovider, showJSON name] |
... | ... | |
373 | 366 |
decodeDLId obj lid = do |
374 | 367 |
dtype <- fromObj obj devType |
375 | 368 |
case dtype of |
376 |
LD_DRBD8 ->
|
|
369 |
DTDrbd8 ->
|
|
377 | 370 |
case lid of |
378 | 371 |
JSArray [nA, nB, p, mA, mB, k] -> do |
379 | 372 |
nA' <- readJSON nA |
... | ... | |
384 | 377 |
k' <- readJSON k |
385 | 378 |
return $ LIDDrbd8 nA' nB' p' mA' mB' k' |
386 | 379 |
_ -> fail "Can't read logical_id for DRBD8 type" |
387 |
LD_LV ->
|
|
380 |
DTPlain ->
|
|
388 | 381 |
case lid of |
389 | 382 |
JSArray [vg, lv] -> do |
390 | 383 |
vg' <- readJSON vg |
391 | 384 |
lv' <- readJSON lv |
392 | 385 |
return $ LIDPlain vg' lv' |
393 | 386 |
_ -> fail "Can't read logical_id for plain type" |
394 |
LD_FILE ->
|
|
387 |
DTFile ->
|
|
395 | 388 |
case lid of |
396 | 389 |
JSArray [driver, path] -> do |
397 | 390 |
driver' <- readJSON driver |
398 | 391 |
path' <- readJSON path |
399 | 392 |
return $ LIDFile driver' path' |
400 | 393 |
_ -> fail "Can't read logical_id for file type" |
401 |
LD_BLOCKDEV -> |
|
394 |
DTSharedFile -> |
|
395 |
case lid of |
|
396 |
JSArray [driver, path] -> do |
|
397 |
driver' <- readJSON driver |
|
398 |
path' <- readJSON path |
|
399 |
return $ LIDSharedFile driver' path' |
|
400 |
_ -> fail "Can't read logical_id for shared file type" |
|
401 |
DTBlock -> |
|
402 | 402 |
case lid of |
403 | 403 |
JSArray [driver, path] -> do |
404 | 404 |
driver' <- readJSON driver |
405 | 405 |
path' <- readJSON path |
406 | 406 |
return $ LIDBlockDev driver' path' |
407 | 407 |
_ -> fail "Can't read logical_id for blockdev type" |
408 |
LD_RADOS ->
|
|
408 |
DTRbd ->
|
|
409 | 409 |
case lid of |
410 | 410 |
JSArray [driver, path] -> do |
411 | 411 |
driver' <- readJSON driver |
412 | 412 |
path' <- readJSON path |
413 | 413 |
return $ LIDRados driver' path' |
414 | 414 |
_ -> fail "Can't read logical_id for rdb type" |
415 |
LD_EXT ->
|
|
415 |
DTExt ->
|
|
416 | 416 |
case lid of |
417 | 417 |
JSArray [extprovider, name] -> do |
418 | 418 |
extprovider' <- readJSON extprovider |
419 | 419 |
name' <- readJSON name |
420 | 420 |
return $ LIDExt extprovider' name' |
421 | 421 |
_ -> fail "Can't read logical_id for extstorage type" |
422 |
DTDiskless -> |
|
423 |
fail "Retrieved 'diskless' disk." |
|
422 | 424 |
|
423 | 425 |
-- | Disk data structure. |
424 | 426 |
-- |
b/test/py/ganeti.cmdlib_unittest.py | ||
---|---|---|
197 | 197 |
disks = [] |
198 | 198 |
disk_template = constants.DT_DISKLESS |
199 | 199 |
else: |
200 |
disks = [objects.Disk(dev_type=constants.LD_DRBD8,
|
|
200 |
disks = [objects.Disk(dev_type=constants.DT_DRBD8,
|
|
201 | 201 |
logical_id=[pnode, snode, 1, 17, 17])] |
202 | 202 |
disk_template = constants.DT_DRBD8 |
203 | 203 |
|
... | ... | |
604 | 604 |
|
605 | 605 |
def testWithoutOldData(self): |
606 | 606 |
new = { |
607 |
constants.LD_LV: {
|
|
607 |
constants.DT_PLAIN: {
|
|
608 | 608 |
"xenvg": { |
609 | 609 |
constants.DS_DISK_RESERVED: 1024, |
610 | 610 |
}, |
... | ... | |
1293 | 1293 |
}] |
1294 | 1294 |
|
1295 | 1295 |
result = self._TestTrivialDisk(constants.DT_PLAIN, disk_info, 3, |
1296 |
constants.LD_LV)
|
|
1296 |
constants.DT_PLAIN)
|
|
1297 | 1297 |
|
1298 | 1298 |
self.assertEqual(map(operator.attrgetter("logical_id"), result), [ |
1299 | 1299 |
("testvg", "ec0-uq0.disk3"), |
... | ... | |
1322 | 1322 |
|
1323 | 1323 |
self._SetUpLUWithTemplates([disk_template]) |
1324 | 1324 |
result = self._TestTrivialDisk(disk_template, disk_info, 2, |
1325 |
constants.LD_FILE, file_storage_dir="/tmp",
|
|
1325 |
constants.DT_FILE, file_storage_dir="/tmp",
|
|
1326 | 1326 |
file_driver=constants.FD_BLKTAP) |
1327 | 1327 |
|
1328 | 1328 |
self.assertEqual(map(operator.attrgetter("logical_id"), result), [ |
... | ... | |
1339 | 1339 |
}] |
1340 | 1340 |
|
1341 | 1341 |
result = self._TestTrivialDisk(constants.DT_BLOCK, disk_info, 10, |
1342 |
constants.LD_BLOCKDEV)
|
|
1342 |
constants.DT_BLOCK)
|
|
1343 | 1343 |
|
1344 | 1344 |
self.assertEqual(map(operator.attrgetter("logical_id"), result), [ |
1345 | 1345 |
(constants.BLOCKDEV_DRIVER_MANUAL, "/tmp/some/block/dev"), |
... | ... | |
1355 | 1355 |
}] |
1356 | 1356 |
|
1357 | 1357 |
result = self._TestTrivialDisk(constants.DT_RBD, disk_info, 0, |
1358 |
constants.LD_RBD)
|
|
1358 |
constants.DT_RBD)
|
|
1359 | 1359 |
|
1360 | 1360 |
self.assertEqual(map(operator.attrgetter("logical_id"), result), [ |
1361 | 1361 |
("rbd", "ec0-uq0.rbd.disk0"), |
... | ... | |
1364 | 1364 |
|
1365 | 1365 |
def testDrbd8(self): |
1366 | 1366 |
gdt = instance.GenerateDiskTemplate |
1367 |
drbd8_defaults = constants.DISK_LD_DEFAULTS[constants.LD_DRBD8]
|
|
1367 |
drbd8_defaults = constants.DISK_DT_DEFAULTS[constants.DT_DRBD8]
|
|
1368 | 1368 |
drbd8_default_metavg = drbd8_defaults[constants.LDP_DEFAULT_METAVG] |
1369 | 1369 |
|
1370 | 1370 |
disk_info = [{ |
... | ... | |
1411 | 1411 |
|
1412 | 1412 |
for (idx, disk) in enumerate(result): |
1413 | 1413 |
self.assertTrue(isinstance(disk, objects.Disk)) |
1414 |
self.assertEqual(disk.dev_type, constants.LD_DRBD8)
|
|
1414 |
self.assertEqual(disk.dev_type, constants.DT_DRBD8)
|
|
1415 | 1415 |
self.assertEqual(disk.size, disk_info[idx][constants.IDISK_SIZE]) |
1416 | 1416 |
self.assertEqual(disk.mode, disk_info[idx][constants.IDISK_MODE]) |
1417 | 1417 |
|
1418 | 1418 |
for child in disk.children: |
1419 | 1419 |
self.assertTrue(isinstance(disk, objects.Disk)) |
1420 |
self.assertEqual(child.dev_type, constants.LD_LV)
|
|
1420 |
self.assertEqual(child.dev_type, constants.DT_PLAIN)
|
|
1421 | 1421 |
self.assertTrue(child.children is None) |
1422 | 1422 |
|
1423 | 1423 |
self.assertEqual(map(operator.attrgetter("logical_id"), disk.children), |
... | ... | |
1528 | 1528 |
cfg=_ConfigForDiskWipe(node_name)) |
1529 | 1529 |
|
1530 | 1530 |
disks = [ |
1531 |
objects.Disk(dev_type=constants.LD_LV),
|
|
1532 |
objects.Disk(dev_type=constants.LD_LV),
|
|
1533 |
objects.Disk(dev_type=constants.LD_LV),
|
|
1531 |
objects.Disk(dev_type=constants.DT_PLAIN),
|
|
1532 |
objects.Disk(dev_type=constants.DT_PLAIN),
|
|
1533 |
objects.Disk(dev_type=constants.DT_PLAIN),
|
|
1534 | 1534 |
] |
1535 | 1535 |
|
1536 | 1536 |
inst = objects.Instance(name="inst21201", |
... | ... | |
1553 | 1553 |
cfg=_ConfigForDiskWipe(node_uuid)) |
1554 | 1554 |
|
1555 | 1555 |
disks = [ |
1556 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk0",
|
|
1556 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk0",
|
|
1557 | 1557 |
size=100 * 1024), |
1558 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk1",
|
|
1558 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk1",
|
|
1559 | 1559 |
size=500 * 1024), |
1560 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk2", size=256),
|
|
1560 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk2", size=256),
|
|
1561 | 1561 |
] |
1562 | 1562 |
|
1563 | 1563 |
inst = objects.Instance(name="inst562", |
... | ... | |
1599 | 1599 |
|
1600 | 1600 |
def testNormalWipe(self): |
1601 | 1601 |
disks = [ |
1602 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk0", size=1024),
|
|
1603 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk1",
|
|
1602 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk0", size=1024),
|
|
1603 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk1",
|
|
1604 | 1604 |
size=500 * 1024), |
1605 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk2", size=128),
|
|
1606 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk3",
|
|
1605 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk2", size=128),
|
|
1606 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk3",
|
|
1607 | 1607 |
size=constants.MAX_WIPE_CHUNK), |
1608 | 1608 |
] |
1609 | 1609 |
|
... | ... | |
1629 | 1629 |
def testWipeWithStartOffset(self): |
1630 | 1630 |
for start_offset in [0, 280, 8895, 1563204]: |
1631 | 1631 |
disks = [ |
1632 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk0",
|
|
1632 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk0",
|
|
1633 | 1633 |
size=128), |
1634 |
objects.Disk(dev_type=constants.LD_LV, logical_id="disk1",
|
|
1634 |
objects.Disk(dev_type=constants.DT_PLAIN, logical_id="disk1",
|
|
1635 | 1635 |
size=start_offset + (100 * 1024)), |
1636 | 1636 |
] |
1637 | 1637 |
|
b/test/py/ganeti.constants_unittest.py | ||
---|---|---|
80 | 80 |
self.failUnless(constants.OP_PRIO_HIGH > constants.OP_PRIO_HIGHEST) |
81 | 81 |
|
82 | 82 |
def testDiskDefaults(self): |
83 |
self.failUnless(set(constants.DISK_LD_DEFAULTS.keys()) ==
|
|
84 |
constants.LOGICAL_DISK_TYPES)
|
|
83 |
self.failUnless(set(constants.DISK_DT_DEFAULTS.keys()) ==
|
|
84 |
constants.DISK_TEMPLATES)
|
|
85 | 85 |
self.failUnless(set(constants.DISK_DT_DEFAULTS.keys()) == |
86 | 86 |
constants.DISK_TEMPLATES) |
87 | 87 |
|
b/test/py/ganeti.hypervisor.hv_xen_unittest.py | ||
---|---|---|
269 | 269 |
|
270 | 270 |
def testManyDisks(self): |
271 | 271 |
for offset in [0, 1, 10]: |
272 |
disks = [(objects.Disk(dev_type=constants.LD_LV), "/tmp/disk/%s" % idx)
|
|
272 |
disks = [(objects.Disk(dev_type=constants.DT_PLAIN), "/tmp/disk/%s" % idx)
|
|
273 | 273 |
for idx in range(len(hv_xen._DISK_LETTERS) + offset)] |
274 | 274 |
|
275 | 275 |
if offset == 0: |
... | ... | |
288 | 288 |
|
289 | 289 |
def testTwoLvDisksWithMode(self): |
290 | 290 |
disks = [ |
291 |
(objects.Disk(dev_type=constants.LD_LV, mode=constants.DISK_RDWR),
|
|
291 |
(objects.Disk(dev_type=constants.DT_PLAIN, mode=constants.DISK_RDWR),
|
|
292 | 292 |
"/tmp/diskFirst"), |
293 |
(objects.Disk(dev_type=constants.LD_LV, mode=constants.DISK_RDONLY),
|
|
293 |
(objects.Disk(dev_type=constants.DT_PLAIN, mode=constants.DISK_RDONLY),
|
|
294 | 294 |
"/tmp/diskLast"), |
295 | 295 |
] |
296 | 296 |
|
... | ... | |
302 | 302 |
|
303 | 303 |
def testFileDisks(self): |
304 | 304 |
disks = [ |
305 |
(objects.Disk(dev_type=constants.LD_FILE, mode=constants.DISK_RDWR,
|
|
305 |
(objects.Disk(dev_type=constants.DT_FILE, mode=constants.DISK_RDWR,
|
|
306 | 306 |
physical_id=[constants.FD_LOOP]), |
307 | 307 |
"/tmp/diskFirst"), |
308 |
(objects.Disk(dev_type=constants.LD_FILE, mode=constants.DISK_RDONLY,
|
|
308 |
(objects.Disk(dev_type=constants.DT_FILE, mode=constants.DISK_RDONLY,
|
|
309 | 309 |
physical_id=[constants.FD_BLKTAP]), |
310 | 310 |
"/tmp/diskTwo"), |
311 |
(objects.Disk(dev_type=constants.LD_FILE, mode=constants.DISK_RDWR,
|
|
311 |
(objects.Disk(dev_type=constants.DT_FILE, mode=constants.DISK_RDWR,
|
|
312 | 312 |
physical_id=[constants.FD_LOOP]), |
313 | 313 |
"/tmp/diskThree"), |
314 |
(objects.Disk(dev_type=constants.LD_FILE, mode=constants.DISK_RDWR,
|
|
314 |
(objects.Disk(dev_type=constants.DT_FILE, mode=constants.DISK_RDWR,
|
|
315 | 315 |
physical_id=[constants.FD_BLKTAP]), |
316 | 316 |
"/tmp/diskLast"), |
317 | 317 |
] |
... | ... | |
326 | 326 |
|
327 | 327 |
def testInvalidFileDisk(self): |
328 | 328 |
disks = [ |
329 |
(objects.Disk(dev_type=constants.LD_FILE, mode=constants.DISK_RDWR,
|
|
329 |
(objects.Disk(dev_type=constants.DT_FILE, mode=constants.DISK_RDWR,
|
|
330 | 330 |
physical_id=["#unknown#"]), |
331 | 331 |
"/tmp/diskinvalid"), |
332 | 332 |
] |
... | ... | |
678 | 678 |
hvp[constants.HV_VNC_PASSWORD_FILE] = self.vncpw_path |
679 | 679 |
|
680 | 680 |
disks = [ |
681 |
(objects.Disk(dev_type=constants.LD_LV, mode=constants.DISK_RDWR),
|
|
681 |
(objects.Disk(dev_type=constants.DT_PLAIN, mode=constants.DISK_RDWR),
|
|
682 | 682 |
utils.PathJoin(self.tmpdir, "disk0")), |
683 |
(objects.Disk(dev_type=constants.LD_LV, mode=constants.DISK_RDONLY),
|
|
683 |
(objects.Disk(dev_type=constants.DT_PLAIN, mode=constants.DISK_RDONLY),
|
|
684 | 684 |
utils.PathJoin(self.tmpdir, "disk1")), |
685 | 685 |
] |
686 | 686 |
|
b/test/py/ganeti.objects_unittest.py | ||
---|---|---|
298 | 298 |
inst = objects.Instance(name="fakeinstplain.example.com", |
299 | 299 |
primary_node="node3.example.com", |
300 | 300 |
disks=[ |
301 |
objects.Disk(dev_type=constants.LD_LV, size=128,
|
|
301 |
objects.Disk(dev_type=constants.DT_PLAIN, size=128,
|
|
302 | 302 |
logical_id=("myxenvg", "disk25494")), |
303 |
objects.Disk(dev_type=constants.LD_LV, size=512,
|
|
303 |
objects.Disk(dev_type=constants.DT_PLAIN, size=512,
|
|
304 | 304 |
logical_id=("myxenvg", "disk29071")), |
305 | 305 |
]) |
306 | 306 |
|
... | ... | |
315 | 315 |
inst = objects.Instance(name="fakeinstdrbd.example.com", |
316 | 316 |
primary_node="node10.example.com", |
317 | 317 |
disks=[ |
318 |
objects.Disk(dev_type=constants.LD_DRBD8, size=786432,
|
|
318 |
objects.Disk(dev_type=constants.DT_DRBD8, size=786432,
|
|
319 | 319 |
logical_id=("node10.example.com", "node15.example.com", |
320 | 320 |
12300, 0, 0, "secret"), |
321 | 321 |
children=[ |
322 |
objects.Disk(dev_type=constants.LD_LV, size=786432,
|
|
322 |
objects.Disk(dev_type=constants.DT_PLAIN, size=786432,
|
|
323 | 323 |
logical_id=("myxenvg", "disk0")), |
324 |
objects.Disk(dev_type=constants.LD_LV, size=128,
|
|
324 |
objects.Disk(dev_type=constants.DT_PLAIN, size=128,
|
|
325 | 325 |
logical_id=("myxenvg", "meta0")) |
326 | 326 |
], |
327 | 327 |
iv_name="disk/0") |
... | ... | |
368 | 368 |
|
369 | 369 |
def testDiskState(self): |
370 | 370 |
node = objects.Node(name="node32087.example.com", disk_state={ |
371 |
constants.LD_LV: {
|
|
371 |
constants.DT_PLAIN: {
|
|
372 | 372 |
"lv32352": objects.NodeDiskState(total=128), |
373 | 373 |
"lv2082": objects.NodeDiskState(total=512), |
374 | 374 |
}, |
... | ... | |
381 | 381 |
|
382 | 382 |
self.assertEqual(node2.name, "node32087.example.com") |
383 | 383 |
self.assertEqual(frozenset(node2.disk_state), frozenset([ |
384 |
constants.LD_LV,
|
|
384 |
constants.DT_PLAIN,
|
|
385 | 385 |
])) |
386 |
self.assertEqual(frozenset(node2.disk_state[constants.LD_LV]), frozenset([ |
|
387 |
"lv32352", |
|
388 |
"lv2082", |
|
389 |
])) |
|
390 |
self.assertEqual(node2.disk_state[constants.LD_LV]["lv2082"].total, 512) |
|
391 |
self.assertEqual(node2.disk_state[constants.LD_LV]["lv32352"].total, 128) |
|
386 |
self.assertEqual(frozenset(node2.disk_state[constants.DT_PLAIN]), |
|
387 |
frozenset(["lv32352", "lv2082"])) |
|
388 |
self.assertEqual(node2.disk_state[constants.DT_PLAIN]["lv2082"].total, 512) |
|
389 |
self.assertEqual(node2.disk_state[constants.DT_PLAIN]["lv32352"].total, 128) |
|
392 | 390 |
|
393 | 391 |
def testFilterEsNdp(self): |
394 | 392 |
node1 = objects.Node(name="node11673.example.com", ndparams={ |
b/test/py/ganeti.rpc_unittest.py | ||
---|---|---|
810 | 810 |
], |
811 | 811 |
disk_template=constants.DT_PLAIN, |
812 | 812 |
disks=[ |
813 |
objects.Disk(dev_type=constants.LD_LV, size=4096,
|
|
813 |
objects.Disk(dev_type=constants.DT_PLAIN, size=4096,
|
|
814 | 814 |
logical_id=("vg", "disk6120")), |
815 |
objects.Disk(dev_type=constants.LD_LV, size=1024,
|
|
815 |
objects.Disk(dev_type=constants.DT_PLAIN, size=1024,
|
|
816 | 816 |
logical_id=("vg", "disk8508")), |
817 | 817 |
]) |
818 | 818 |
inst.UpgradeConfig() |
... | ... | |
882 | 882 |
constants.HV_BOOT_ORDER: "xyz", |
883 | 883 |
}) |
884 | 884 |
self.assertEqual(result["disks"], [{ |
885 |
"dev_type": constants.LD_LV,
|
|
885 |
"dev_type": constants.DT_PLAIN,
|
|
886 | 886 |
"size": 4096, |
887 | 887 |
"logical_id": ("vg", "disk6120"), |
888 | 888 |
"params": constants.DISK_DT_DEFAULTS[inst.disk_template], |
889 | 889 |
}, { |
890 |
"dev_type": constants.LD_LV,
|
|
890 |
"dev_type": constants.DT_PLAIN,
|
|
891 | 891 |
"size": 1024, |
892 | 892 |
"logical_id": ("vg", "disk8508"), |
893 | 893 |
"params": constants.DISK_DT_DEFAULTS[inst.disk_template], |
b/tools/cfgupgrade12 | ||
---|---|---|
263 | 263 |
""" |
264 | 264 |
if "mode" not in disk: |
265 | 265 |
disk["mode"] = constants.DISK_RDWR |
266 |
if disk["dev_type"] == constants.LD_DRBD8:
|
|
266 |
if disk["dev_type"] == constants.DT_DRBD8:
|
|
267 | 267 |
old_lid = disk["logical_id"] |
268 | 268 |
for node in old_lid[:2]: |
269 | 269 |
if node not in drbd_minors: |
b/tools/sanitize-config | ||
---|---|---|
199 | 199 |
for child in disk["children"]: |
200 | 200 |
helper(child) |
201 | 201 |
|
202 |
if disk["dev_type"] == constants.LD_DRBD8:
|
|
202 |
if disk["dev_type"] == constants.DT_DRBD8:
|
|
203 | 203 |
if "physical_id" in disk: |
204 | 204 |
del disk["physical_id"] |
205 | 205 |
|
206 |
if disk["dev_type"] == constants.LD_LV and opts.sanitize_lvs:
|
|
206 |
if disk["dev_type"] == constants.DT_PLAIN and opts.sanitize_lvs:
|
|
207 | 207 |
disk["logical_id"][1] = _Get(disk["logical_id"][1]) |
208 | 208 |
disk["physical_id"][1] = disk["logical_id"][1] |
209 | 209 |
|
... | ... | |
223 | 223 |
RandomizeDiskSecrets(child) |
224 | 224 |
|
225 | 225 |
# only disk type to contain secrets is the drbd one |
226 |
if disk["dev_type"] == constants.LD_DRBD8:
|
|
226 |
if disk["dev_type"] == constants.DT_DRBD8:
|
|
227 | 227 |
disk["logical_id"][5] = utils.GenerateSecret() |
228 | 228 |
|
229 | 229 |
|
... | ... | |
236 | 236 |
RenameDiskNodes(child, node_map) |
237 | 237 |
|
238 | 238 |
# only disk type to contain nodes is the drbd one |
239 |
if disk["dev_type"] == constants.LD_DRBD8:
|
|
239 |
if disk["dev_type"] == constants.DT_DRBD8:
|
|
240 | 240 |
lid = disk["logical_id"] |
241 | 241 |
lid[0] = node_map[lid[0]] |
242 | 242 |
lid[1] = node_map[lid[1]] |
Also available in: Unified diff