185 |
185 |
if constants.DT_FILE in enabled_disk_templates:
|
186 |
186 |
cmd.append(
|
187 |
187 |
"--file-storage-dir=%s" %
|
188 |
|
qa_config.get("file-storage-dir", pathutils.DEFAULT_FILE_STORAGE_DIR))
|
|
188 |
qa_config.get("default-file-storage-dir",
|
|
189 |
pathutils.DEFAULT_FILE_STORAGE_DIR))
|
189 |
190 |
|
190 |
191 |
for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count",
|
191 |
192 |
"nic-count"):
|
... | ... | |
439 |
440 |
AssertCommand(["gnt-cluster", "modify", "-D", param], fail=True)
|
440 |
441 |
|
441 |
442 |
|
|
443 |
def _GetOtherEnabledDiskTemplate(undesired_disk_templates,
|
|
444 |
enabled_disk_templates):
|
|
445 |
"""Returns one template that is not in the undesired set.
|
|
446 |
|
|
447 |
@type undesired_disk_templates: list of string
|
|
448 |
@param undesired_disk_templates: a list of disk templates that we want to
|
|
449 |
exclude when drawing one disk template from the list of enabled
|
|
450 |
disk templates
|
|
451 |
@type enabled_disk_templates: list of string
|
|
452 |
@param enabled_disk_templates: list of enabled disk templates (in QA)
|
|
453 |
|
|
454 |
"""
|
|
455 |
desired_templates = list(set(enabled_disk_templates)
|
|
456 |
- set(undesired_disk_templates))
|
|
457 |
if desired_templates:
|
|
458 |
template = desired_templates[0]
|
|
459 |
else:
|
|
460 |
# If no desired disk template is available for QA, choose 'diskless' and
|
|
461 |
# hope for the best.
|
|
462 |
template = constants.ST_DISKLESS
|
|
463 |
|
|
464 |
return template
|
|
465 |
|
|
466 |
|
|
467 |
def TestClusterModifyFileBasedStorageDir(
|
|
468 |
file_disk_template, dir_config_key, default_dir, option_name):
|
|
469 |
"""Tests gnt-cluster modify wrt to file-based directory options.
|
|
470 |
|
|
471 |
@type file_disk_template: string
|
|
472 |
@param file_disk_template: file-based disk template
|
|
473 |
@type dir_config_key: string
|
|
474 |
@param dir_config_key: key for the QA config to retrieve the default
|
|
475 |
directory value
|
|
476 |
@type default_dir: string
|
|
477 |
@param default_dir: default directory, if the QA config does not specify
|
|
478 |
it
|
|
479 |
@type option_name: string
|
|
480 |
@param option_name: name of the option of 'gnt-cluster modify' to
|
|
481 |
change the directory
|
|
482 |
|
|
483 |
"""
|
|
484 |
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
|
|
485 |
assert file_disk_template in [constants.DT_FILE, constants.DT_SHARED_FILE]
|
|
486 |
if not qa_config.IsTemplateSupported(file_disk_template):
|
|
487 |
return
|
|
488 |
|
|
489 |
# Get some non-file-based disk template to disable file storage
|
|
490 |
other_disk_template = _GetOtherEnabledDiskTemplate(
|
|
491 |
utils.storage.GetDiskTemplatesOfStorageType(constants.ST_FILE),
|
|
492 |
enabled_disk_templates)
|
|
493 |
|
|
494 |
file_storage_dir = qa_config.get(dir_config_key, default_dir)
|
|
495 |
invalid_file_storage_dir = "/boot/"
|
|
496 |
|
|
497 |
for fail, cmd in [
|
|
498 |
(False, ["gnt-cluster", "modify",
|
|
499 |
"--enabled-disk-templates=%s" % file_disk_template]),
|
|
500 |
(False, ["gnt-cluster", "modify",
|
|
501 |
"--%s=%s" % (option_name, file_storage_dir)]),
|
|
502 |
(False, ["gnt-cluster", "modify",
|
|
503 |
"--%s=%s" % (option_name, invalid_file_storage_dir)]),
|
|
504 |
# file storage dir is set to an inacceptable path, thus verify
|
|
505 |
# should fail
|
|
506 |
(True, ["gnt-cluster", "verify"]),
|
|
507 |
# unsetting the storage dir while file storage is enabled
|
|
508 |
# should fail
|
|
509 |
(True, ["gnt-cluster", "modify",
|
|
510 |
"--%s=" % option_name]),
|
|
511 |
(False, ["gnt-cluster", "modify",
|
|
512 |
"--%s=%s" % (option_name, file_storage_dir)]),
|
|
513 |
(False, ["gnt-cluster", "modify",
|
|
514 |
"--enabled-disk-templates=%s" % other_disk_template]),
|
|
515 |
(False, ["gnt-cluster", "modify",
|
|
516 |
"--%s=%s" % (option_name, invalid_file_storage_dir)]),
|
|
517 |
# file storage is set to an inacceptable path, but file storage
|
|
518 |
# is disabled, thus verify should not fail
|
|
519 |
(False, ["gnt-cluster", "verify"]),
|
|
520 |
# unsetting the file storage dir while file storage is not enabled
|
|
521 |
# should be fine
|
|
522 |
(False, ["gnt-cluster", "modify",
|
|
523 |
"--%s=" % option_name]),
|
|
524 |
# resetting everything to sane values
|
|
525 |
(False, ["gnt-cluster", "modify",
|
|
526 |
"--%s=%s" % (option_name, file_storage_dir),
|
|
527 |
"--enabled-disk-templates=%s" % ",".join(enabled_disk_templates)])
|
|
528 |
]:
|
|
529 |
AssertCommand(cmd, fail=fail)
|
|
530 |
|
|
531 |
|
|
532 |
def TestClusterModifyFileStorageDir():
|
|
533 |
"""gnt-cluster modify --file-storage-dir=..."""
|
|
534 |
TestClusterModifyFileBasedStorageDir(
|
|
535 |
constants.DT_FILE, "default-file-storage-dir",
|
|
536 |
pathutils.DEFAULT_FILE_STORAGE_DIR,
|
|
537 |
"file-storage-dir")
|
|
538 |
|
|
539 |
|
|
540 |
def TestClusterModifySharedFileStorageDir():
|
|
541 |
"""gnt-cluster modify --shared-file-storage-dir=..."""
|
|
542 |
TestClusterModifyFileBasedStorageDir(
|
|
543 |
constants.DT_SHARED_FILE, "default-shared-file-storage-dir",
|
|
544 |
pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR,
|
|
545 |
"shared-file-storage-dir")
|
|
546 |
|
|
547 |
|
442 |
548 |
def TestClusterModifyDiskTemplates():
|
443 |
549 |
"""gnt-cluster modify --enabled-disk-templates=..."""
|
444 |
550 |
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
|
... | ... | |
530 |
636 |
return
|
531 |
637 |
|
532 |
638 |
# determine an LVM and a non-LVM disk template for the tests
|
533 |
|
non_lvm_templates = list(set(enabled_disk_templates)
|
534 |
|
- set(utils.GetLvmDiskTemplates()))
|
|
639 |
non_lvm_template = _GetOtherEnabledDiskTemplate(utils.GetLvmDiskTemplates(),
|
|
640 |
enabled_disk_templates)
|
535 |
641 |
lvm_template = list(set(enabled_disk_templates)
|
536 |
642 |
.intersection(set(utils.GetLvmDiskTemplates())))[0]
|
537 |
|
non_lvm_template = None
|
538 |
|
if non_lvm_templates:
|
539 |
|
non_lvm_template = non_lvm_templates[0]
|
540 |
|
else:
|
541 |
|
# If no non-lvm disk template is available for QA, choose 'diskless' and
|
542 |
|
# hope for the best.
|
543 |
|
non_lvm_template = constants.ST_DISKLESS
|
544 |
643 |
|
545 |
644 |
vgname = qa_config.get("vg-name", constants.DEFAULT_VG)
|
546 |
645 |
|