Revision 912737ba qa/qa_cluster.py
b/qa/qa_cluster.py | ||
---|---|---|
192 | 192 |
if master.secondary: |
193 | 193 |
cmd.append("--secondary-ip=%s" % master.secondary) |
194 | 194 |
|
195 |
vgname = qa_config.get("vg-name", None) |
|
196 |
if vgname: |
|
197 |
cmd.append("--vg-name=%s" % vgname) |
|
195 |
if utils.IsLvmEnabled(qa_config.GetEnabledDiskTemplates()): |
|
196 |
vgname = qa_config.get("vg-name", constants.DEFAULT_VG) |
|
197 |
if vgname: |
|
198 |
cmd.append("--vg-name=%s" % vgname) |
|
199 |
else: |
|
200 |
raise qa_error.Error("Please specify a volume group if you enable" |
|
201 |
" lvm-based disk templates in the QA.") |
|
198 | 202 |
|
199 | 203 |
master_netdev = qa_config.get("master-netdev", None) |
200 | 204 |
if master_netdev: |
... | ... | |
398 | 402 |
|
399 | 403 |
_TestClusterModifyDiskTemplatesArguments(default_disk_template, |
400 | 404 |
enabled_disk_templates) |
405 |
_TestClusterModifyDiskTemplatesVgName(enabled_disk_templates) |
|
401 | 406 |
|
402 | 407 |
_RestoreEnabledDiskTemplates() |
403 | 408 |
nodes = qa_config.AcquireManyNodes(2) |
... | ... | |
420 | 425 |
other tests. |
421 | 426 |
|
422 | 427 |
""" |
428 |
vgname = qa_config.get("vg-name", constants.DEFAULT_VG) |
|
423 | 429 |
AssertCommand( |
424 | 430 |
["gnt-cluster", "modify", |
425 |
"--enabled-disk-template=%s" % |
|
426 |
",".join(qa_config.GetEnabledDiskTemplates())], |
|
431 |
"--enabled-disk-templates=%s" % |
|
432 |
",".join(qa_config.GetEnabledDiskTemplates()), |
|
433 |
"--vg-name=%s" % vgname], |
|
427 | 434 |
fail=False) |
428 | 435 |
|
429 | 436 |
|
... | ... | |
434 | 441 |
of instances. |
435 | 442 |
|
436 | 443 |
""" |
437 |
AssertCommand( |
|
438 |
["gnt-cluster", "modify", |
|
439 |
"--enabled-disk-template=%s" % |
|
440 |
",".join(enabled_disk_templates)], |
|
441 |
fail=False) |
|
444 |
_RestoreEnabledDiskTemplates() |
|
442 | 445 |
|
443 | 446 |
# bogus templates |
444 | 447 |
AssertCommand(["gnt-cluster", "modify", |
... | ... | |
452 | 455 |
(default_disk_template, default_disk_template)], |
453 | 456 |
fail=False) |
454 | 457 |
|
458 |
# interaction with --drbd-usermode-helper option |
|
459 |
drbd_usermode_helper = qa_config.get("drbd-usermode-helper", None) |
|
460 |
if not drbd_usermode_helper: |
|
461 |
drbd_usermode_helper = "/bin/true" |
|
462 |
# specifying a helper when drbd gets disabled |
|
463 |
AssertCommand(["gnt-cluster", "modify", |
|
464 |
"--drbd-usermode-helper=%s" % drbd_usermode_helper, |
|
465 |
"--enabled-disk-templates=%s" % constants.DT_DISKLESS], |
|
466 |
fail=False) |
|
467 |
if constants.DT_DRBD8 in enabled_disk_templates: |
|
468 |
# specifying a vg name when lvm is enabled |
|
469 |
AssertCommand(["gnt-cluster", "modify", |
|
470 |
"--drbd-usermode-helper=%s" % drbd_usermode_helper, |
|
471 |
"--enabled-disk-templates=%s" % |
|
472 |
",".join(enabled_disk_templates)], |
|
473 |
fail=False) |
|
474 |
|
|
475 |
|
|
476 |
def _TestClusterModifyDiskTemplatesVgName(enabled_disk_templates): |
|
477 |
"""Tests argument handling of 'gnt-cluster modify' with respect to |
|
478 |
the parameter '--enabled-disk-templates' and '--vg-name'. This test is |
|
479 |
independent of instances. |
|
480 |
|
|
481 |
""" |
|
482 |
if not utils.IsLvmEnabled(enabled_disk_templates): |
|
483 |
# These tests only make sense if lvm is enabled for QA |
|
484 |
return |
|
485 |
|
|
486 |
# determine an LVM and a non-LVM disk template for the tests |
|
487 |
non_lvm_templates = list(set(enabled_disk_templates) |
|
488 |
- set(utils.GetLvmDiskTemplates())) |
|
489 |
lvm_template = list(set(enabled_disk_templates) |
|
490 |
.intersection(set(utils.GetLvmDiskTemplates())))[0] |
|
491 |
non_lvm_template = None |
|
492 |
if non_lvm_templates: |
|
493 |
non_lvm_template = non_lvm_templates[0] |
|
494 |
else: |
|
495 |
# If no non-lvm disk template is available for QA, choose 'diskless' and |
|
496 |
# hope for the best. |
|
497 |
non_lvm_template = constants.ST_DISKLESS |
|
498 |
|
|
499 |
vgname = qa_config.get("vg-name", constants.DEFAULT_VG) |
|
500 |
|
|
501 |
# Clean start: unset volume group name, disable lvm storage |
|
502 |
AssertCommand( |
|
503 |
["gnt-cluster", "modify", |
|
504 |
"--enabled-disk-templates=%s" % non_lvm_template, |
|
505 |
"--vg-name="], |
|
506 |
fail=False) |
|
507 |
|
|
508 |
# Try to enable lvm, when no volume group is given |
|
509 |
AssertCommand( |
|
510 |
["gnt-cluster", "modify", |
|
511 |
"--enabled-disk-templates=%s" % lvm_template], |
|
512 |
fail=True) |
|
513 |
|
|
514 |
# Set volume group, with lvm still disabled: just a warning |
|
515 |
AssertCommand(["gnt-cluster", "modify", "--vg-name=%s" % vgname], fail=False) |
|
516 |
|
|
517 |
# Try unsetting vg name and enabling lvm at the same time |
|
518 |
AssertCommand( |
|
519 |
["gnt-cluster", "modify", |
|
520 |
"--enabled-disk-templates=%s" % lvm_template, |
|
521 |
"--vg-name="], |
|
522 |
fail=True) |
|
523 |
|
|
524 |
# Enable lvm with vg name present |
|
525 |
AssertCommand( |
|
526 |
["gnt-cluster", "modify", |
|
527 |
"--enabled-disk-templates=%s" % lvm_template], |
|
528 |
fail=False) |
|
529 |
|
|
530 |
# Try unsetting vg name with lvm still enabled |
|
531 |
AssertCommand(["gnt-cluster", "modify", "--vg-name="], fail=True) |
|
532 |
|
|
533 |
# Disable lvm with vg name still set |
|
534 |
AssertCommand( |
|
535 |
["gnt-cluster", "modify", "--enabled-disk-templates=%s" % non_lvm_template], |
|
536 |
fail=False) |
|
537 |
|
|
538 |
# Try unsetting vg name with lvm disabled |
|
539 |
AssertCommand(["gnt-cluster", "modify", "--vg-name="], fail=False) |
|
540 |
|
|
541 |
# Set vg name and enable lvm at the same time |
|
542 |
AssertCommand( |
|
543 |
["gnt-cluster", "modify", |
|
544 |
"--enabled-disk-templates=%s" % lvm_template, |
|
545 |
"--vg-name=%s" % vgname], |
|
546 |
fail=False) |
|
547 |
|
|
548 |
# Unset vg name and disable lvm at the same time |
|
549 |
AssertCommand( |
|
550 |
["gnt-cluster", "modify", |
|
551 |
"--enabled-disk-templates=%s" % non_lvm_template, |
|
552 |
"--vg-name="], |
|
553 |
fail=False) |
|
554 |
|
|
555 |
_RestoreEnabledDiskTemplates() |
|
556 |
|
|
455 | 557 |
|
456 | 558 |
def _TestClusterModifyUsedDiskTemplate(instance_template, |
457 | 559 |
enabled_disk_templates): |
Also available in: Unified diff