Revision 197b323b lib/opcodes.py
b/lib/opcodes.py | ||
---|---|---|
45 | 45 |
# Common opcode attributes |
46 | 46 |
|
47 | 47 |
#: output fields for a query operation |
48 |
_POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)) |
|
48 |
_POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), |
|
49 |
None) |
|
49 | 50 |
|
50 | 51 |
#: the shutdown timeout |
51 | 52 |
_PShutdownTimeout = ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, |
52 |
ht.TPositiveInt) |
|
53 |
ht.TPositiveInt, None)
|
|
53 | 54 |
|
54 | 55 |
#: the force parameter |
55 |
_PForce = ("force", False, ht.TBool) |
|
56 |
_PForce = ("force", False, ht.TBool, None)
|
|
56 | 57 |
|
57 | 58 |
#: a required instance name (for single-instance LUs) |
58 |
_PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString) |
|
59 |
_PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString, None)
|
|
59 | 60 |
|
60 | 61 |
#: Whether to ignore offline nodes |
61 |
_PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool) |
|
62 |
_PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool, None)
|
|
62 | 63 |
|
63 | 64 |
#: a required node name (for single-node LUs) |
64 |
_PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString) |
|
65 |
_PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString, None)
|
|
65 | 66 |
|
66 | 67 |
#: a required node group name (for single-group LUs) |
67 |
_PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString) |
|
68 |
_PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString, None)
|
|
68 | 69 |
|
69 | 70 |
#: Migration type (live/non-live) |
70 | 71 |
_PMigrationMode = ("mode", None, |
71 |
ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES))) |
|
72 |
ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES)), |
|
73 |
None) |
|
72 | 74 |
|
73 | 75 |
#: Obsolete 'live' migration mode (boolean) |
74 |
_PMigrationLive = ("live", None, ht.TMaybeBool) |
|
76 |
_PMigrationLive = ("live", None, ht.TMaybeBool, None)
|
|
75 | 77 |
|
76 | 78 |
#: Tag type |
77 |
_PTagKind = ("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES)) |
|
79 |
_PTagKind = ("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES), None)
|
|
78 | 80 |
|
79 | 81 |
#: List of tag strings |
80 |
_PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)) |
|
82 |
_PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None)
|
|
81 | 83 |
|
82 | 84 |
#: OP_ID conversion regular expression |
83 | 85 |
_OPID_RE = re.compile("([a-z])([A-Z])") |
... | ... | |
151 | 153 |
|
152 | 154 |
|
153 | 155 |
#: Storage type parameter |
154 |
_PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType) |
|
156 |
_PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType, None)
|
|
155 | 157 |
|
156 | 158 |
|
157 | 159 |
class _AutoOpParamSlots(type): |
... | ... | |
178 | 180 |
params = attrs.setdefault("OP_PARAMS", []) |
179 | 181 |
|
180 | 182 |
# Use parameter names as slots |
181 |
slots = [pname for (pname, _, _) in params] |
|
183 |
slots = [pname for (pname, _, _, _) in params]
|
|
182 | 184 |
|
183 | 185 |
assert "OP_DSC_FIELD" not in attrs or attrs["OP_DSC_FIELD"] in slots, \ |
184 | 186 |
"Class '%s' uses unknown field in OP_DSC_FIELD" % name |
... | ... | |
281 | 283 |
requirements |
282 | 284 |
|
283 | 285 |
""" |
284 |
for (attr_name, default, test) in self.GetAllParams(): |
|
286 |
for (attr_name, default, test, _) in self.GetAllParams():
|
|
285 | 287 |
assert test == ht.NoType or callable(test) |
286 | 288 |
|
287 | 289 |
if not hasattr(self, attr_name): |
... | ... | |
334 | 336 |
# as OP_ID is dynamically defined |
335 | 337 |
WITH_LU = True |
336 | 338 |
OP_PARAMS = [ |
337 |
("dry_run", None, ht.TMaybeBool), |
|
338 |
("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
|
339 |
("dry_run", None, ht.TMaybeBool, None),
|
|
340 |
("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
|
|
339 | 341 |
("priority", constants.OP_PRIO_DEFAULT, |
340 |
ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID)), |
|
342 |
ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), None),
|
|
341 | 343 |
] |
342 | 344 |
|
343 | 345 |
def __getstate__(self): |
... | ... | |
442 | 444 |
""" |
443 | 445 |
OP_PARAMS = [ |
444 | 446 |
("skip_checks", ht.EmptyList, |
445 |
ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS))), |
|
446 |
("verbose", False, ht.TBool), |
|
447 |
("error_codes", False, ht.TBool), |
|
448 |
("debug_simulate_errors", False, ht.TBool), |
|
447 |
ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS)), None),
|
|
448 |
("verbose", False, ht.TBool, None),
|
|
449 |
("error_codes", False, ht.TBool, None),
|
|
450 |
("debug_simulate_errors", False, ht.TBool, None),
|
|
449 | 451 |
] |
450 | 452 |
|
451 | 453 |
|
... | ... | |
489 | 491 |
|
490 | 492 |
""" |
491 | 493 |
OP_PARAMS = [ |
492 |
("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
494 |
("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
493 | 495 |
] |
494 | 496 |
|
495 | 497 |
|
... | ... | |
511 | 513 |
""" |
512 | 514 |
OP_DSC_FIELD = "name" |
513 | 515 |
OP_PARAMS = [ |
514 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
516 |
("name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
515 | 517 |
] |
516 | 518 |
|
517 | 519 |
|
... | ... | |
523 | 525 |
|
524 | 526 |
""" |
525 | 527 |
OP_PARAMS = [ |
526 |
("vg_name", None, ht.TMaybeString), |
|
528 |
("vg_name", None, ht.TMaybeString, None),
|
|
527 | 529 |
("enabled_hypervisors", None, |
528 | 530 |
ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue), |
529 |
ht.TNone)), |
|
531 |
ht.TNone), None),
|
|
530 | 532 |
("hvparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
531 |
ht.TNone)), |
|
532 |
("beparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
533 |
ht.TNone), None),
|
|
534 |
("beparams", None, ht.TOr(ht.TDict, ht.TNone), None),
|
|
533 | 535 |
("os_hvp", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
534 |
ht.TNone)), |
|
536 |
ht.TNone), None),
|
|
535 | 537 |
("osparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
536 |
ht.TNone)), |
|
537 |
("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone)), |
|
538 |
("uid_pool", None, ht.NoType), |
|
539 |
("add_uids", None, ht.NoType), |
|
540 |
("remove_uids", None, ht.NoType), |
|
541 |
("maintain_node_health", None, ht.TMaybeBool), |
|
542 |
("prealloc_wipe_disks", None, ht.TMaybeBool), |
|
543 |
("nicparams", None, ht.TMaybeDict), |
|
544 |
("ndparams", None, ht.TMaybeDict), |
|
545 |
("drbd_helper", None, ht.TOr(ht.TString, ht.TNone)), |
|
546 |
("default_iallocator", None, ht.TOr(ht.TString, ht.TNone)), |
|
547 |
("master_netdev", None, ht.TOr(ht.TString, ht.TNone)), |
|
548 |
("reserved_lvs", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone)), |
|
549 |
("hidden_os", None, _TestClusterOsList), |
|
550 |
("blacklisted_os", None, _TestClusterOsList), |
|
538 |
ht.TNone), None), |
|
539 |
("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone), |
|
540 |
None), |
|
541 |
("uid_pool", None, ht.NoType, None), |
|
542 |
("add_uids", None, ht.NoType, None), |
|
543 |
("remove_uids", None, ht.NoType, None), |
|
544 |
("maintain_node_health", None, ht.TMaybeBool, None), |
|
545 |
("prealloc_wipe_disks", None, ht.TMaybeBool, None), |
|
546 |
("nicparams", None, ht.TMaybeDict, None), |
|
547 |
("ndparams", None, ht.TMaybeDict, None), |
|
548 |
("drbd_helper", None, ht.TOr(ht.TString, ht.TNone), None), |
|
549 |
("default_iallocator", None, ht.TOr(ht.TString, ht.TNone), None), |
|
550 |
("master_netdev", None, ht.TOr(ht.TString, ht.TNone), None), |
|
551 |
("reserved_lvs", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone), None), |
|
552 |
("hidden_os", None, _TestClusterOsList, None), |
|
553 |
("blacklisted_os", None, _TestClusterOsList, None), |
|
551 | 554 |
] |
552 | 555 |
|
553 | 556 |
|
... | ... | |
566 | 569 |
|
567 | 570 |
""" |
568 | 571 |
OP_PARAMS = [ |
569 |
("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY)), |
|
570 |
("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
572 |
("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY), None),
|
|
573 |
("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None),
|
|
571 | 574 |
("filter", None, ht.TOr(ht.TNone, |
572 |
ht.TListOf(ht.TOr(ht.TNonEmptyString, ht.TList)))), |
|
575 |
ht.TListOf(ht.TOr(ht.TNonEmptyString, ht.TList))), None),
|
|
573 | 576 |
] |
574 | 577 |
|
575 | 578 |
|
... | ... | |
581 | 584 |
|
582 | 585 |
""" |
583 | 586 |
OP_PARAMS = [ |
584 |
("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY)), |
|
585 |
("fields", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))), |
|
587 |
("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY), None),
|
|
588 |
("fields", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)), None),
|
|
586 | 589 |
] |
587 | 590 |
|
588 | 591 |
|
589 | 592 |
class OpOobCommand(OpCode): |
590 | 593 |
"""Interact with OOB.""" |
591 | 594 |
OP_PARAMS = [ |
592 |
("node_names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
593 |
("command", None, ht.TElemOf(constants.OOB_COMMANDS)), |
|
594 |
("timeout", constants.OOB_TIMEOUT, ht.TInt), |
|
595 |
("ignore_status", False, ht.TBool), |
|
596 |
("force_master", False, ht.TBool), |
|
595 |
("node_names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
596 |
("command", None, ht.TElemOf(constants.OOB_COMMANDS), None),
|
|
597 |
("timeout", constants.OOB_TIMEOUT, ht.TInt, None),
|
|
598 |
("ignore_status", False, ht.TBool, None),
|
|
599 |
("force_master", False, ht.TBool, None),
|
|
597 | 600 |
] |
598 | 601 |
|
599 | 602 |
|
... | ... | |
644 | 647 |
OP_DSC_FIELD = "node_name" |
645 | 648 |
OP_PARAMS = [ |
646 | 649 |
_PNodeName, |
647 |
("primary_ip", None, ht.NoType), |
|
648 |
("secondary_ip", None, ht.TMaybeString), |
|
649 |
("readd", False, ht.TBool), |
|
650 |
("group", None, ht.TMaybeString), |
|
651 |
("master_capable", None, ht.TMaybeBool), |
|
652 |
("vm_capable", None, ht.TMaybeBool), |
|
653 |
("ndparams", None, ht.TMaybeDict), |
|
650 |
("primary_ip", None, ht.NoType, None),
|
|
651 |
("secondary_ip", None, ht.TMaybeString, None),
|
|
652 |
("readd", False, ht.TBool, None),
|
|
653 |
("group", None, ht.TMaybeString, None),
|
|
654 |
("master_capable", None, ht.TMaybeBool, None),
|
|
655 |
("vm_capable", None, ht.TMaybeBool, None),
|
|
656 |
("ndparams", None, ht.TMaybeDict, None),
|
|
654 | 657 |
] |
655 | 658 |
|
656 | 659 |
|
... | ... | |
658 | 661 |
"""Compute the list of nodes.""" |
659 | 662 |
OP_PARAMS = [ |
660 | 663 |
_POutputFields, |
661 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
662 |
("use_locking", False, ht.TBool), |
|
664 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
665 |
("use_locking", False, ht.TBool, None),
|
|
663 | 666 |
] |
664 | 667 |
|
665 | 668 |
|
... | ... | |
667 | 670 |
"""Get list of volumes on node.""" |
668 | 671 |
OP_PARAMS = [ |
669 | 672 |
_POutputFields, |
670 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
673 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
671 | 674 |
] |
672 | 675 |
|
673 | 676 |
|
... | ... | |
676 | 679 |
OP_PARAMS = [ |
677 | 680 |
_POutputFields, |
678 | 681 |
_PStorageType, |
679 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
680 |
("name", None, ht.TMaybeString), |
|
682 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
683 |
("name", None, ht.TMaybeString, None),
|
|
681 | 684 |
] |
682 | 685 |
|
683 | 686 |
|
... | ... | |
686 | 689 |
OP_PARAMS = [ |
687 | 690 |
_PNodeName, |
688 | 691 |
_PStorageType, |
689 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
690 |
("changes", ht.NoDefault, ht.TDict), |
|
692 |
("name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
693 |
("changes", ht.NoDefault, ht.TDict, None),
|
|
691 | 694 |
] |
692 | 695 |
|
693 | 696 |
|
... | ... | |
697 | 700 |
OP_PARAMS = [ |
698 | 701 |
_PNodeName, |
699 | 702 |
_PStorageType, |
700 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
701 |
("ignore_consistency", False, ht.TBool), |
|
703 |
("name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
704 |
("ignore_consistency", False, ht.TBool, None),
|
|
702 | 705 |
] |
703 | 706 |
|
704 | 707 |
|
... | ... | |
708 | 711 |
OP_PARAMS = [ |
709 | 712 |
_PNodeName, |
710 | 713 |
_PForce, |
711 |
("master_candidate", None, ht.TMaybeBool), |
|
712 |
("offline", None, ht.TMaybeBool), |
|
713 |
("drained", None, ht.TMaybeBool), |
|
714 |
("auto_promote", False, ht.TBool), |
|
715 |
("master_capable", None, ht.TMaybeBool), |
|
716 |
("vm_capable", None, ht.TMaybeBool), |
|
717 |
("secondary_ip", None, ht.TMaybeString), |
|
718 |
("ndparams", None, ht.TMaybeDict), |
|
719 |
("powered", None, ht.TMaybeBool), |
|
714 |
("master_candidate", None, ht.TMaybeBool, None),
|
|
715 |
("offline", None, ht.TMaybeBool, None),
|
|
716 |
("drained", None, ht.TMaybeBool, None),
|
|
717 |
("auto_promote", False, ht.TBool, None),
|
|
718 |
("master_capable", None, ht.TMaybeBool, None),
|
|
719 |
("vm_capable", None, ht.TMaybeBool, None),
|
|
720 |
("secondary_ip", None, ht.TMaybeString, None),
|
|
721 |
("ndparams", None, ht.TMaybeDict, None),
|
|
722 |
("powered", None, ht.TMaybeBool, None),
|
|
720 | 723 |
] |
721 | 724 |
|
722 | 725 |
|
... | ... | |
743 | 746 |
"""Compute the evacuation strategy for a list of nodes.""" |
744 | 747 |
OP_DSC_FIELD = "nodes" |
745 | 748 |
OP_PARAMS = [ |
746 |
("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
747 |
("remote_node", None, ht.TMaybeString), |
|
748 |
("iallocator", None, ht.TMaybeString), |
|
749 |
("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None),
|
|
750 |
("remote_node", None, ht.TMaybeString, None),
|
|
751 |
("iallocator", None, ht.TMaybeString, None),
|
|
749 | 752 |
] |
750 | 753 |
|
751 | 754 |
|
... | ... | |
766 | 769 |
OP_DSC_FIELD = "instance_name" |
767 | 770 |
OP_PARAMS = [ |
768 | 771 |
_PInstanceName, |
769 |
("beparams", ht.EmptyDict, ht.TDict), |
|
770 |
("disks", ht.NoDefault, ht.TListOf(ht.TDict)), |
|
771 |
("disk_template", ht.NoDefault, _CheckDiskTemplate), |
|
772 |
("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER))), |
|
773 |
("file_storage_dir", None, ht.TMaybeString), |
|
774 |
("force_variant", False, ht.TBool), |
|
775 |
("hvparams", ht.EmptyDict, ht.TDict), |
|
776 |
("hypervisor", None, ht.TMaybeString), |
|
777 |
("iallocator", None, ht.TMaybeString), |
|
778 |
("identify_defaults", False, ht.TBool), |
|
779 |
("ip_check", True, ht.TBool), |
|
780 |
("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES)), |
|
781 |
("name_check", True, ht.TBool), |
|
782 |
("nics", ht.NoDefault, ht.TListOf(ht.TDict)), |
|
783 |
("no_install", None, ht.TMaybeBool), |
|
784 |
("osparams", ht.EmptyDict, ht.TDict), |
|
785 |
("os_type", None, ht.TMaybeString), |
|
786 |
("pnode", None, ht.TMaybeString), |
|
787 |
("snode", None, ht.TMaybeString), |
|
788 |
("source_handshake", None, ht.TOr(ht.TList, ht.TNone)), |
|
789 |
("source_instance_name", None, ht.TMaybeString), |
|
772 |
("beparams", ht.EmptyDict, ht.TDict, None),
|
|
773 |
("disks", ht.NoDefault, ht.TListOf(ht.TDict), None),
|
|
774 |
("disk_template", ht.NoDefault, _CheckDiskTemplate, None),
|
|
775 |
("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER)), None),
|
|
776 |
("file_storage_dir", None, ht.TMaybeString, None),
|
|
777 |
("force_variant", False, ht.TBool, None),
|
|
778 |
("hvparams", ht.EmptyDict, ht.TDict, None),
|
|
779 |
("hypervisor", None, ht.TMaybeString, None),
|
|
780 |
("iallocator", None, ht.TMaybeString, None),
|
|
781 |
("identify_defaults", False, ht.TBool, None),
|
|
782 |
("ip_check", True, ht.TBool, None),
|
|
783 |
("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES), None),
|
|
784 |
("name_check", True, ht.TBool, None),
|
|
785 |
("nics", ht.NoDefault, ht.TListOf(ht.TDict), None),
|
|
786 |
("no_install", None, ht.TMaybeBool, None),
|
|
787 |
("osparams", ht.EmptyDict, ht.TDict, None),
|
|
788 |
("os_type", None, ht.TMaybeString, None),
|
|
789 |
("pnode", None, ht.TMaybeString, None),
|
|
790 |
("snode", None, ht.TMaybeString, None),
|
|
791 |
("source_handshake", None, ht.TOr(ht.TList, ht.TNone), None),
|
|
792 |
("source_instance_name", None, ht.TMaybeString, None),
|
|
790 | 793 |
("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, |
791 |
ht.TPositiveInt), |
|
792 |
("source_x509_ca", None, ht.TMaybeString), |
|
793 |
("src_node", None, ht.TMaybeString), |
|
794 |
("src_path", None, ht.TMaybeString), |
|
795 |
("start", True, ht.TBool), |
|
796 |
("wait_for_sync", True, ht.TBool), |
|
794 |
ht.TPositiveInt, None),
|
|
795 |
("source_x509_ca", None, ht.TMaybeString, None),
|
|
796 |
("src_node", None, ht.TMaybeString, None),
|
|
797 |
("src_path", None, ht.TMaybeString, None),
|
|
798 |
("start", True, ht.TBool, None),
|
|
799 |
("wait_for_sync", True, ht.TBool, None),
|
|
797 | 800 |
] |
798 | 801 |
|
799 | 802 |
|
... | ... | |
802 | 805 |
OP_DSC_FIELD = "instance_name" |
803 | 806 |
OP_PARAMS = [ |
804 | 807 |
_PInstanceName, |
805 |
("os_type", None, ht.TMaybeString), |
|
806 |
("force_variant", False, ht.TBool), |
|
807 |
("osparams", None, ht.TMaybeDict), |
|
808 |
("os_type", None, ht.TMaybeString, None),
|
|
809 |
("force_variant", False, ht.TBool, None),
|
|
810 |
("osparams", None, ht.TMaybeDict, None),
|
|
808 | 811 |
] |
809 | 812 |
|
810 | 813 |
|
... | ... | |
814 | 817 |
OP_PARAMS = [ |
815 | 818 |
_PInstanceName, |
816 | 819 |
_PShutdownTimeout, |
817 |
("ignore_failures", False, ht.TBool), |
|
820 |
("ignore_failures", False, ht.TBool, None),
|
|
818 | 821 |
] |
819 | 822 |
|
820 | 823 |
|
... | ... | |
822 | 825 |
"""Rename an instance.""" |
823 | 826 |
OP_PARAMS = [ |
824 | 827 |
_PInstanceName, |
825 |
("new_name", ht.NoDefault, ht.TNonEmptyString), |
|
826 |
("ip_check", False, ht.TBool), |
|
827 |
("name_check", True, ht.TBool), |
|
828 |
("new_name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
829 |
("ip_check", False, ht.TBool, None),
|
|
830 |
("name_check", True, ht.TBool, None),
|
|
828 | 831 |
] |
829 | 832 |
|
830 | 833 |
|
... | ... | |
835 | 838 |
_PInstanceName, |
836 | 839 |
_PForce, |
837 | 840 |
_PIgnoreOfflineNodes, |
838 |
("hvparams", ht.EmptyDict, ht.TDict), |
|
839 |
("beparams", ht.EmptyDict, ht.TDict), |
|
841 |
("hvparams", ht.EmptyDict, ht.TDict, None),
|
|
842 |
("beparams", ht.EmptyDict, ht.TDict, None),
|
|
840 | 843 |
] |
841 | 844 |
|
842 | 845 |
|
... | ... | |
846 | 849 |
OP_PARAMS = [ |
847 | 850 |
_PInstanceName, |
848 | 851 |
_PIgnoreOfflineNodes, |
849 |
("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt), |
|
852 |
("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt, None),
|
|
850 | 853 |
] |
851 | 854 |
|
852 | 855 |
|
... | ... | |
856 | 859 |
OP_PARAMS = [ |
857 | 860 |
_PInstanceName, |
858 | 861 |
_PShutdownTimeout, |
859 |
("ignore_secondaries", False, ht.TBool), |
|
860 |
("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES)), |
|
862 |
("ignore_secondaries", False, ht.TBool, None),
|
|
863 |
("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES), None),
|
|
861 | 864 |
] |
862 | 865 |
|
863 | 866 |
|
... | ... | |
866 | 869 |
OP_DSC_FIELD = "instance_name" |
867 | 870 |
OP_PARAMS = [ |
868 | 871 |
_PInstanceName, |
869 |
("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES)), |
|
870 |
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt)), |
|
871 |
("remote_node", None, ht.TMaybeString), |
|
872 |
("iallocator", None, ht.TMaybeString), |
|
873 |
("early_release", False, ht.TBool), |
|
872 |
("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES), None),
|
|
873 |
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt), None),
|
|
874 |
("remote_node", None, ht.TMaybeString, None),
|
|
875 |
("iallocator", None, ht.TMaybeString, None),
|
|
876 |
("early_release", False, ht.TBool, None),
|
|
874 | 877 |
] |
875 | 878 |
|
876 | 879 |
|
... | ... | |
880 | 883 |
OP_PARAMS = [ |
881 | 884 |
_PInstanceName, |
882 | 885 |
_PShutdownTimeout, |
883 |
("ignore_consistency", False, ht.TBool), |
|
886 |
("ignore_consistency", False, ht.TBool, None),
|
|
884 | 887 |
] |
885 | 888 |
|
886 | 889 |
|
... | ... | |
899 | 902 |
_PInstanceName, |
900 | 903 |
_PMigrationMode, |
901 | 904 |
_PMigrationLive, |
902 |
("cleanup", False, ht.TBool), |
|
905 |
("cleanup", False, ht.TBool, None),
|
|
903 | 906 |
] |
904 | 907 |
|
905 | 908 |
|
... | ... | |
917 | 920 |
OP_PARAMS = [ |
918 | 921 |
_PInstanceName, |
919 | 922 |
_PShutdownTimeout, |
920 |
("target_node", ht.NoDefault, ht.TNonEmptyString), |
|
923 |
("target_node", ht.NoDefault, ht.TNonEmptyString, None),
|
|
921 | 924 |
] |
922 | 925 |
|
923 | 926 |
|
... | ... | |
934 | 937 |
OP_DSC_FIELD = "instance_name" |
935 | 938 |
OP_PARAMS = [ |
936 | 939 |
_PInstanceName, |
937 |
("ignore_size", False, ht.TBool), |
|
940 |
("ignore_size", False, ht.TBool, None),
|
|
938 | 941 |
] |
939 | 942 |
|
940 | 943 |
|
... | ... | |
952 | 955 |
OP_DSC_FIELD = "instance_name" |
953 | 956 |
OP_PARAMS = [ |
954 | 957 |
_PInstanceName, |
955 |
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt)), |
|
958 |
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt), None),
|
|
956 | 959 |
] |
957 | 960 |
|
958 | 961 |
|
... | ... | |
960 | 963 |
"""Compute the list of instances.""" |
961 | 964 |
OP_PARAMS = [ |
962 | 965 |
_POutputFields, |
963 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
964 |
("use_locking", False, ht.TBool), |
|
966 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
967 |
("use_locking", False, ht.TBool, None),
|
|
965 | 968 |
] |
966 | 969 |
|
967 | 970 |
|
968 | 971 |
class OpInstanceQueryData(OpCode): |
969 | 972 |
"""Compute the run-time status of instances.""" |
970 | 973 |
OP_PARAMS = [ |
971 |
("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
972 |
("static", False, ht.TBool), |
|
974 |
("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
975 |
("static", False, ht.TBool, None),
|
|
973 | 976 |
] |
974 | 977 |
|
975 | 978 |
|
... | ... | |
979 | 982 |
OP_PARAMS = [ |
980 | 983 |
_PInstanceName, |
981 | 984 |
_PForce, |
982 |
("nics", ht.EmptyList, ht.TList), |
|
983 |
("disks", ht.EmptyList, ht.TList), |
|
984 |
("beparams", ht.EmptyDict, ht.TDict), |
|
985 |
("hvparams", ht.EmptyDict, ht.TDict), |
|
986 |
("disk_template", None, ht.TOr(ht.TNone, _CheckDiskTemplate)), |
|
987 |
("remote_node", None, ht.TMaybeString), |
|
988 |
("os_name", None, ht.TMaybeString), |
|
989 |
("force_variant", False, ht.TBool), |
|
990 |
("osparams", None, ht.TMaybeDict), |
|
985 |
("nics", ht.EmptyList, ht.TList, None),
|
|
986 |
("disks", ht.EmptyList, ht.TList, None),
|
|
987 |
("beparams", ht.EmptyDict, ht.TDict, None),
|
|
988 |
("hvparams", ht.EmptyDict, ht.TDict, None),
|
|
989 |
("disk_template", None, ht.TOr(ht.TNone, _CheckDiskTemplate), None),
|
|
990 |
("remote_node", None, ht.TMaybeString, None),
|
|
991 |
("os_name", None, ht.TMaybeString, None),
|
|
992 |
("force_variant", False, ht.TBool, None),
|
|
993 |
("osparams", None, ht.TMaybeDict, None),
|
|
991 | 994 |
] |
992 | 995 |
|
993 | 996 |
|
... | ... | |
996 | 999 |
OP_DSC_FIELD = "instance_name" |
997 | 1000 |
OP_PARAMS = [ |
998 | 1001 |
_PInstanceName, |
999 |
("disk", ht.NoDefault, ht.TInt), |
|
1000 |
("amount", ht.NoDefault, ht.TInt), |
|
1001 |
("wait_for_sync", True, ht.TBool), |
|
1002 |
("disk", ht.NoDefault, ht.TInt, None),
|
|
1003 |
("amount", ht.NoDefault, ht.TInt, None),
|
|
1004 |
("wait_for_sync", True, ht.TBool, None),
|
|
1002 | 1005 |
] |
1003 | 1006 |
|
1004 | 1007 |
|
... | ... | |
1009 | 1012 |
OP_DSC_FIELD = "group_name" |
1010 | 1013 |
OP_PARAMS = [ |
1011 | 1014 |
_PGroupName, |
1012 |
("ndparams", None, ht.TMaybeDict), |
|
1015 |
("ndparams", None, ht.TMaybeDict, None),
|
|
1013 | 1016 |
("alloc_policy", None, |
1014 |
ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES))), |
|
1017 |
ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES)), None),
|
|
1015 | 1018 |
] |
1016 | 1019 |
|
1017 | 1020 |
|
... | ... | |
1021 | 1024 |
OP_PARAMS = [ |
1022 | 1025 |
_PGroupName, |
1023 | 1026 |
_PForce, |
1024 |
("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
1027 |
("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None),
|
|
1025 | 1028 |
] |
1026 | 1029 |
|
1027 | 1030 |
|
... | ... | |
1029 | 1032 |
"""Compute the list of node groups.""" |
1030 | 1033 |
OP_PARAMS = [ |
1031 | 1034 |
_POutputFields, |
1032 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
1035 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
1033 | 1036 |
] |
1034 | 1037 |
|
1035 | 1038 |
|
... | ... | |
1038 | 1041 |
OP_DSC_FIELD = "group_name" |
1039 | 1042 |
OP_PARAMS = [ |
1040 | 1043 |
_PGroupName, |
1041 |
("ndparams", None, ht.TMaybeDict), |
|
1044 |
("ndparams", None, ht.TMaybeDict, None),
|
|
1042 | 1045 |
("alloc_policy", None, ht.TOr(ht.TNone, |
1043 |
ht.TElemOf(constants.VALID_ALLOC_POLICIES))), |
|
1046 |
ht.TElemOf(constants.VALID_ALLOC_POLICIES)), None),
|
|
1044 | 1047 |
] |
1045 | 1048 |
|
1046 | 1049 |
|
... | ... | |
1056 | 1059 |
"""Rename a node group in the cluster.""" |
1057 | 1060 |
OP_DSC_FIELD = "old_name" |
1058 | 1061 |
OP_PARAMS = [ |
1059 |
("old_name", ht.NoDefault, ht.TNonEmptyString), |
|
1060 |
("new_name", ht.NoDefault, ht.TNonEmptyString), |
|
1062 |
("old_name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
1063 |
("new_name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
1061 | 1064 |
] |
1062 | 1065 |
|
1063 | 1066 |
|
... | ... | |
1066 | 1069 |
"""Compute the list of guest operating systems.""" |
1067 | 1070 |
OP_PARAMS = [ |
1068 | 1071 |
_POutputFields, |
1069 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
1072 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
1070 | 1073 |
] |
1071 | 1074 |
|
1072 | 1075 |
|
... | ... | |
1074 | 1077 |
class OpBackupQuery(OpCode): |
1075 | 1078 |
"""Compute the list of exported images.""" |
1076 | 1079 |
OP_PARAMS = [ |
1077 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
1078 |
("use_locking", False, ht.TBool), |
|
1080 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
1081 |
("use_locking", False, ht.TBool, None),
|
|
1079 | 1082 |
] |
1080 | 1083 |
|
1081 | 1084 |
|
... | ... | |
1089 | 1092 |
OP_DSC_FIELD = "instance_name" |
1090 | 1093 |
OP_PARAMS = [ |
1091 | 1094 |
_PInstanceName, |
1092 |
("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES)), |
|
1095 |
("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES), None),
|
|
1093 | 1096 |
] |
1094 | 1097 |
|
1095 | 1098 |
|
... | ... | |
1115 | 1118 |
_PShutdownTimeout, |
1116 | 1119 |
# TODO: Rename target_node as it changes meaning for different export modes |
1117 | 1120 |
# (e.g. "destination") |
1118 |
("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList)), |
|
1119 |
("shutdown", True, ht.TBool), |
|
1120 |
("remove_instance", False, ht.TBool), |
|
1121 |
("ignore_remove_failures", False, ht.TBool), |
|
1122 |
("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES)), |
|
1123 |
("x509_key_name", None, ht.TOr(ht.TList, ht.TNone)), |
|
1124 |
("destination_x509_ca", None, ht.TMaybeString), |
|
1121 |
("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList), None),
|
|
1122 |
("shutdown", True, ht.TBool, None),
|
|
1123 |
("remove_instance", False, ht.TBool, None),
|
|
1124 |
("ignore_remove_failures", False, ht.TBool, None),
|
|
1125 |
("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES), None),
|
|
1126 |
("x509_key_name", None, ht.TOr(ht.TList, ht.TNone), None),
|
|
1127 |
("destination_x509_ca", None, ht.TMaybeString, None),
|
|
1125 | 1128 |
] |
1126 | 1129 |
|
1127 | 1130 |
|
... | ... | |
1140 | 1143 |
OP_PARAMS = [ |
1141 | 1144 |
_PTagKind, |
1142 | 1145 |
# Name is only meaningful for nodes and instances |
1143 |
("name", ht.NoDefault, ht.TMaybeString), |
|
1146 |
("name", ht.NoDefault, ht.TMaybeString, None),
|
|
1144 | 1147 |
] |
1145 | 1148 |
|
1146 | 1149 |
|
... | ... | |
1148 | 1151 |
"""Searches the tags in the cluster for a given pattern.""" |
1149 | 1152 |
OP_DSC_FIELD = "pattern" |
1150 | 1153 |
OP_PARAMS = [ |
1151 |
("pattern", ht.NoDefault, ht.TNonEmptyString), |
|
1154 |
("pattern", ht.NoDefault, ht.TNonEmptyString, None),
|
|
1152 | 1155 |
] |
1153 | 1156 |
|
1154 | 1157 |
|
... | ... | |
1158 | 1161 |
_PTagKind, |
1159 | 1162 |
_PTags, |
1160 | 1163 |
# Name is only meaningful for nodes and instances |
1161 |
("name", ht.NoDefault, ht.TMaybeString), |
|
1164 |
("name", ht.NoDefault, ht.TMaybeString, None),
|
|
1162 | 1165 |
] |
1163 | 1166 |
|
1164 | 1167 |
|
... | ... | |
1168 | 1171 |
_PTagKind, |
1169 | 1172 |
_PTags, |
1170 | 1173 |
# Name is only meaningful for nodes and instances |
1171 |
("name", ht.NoDefault, ht.TMaybeString), |
|
1174 |
("name", ht.NoDefault, ht.TMaybeString, None),
|
|
1172 | 1175 |
] |
1173 | 1176 |
|
1174 | 1177 |
# Test opcodes |
... | ... | |
1195 | 1198 |
""" |
1196 | 1199 |
OP_DSC_FIELD = "duration" |
1197 | 1200 |
OP_PARAMS = [ |
1198 |
("duration", ht.NoDefault, ht.TFloat), |
|
1199 |
("on_master", True, ht.TBool), |
|
1200 |
("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
1201 |
("repeat", 0, ht.TPositiveInt)
|
|
1201 |
("duration", ht.NoDefault, ht.TFloat, None),
|
|
1202 |
("on_master", True, ht.TBool, None),
|
|
1203 |
("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
1204 |
("repeat", 0, ht.TPositiveInt, None),
|
|
1202 | 1205 |
] |
1203 | 1206 |
|
1204 | 1207 |
|
... | ... | |
1216 | 1219 |
OP_DSC_FIELD = "allocator" |
1217 | 1220 |
OP_PARAMS = [ |
1218 | 1221 |
("direction", ht.NoDefault, |
1219 |
ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)), |
|
1220 |
("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES)), |
|
1221 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
1222 |
ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS), None),
|
|
1223 |
("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES), None),
|
|
1224 |
("name", ht.NoDefault, ht.TNonEmptyString, None),
|
|
1222 | 1225 |
("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf( |
1223 | 1226 |
ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]), |
1224 |
ht.TOr(ht.TNone, ht.TNonEmptyString))))), |
|
1225 |
("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList)), |
|
1226 |
("hypervisor", None, ht.TMaybeString), |
|
1227 |
("allocator", None, ht.TMaybeString), |
|
1228 |
("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
1229 |
("mem_size", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
|
1230 |
("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
|
1231 |
("os", None, ht.TMaybeString), |
|
1232 |
("disk_template", None, ht.TMaybeString), |
|
1233 |
("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))), |
|
1227 |
ht.TOr(ht.TNone, ht.TNonEmptyString)))), None),
|
|
1228 |
("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList), None),
|
|
1229 |
("hypervisor", None, ht.TMaybeString, None),
|
|
1230 |
("allocator", None, ht.TMaybeString, None),
|
|
1231 |
("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
|
|
1232 |
("mem_size", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
|
|
1233 |
("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
|
|
1234 |
("os", None, ht.TMaybeString, None),
|
|
1235 |
("disk_template", None, ht.TMaybeString, None),
|
|
1236 |
("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)), None),
|
|
1234 | 1237 |
] |
1235 | 1238 |
|
1236 | 1239 |
|
... | ... | |
1239 | 1242 |
|
1240 | 1243 |
""" |
1241 | 1244 |
OP_PARAMS = [ |
1242 |
("notify_waitlock", False, ht.TBool), |
|
1243 |
("notify_exec", False, ht.TBool), |
|
1244 |
("log_messages", ht.EmptyList, ht.TListOf(ht.TString)), |
|
1245 |
("fail", False, ht.TBool), |
|
1245 |
("notify_waitlock", False, ht.TBool, None),
|
|
1246 |
("notify_exec", False, ht.TBool, None),
|
|
1247 |
("log_messages", ht.EmptyList, ht.TListOf(ht.TString), None),
|
|
1248 |
("fail", False, ht.TBool, None),
|
|
1246 | 1249 |
] |
1247 | 1250 |
|
1248 | 1251 |
|
... | ... | |
1251 | 1254 |
|
1252 | 1255 |
""" |
1253 | 1256 |
OP_PARAMS = [ |
1254 |
("result", ht.NoDefault, ht.NoType), |
|
1255 |
("messages", ht.NoDefault, ht.NoType), |
|
1256 |
("fail", ht.NoDefault, ht.NoType), |
|
1257 |
("result", ht.NoDefault, ht.NoType, None),
|
|
1258 |
("messages", ht.NoDefault, ht.NoType, None),
|
|
1259 |
("fail", ht.NoDefault, ht.NoType, None),
|
|
1257 | 1260 |
] |
1258 | 1261 |
WITH_LU = False |
1259 | 1262 |
|
Also available in: Unified diff