Revision 45d4c81c

b/lib/opcodes.py
46 46

  
47 47
#: output fields for a query operation
48 48
_POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
49
                  None)
49
                  "Selected output fields")
50 50

  
51 51
#: the shutdown timeout
52
_PShutdownTimeout = ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
53
                     ht.TPositiveInt, None)
52
_PShutdownTimeout = \
53
  ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
54
   "How long to wait for instance to shut down")
54 55

  
55 56
#: the force parameter
56
_PForce = ("force", False, ht.TBool, None)
57
_PForce = ("force", False, ht.TBool, "Whether to force the operation")
57 58

  
58 59
#: a required instance name (for single-instance LUs)
59
_PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString, None)
60
_PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString,
61
                  "Instance name")
60 62

  
61 63
#: Whether to ignore offline nodes
62
_PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool, None)
64
_PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool,
65
                        "Whether to ignore offline nodes")
63 66

  
64 67
#: a required node name (for single-node LUs)
65
_PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString, None)
68
_PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString, "Node name")
66 69

  
67 70
#: a required node group name (for single-group LUs)
68
_PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString, None)
71
_PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString, "Group name")
69 72

  
70 73
#: Migration type (live/non-live)
71 74
_PMigrationMode = ("mode", None,
72 75
                   ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES)),
73
                   None)
76
                   "Migration mode")
74 77

  
75 78
#: Obsolete 'live' migration mode (boolean)
76
_PMigrationLive = ("live", None, ht.TMaybeBool, None)
79
_PMigrationLive = ("live", None, ht.TMaybeBool,
80
                   "Legacy setting for live migration, do not use")
77 81

  
78 82
#: Tag type
79 83
_PTagKind = ("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES), None)
......
81 85
#: List of tag strings
82 86
_PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None)
83 87

  
88
_PForceVariant = ("force_variant", False, ht.TBool,
89
                  "Whether to force an unknown OS variant")
90

  
91
_PWaitForSync = ("wait_for_sync", True, ht.TBool,
92
                 "Whether to wait for the disk to synchronize")
93

  
94
_PIgnoreConsistency = ("ignore_consistency", False, ht.TBool,
95
                       "Whether to ignore disk consistency")
96

  
97
_PStorageName = ("name", ht.NoDefault, ht.TMaybeString, "Storage name")
98

  
99
_PUseLocking = ("use_locking", False, ht.TBool,
100
                "Whether to use synchronization")
101

  
102
_PNameCheck = ("name_check", True, ht.TBool, "Whether to check name")
103

  
104
_PNodeGroupAllocPolicy = \
105
  ("alloc_policy", None,
106
   ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES)),
107
   "Instance allocation policy")
108

  
109
_PGroupNodeParams = ("ndparams", None, ht.TMaybeDict,
110
                     "Default node parameters for group")
111

  
112
_PIpCheckDoc = "Whether to ensure instance's IP address is inactive"
113

  
84 114
#: OP_ID conversion regular expression
85 115
_OPID_RE = re.compile("([a-z])([A-Z])")
86 116

  
......
153 183

  
154 184

  
155 185
#: Storage type parameter
156
_PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType, None)
186
_PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType,
187
                 "Storage type")
157 188

  
158 189

  
159 190
class _AutoOpParamSlots(type):
......
336 367
  # as OP_ID is dynamically defined
337 368
  WITH_LU = True
338 369
  OP_PARAMS = [
339
    ("dry_run", None, ht.TMaybeBool, None),
340
    ("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
370
    ("dry_run", None, ht.TMaybeBool, "Run checks only, don't execute"),
371
    ("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt), "Debug level"),
341 372
    ("priority", constants.OP_PRIO_DEFAULT,
342
     ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), None),
373
     ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), "Opcode priority"),
343 374
    ]
344 375

  
345 376
  def __getstate__(self):
......
525 556

  
526 557
  """
527 558
  OP_PARAMS = [
528
    ("vg_name", None, ht.TMaybeString, None),
559
    ("vg_name", None, ht.TMaybeString, "Volume group name"),
529 560
    ("enabled_hypervisors", None,
530 561
     ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue),
531
            ht.TNone), None),
562
            ht.TNone),
563
     "List of enabled hypervisors"),
532 564
    ("hvparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict),
533
                              ht.TNone), None),
534
    ("beparams", None, ht.TOr(ht.TDict, ht.TNone), None),
565
                              ht.TNone),
566
     "Cluster-wide hypervisor parameter defaults, hypervisor-dependent"),
567
    ("beparams", None, ht.TOr(ht.TDict, ht.TNone),
568
     "Cluster-wide backend parameter defaults"),
535 569
    ("os_hvp", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict),
536
                            ht.TNone), None),
570
                            ht.TNone),
571
     "Cluster-wide per-OS hypervisor parameter defaults"),
537 572
    ("osparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict),
538
                              ht.TNone), None),
573
                              ht.TNone),
574
     "Cluster-wide OS parameter defaults"),
539 575
    ("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),
576
     "Master candidate pool size"),
577
    ("uid_pool", None, ht.NoType,
578
     "Set UID pool, must be list of lists describing UID ranges (two items,"
579
     " start and end inclusive)"),
580
    ("add_uids", None, ht.NoType,
581
     "Extend UID pool, must be list of lists describing UID ranges (two"
582
     " items, start and end inclusive) to be added"),
583
    ("remove_uids", None, ht.NoType,
584
     "Shrink UID pool, must be list of lists describing UID ranges (two"
585
     " items, start and end inclusive) to be removed"),
586
    ("maintain_node_health", None, ht.TMaybeBool,
587
     "Whether to automatically maintain node health"),
588
    ("prealloc_wipe_disks", None, ht.TMaybeBool,
589
     "Whether to wipe disks before allocating them to instances"),
590
    ("nicparams", None, ht.TMaybeDict, "Cluster-wide NIC parameter defaults"),
591
    ("ndparams", None, ht.TMaybeDict, "Cluster-wide node parameter defaults"),
592
    ("drbd_helper", None, ht.TOr(ht.TString, ht.TNone), "DRBD helper program"),
593
    ("default_iallocator", None, ht.TOr(ht.TString, ht.TNone),
594
     "Default iallocator for cluster"),
595
    ("master_netdev", None, ht.TOr(ht.TString, ht.TNone),
596
     "Master network device"),
597
    ("reserved_lvs", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone),
598
     "List of reserved LVs"),
599
    ("hidden_os", None, _TestClusterOsList,
600
     "Modify list of hidden operating systems. Each modification must have"
601
     " two items, the operation and the OS name. The operation can be"
602
     " ``%s`` or ``%s``." % (constants.DDM_ADD, constants.DDM_REMOVE)),
603
    ("blacklisted_os", None, _TestClusterOsList,
604
     "Modify list of blacklisted operating systems. Each modification must have"
605
     " two items, the operation and the OS name. The operation can be"
606
     " ``%s`` or ``%s``." % (constants.DDM_ADD, constants.DDM_REMOVE)),
554 607
    ]
555 608

  
556 609

  
......
569 622

  
570 623
  """
571 624
  OP_PARAMS = [
572
    ("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY), None),
573
    ("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None),
625
    ("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY),
626
     "Resource(s) to query for"),
627
    ("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
628
     "Requested fields"),
574 629
    ("filter", None, ht.TOr(ht.TNone,
575
                            ht.TListOf(ht.TOr(ht.TNonEmptyString, ht.TList))), None),
630
                            ht.TListOf(ht.TOr(ht.TNonEmptyString, ht.TList))),
631
     "Query filter"),
576 632
    ]
577 633

  
578 634

  
......
647 703
  OP_DSC_FIELD = "node_name"
648 704
  OP_PARAMS = [
649 705
    _PNodeName,
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),
706
    ("primary_ip", None, ht.NoType, "Primary IP address"),
707
    ("secondary_ip", None, ht.TMaybeString, "Secondary IP address"),
708
    ("readd", False, ht.TBool, "Whether node is re-added to cluster"),
709
    ("group", None, ht.TMaybeString, "Initial node group"),
710
    ("master_capable", None, ht.TMaybeBool,
711
     "Whether node can become master or master candidate"),
712
    ("vm_capable", None, ht.TMaybeBool,
713
     "Whether node can host instances"),
714
    ("ndparams", None, ht.TMaybeDict, "Node parameters"),
657 715
    ]
658 716

  
659 717

  
......
661 719
  """Compute the list of nodes."""
662 720
  OP_PARAMS = [
663 721
    _POutputFields,
664
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
665
    ("use_locking", False, ht.TBool, None),
722
    _PUseLocking,
723
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
724
     "Empty list to query all nodes, node names otherwise"),
666 725
    ]
667 726

  
668 727

  
......
670 729
  """Get list of volumes on node."""
671 730
  OP_PARAMS = [
672 731
    _POutputFields,
673
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
732
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
733
     "Empty list to query all nodes, node names otherwise"),
674 734
    ]
675 735

  
676 736

  
......
679 739
  OP_PARAMS = [
680 740
    _POutputFields,
681 741
    _PStorageType,
682
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
683
    ("name", None, ht.TMaybeString, None),
742
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "List of nodes"),
743
    ("name", None, ht.TMaybeString, "Storage name"),
684 744
    ]
685 745

  
686 746

  
......
689 749
  OP_PARAMS = [
690 750
    _PNodeName,
691 751
    _PStorageType,
692
    ("name", ht.NoDefault, ht.TNonEmptyString, None),
693
    ("changes", ht.NoDefault, ht.TDict, None),
752
    _PStorageName,
753
    ("changes", ht.NoDefault, ht.TDict, "Requested changes"),
694 754
    ]
695 755

  
696 756

  
......
700 760
  OP_PARAMS = [
701 761
    _PNodeName,
702 762
    _PStorageType,
703
    ("name", ht.NoDefault, ht.TNonEmptyString, None),
704
    ("ignore_consistency", False, ht.TBool, None),
763
    _PStorageName,
764
    _PIgnoreConsistency,
705 765
    ]
706 766

  
707 767

  
......
711 771
  OP_PARAMS = [
712 772
    _PNodeName,
713 773
    _PForce,
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),
774
    ("master_candidate", None, ht.TMaybeBool,
775
     "Whether the node should become a master candidate"),
776
    ("offline", None, ht.TMaybeBool,
777
     "Whether the node should be marked as offline"),
778
    ("drained", None, ht.TMaybeBool,
779
     "Whether the node should be marked as drained"),
780
    ("auto_promote", False, ht.TBool,
781
     "Whether node(s) should be promoted to master candidate if necessary"),
782
    ("master_capable", None, ht.TMaybeBool,
783
     "Denote whether node can become master or master candidate"),
784
    ("vm_capable", None, ht.TMaybeBool,
785
     "Denote whether node can host instances"),
786
    ("secondary_ip", None, ht.TMaybeString,
787
     "Change node's secondary IP address"),
788
    ("ndparams", None, ht.TMaybeDict, "Set node parameters"),
789
    ("powered", None, ht.TMaybeBool,
790
     "Whether the node should be marked as powered"),
723 791
    ]
724 792

  
725 793

  
......
769 837
  OP_DSC_FIELD = "instance_name"
770 838
  OP_PARAMS = [
771 839
    _PInstanceName,
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),
840
    _PForceVariant,
841
    _PWaitForSync,
842
    _PNameCheck,
843
    ("beparams", ht.EmptyDict, ht.TDict, "Backend parameters for instance"),
844
    ("disks", ht.NoDefault, ht.TListOf(ht.TDict), "Disk descriptions"),
845
    ("disk_template", ht.NoDefault, _CheckDiskTemplate, "Disk template"),
846
    ("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER)),
847
     "Driver for file-backed disks"),
848
    ("file_storage_dir", None, ht.TMaybeString,
849
     "Directory for storing file-backed disks"),
850
    ("hvparams", ht.EmptyDict, ht.TDict,
851
     "Hypervisor parameters for instance, hypervisor-dependent"),
852
    ("hypervisor", None, ht.TMaybeString, "Hypervisor"),
853
    ("iallocator", None, ht.TMaybeString,
854
     "Iallocator for deciding which node(s) to use"),
855
    ("identify_defaults", False, ht.TBool,
856
     "Reset instance parameters to default if equal"),
857
    ("ip_check", True, ht.TBool, _PIpCheckDoc),
858
    ("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES),
859
     "Instance creation mode"),
860
    ("nics", ht.NoDefault, ht.TListOf(ht.TDict),
861
     "List of NIC (network interface) definitions"),
862
    ("no_install", None, ht.TMaybeBool,
863
     "Do not install the OS (will disable automatic start)"),
864
    ("osparams", ht.EmptyDict, ht.TDict, "OS parameters for instance"),
865
    ("os_type", None, ht.TMaybeString, "Operating system"),
866
    ("pnode", None, ht.TMaybeString, "Primary node"),
867
    ("snode", None, ht.TMaybeString, "Secondary node"),
868
    ("source_handshake", None, ht.TOr(ht.TList, ht.TNone),
869
     "Signed handshake from source (remote import only)"),
870
    ("source_instance_name", None, ht.TMaybeString,
871
     "Source instance name (remote import only)"),
793 872
    ("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
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),
873
     ht.TPositiveInt, "How long source instance was given to shut down"),
874
    ("source_x509_ca", None, ht.TMaybeString,
875
     "Source X509 CA in PEM format (remote import only)"),
876
    ("src_node", None, ht.TMaybeString, "Source node for import"),
877
    ("src_path", None, ht.TMaybeString, "Source directory for import"),
878
    ("start", True, ht.TBool, "Whether to start instance after creation"),
800 879
    ]
801 880

  
802 881

  
......
805 884
  OP_DSC_FIELD = "instance_name"
806 885
  OP_PARAMS = [
807 886
    _PInstanceName,
808
    ("os_type", None, ht.TMaybeString, None),
809
    ("force_variant", False, ht.TBool, None),
810
    ("osparams", None, ht.TMaybeDict, None),
887
    _PForceVariant,
888
    ("os_type", None, ht.TMaybeString, "Instance operating system"),
889
    ("osparams", None, ht.TMaybeDict, "Temporary OS parameters"),
811 890
    ]
812 891

  
813 892

  
......
817 896
  OP_PARAMS = [
818 897
    _PInstanceName,
819 898
    _PShutdownTimeout,
820
    ("ignore_failures", False, ht.TBool, None),
899
    ("ignore_failures", False, ht.TBool,
900
     "Whether to ignore failures during removal"),
821 901
    ]
822 902

  
823 903

  
......
825 905
  """Rename an instance."""
826 906
  OP_PARAMS = [
827 907
    _PInstanceName,
828
    ("new_name", ht.NoDefault, ht.TNonEmptyString, None),
829
    ("ip_check", False, ht.TBool, None),
830
    ("name_check", True, ht.TBool, None),
908
    _PNameCheck,
909
    ("new_name", ht.NoDefault, ht.TNonEmptyString, "New instance name"),
910
    ("ip_check", False, ht.TBool, _PIpCheckDoc),
831 911
    ]
832 912

  
833 913

  
......
838 918
    _PInstanceName,
839 919
    _PForce,
840 920
    _PIgnoreOfflineNodes,
841
    ("hvparams", ht.EmptyDict, ht.TDict, None),
842
    ("beparams", ht.EmptyDict, ht.TDict, None),
921
    ("hvparams", ht.EmptyDict, ht.TDict,
922
     "Temporary hypervisor parameters, hypervisor-dependent"),
923
    ("beparams", ht.EmptyDict, ht.TDict, "Temporary backend parameters"),
843 924
    ]
844 925

  
845 926

  
......
849 930
  OP_PARAMS = [
850 931
    _PInstanceName,
851 932
    _PIgnoreOfflineNodes,
852
    ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt, None),
933
    ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
934
     "How long to wait for instance to shut down"),
853 935
    ]
854 936

  
855 937

  
......
859 941
  OP_PARAMS = [
860 942
    _PInstanceName,
861 943
    _PShutdownTimeout,
862
    ("ignore_secondaries", False, ht.TBool, None),
863
    ("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES), None),
944
    ("ignore_secondaries", False, ht.TBool,
945
     "Whether to start the instance even if secondary disks are failing"),
946
    ("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES),
947
     "How to reboot instance"),
864 948
    ]
865 949

  
866 950

  
......
869 953
  OP_DSC_FIELD = "instance_name"
870 954
  OP_PARAMS = [
871 955
    _PInstanceName,
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),
956
    ("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES),
957
     "Replacement mode"),
958
    ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt),
959
     "Disk indexes"),
960
    ("remote_node", None, ht.TMaybeString, "New secondary node"),
961
    ("iallocator", None, ht.TMaybeString,
962
     "Iallocator for deciding new secondary node"),
963
    ("early_release", False, ht.TBool,
964
     "Whether to release locks as soon as possible"),
877 965
    ]
878 966

  
879 967

  
......
883 971
  OP_PARAMS = [
884 972
    _PInstanceName,
885 973
    _PShutdownTimeout,
886
    ("ignore_consistency", False, ht.TBool, None),
974
    _PIgnoreConsistency,
887 975
    ]
888 976

  
889 977

  
......
902 990
    _PInstanceName,
903 991
    _PMigrationMode,
904 992
    _PMigrationLive,
905
    ("cleanup", False, ht.TBool, None),
993
    ("cleanup", False, ht.TBool,
994
     "Whether a previously failed migration should be cleaned up"),
906 995
    ]
907 996

  
908 997

  
......
920 1009
  OP_PARAMS = [
921 1010
    _PInstanceName,
922 1011
    _PShutdownTimeout,
923
    ("target_node", ht.NoDefault, ht.TNonEmptyString, None),
1012
    ("target_node", ht.NoDefault, ht.TNonEmptyString, "Target node"),
924 1013
    ]
925 1014

  
926 1015

  
......
937 1026
  OP_DSC_FIELD = "instance_name"
938 1027
  OP_PARAMS = [
939 1028
    _PInstanceName,
940
    ("ignore_size", False, ht.TBool, None),
1029
    ("ignore_size", False, ht.TBool, "Whether to ignore recorded size"),
941 1030
    ]
942 1031

  
943 1032

  
......
955 1044
  OP_DSC_FIELD = "instance_name"
956 1045
  OP_PARAMS = [
957 1046
    _PInstanceName,
958
    ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt), None),
1047
    ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt),
1048
     "List of disk indexes"),
959 1049
    ]
960 1050

  
961 1051

  
......
963 1053
  """Compute the list of instances."""
964 1054
  OP_PARAMS = [
965 1055
    _POutputFields,
966
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
967
    ("use_locking", False, ht.TBool, None),
1056
    _PUseLocking,
1057
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
1058
     "Empty list to query all instances, instance names otherwise"),
968 1059
    ]
969 1060

  
970 1061

  
......
982 1073
  OP_PARAMS = [
983 1074
    _PInstanceName,
984 1075
    _PForce,
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),
1076
    _PForceVariant,
1077
    ("nics", ht.EmptyList, ht.TList,
1078
     "List of NIC changes. Each item is of the form ``(op, settings)``."
1079
     " ``op`` can be ``%s`` to add a new NIC with the specified settings,"
1080
     " ``%s`` to remove the last NIC or a number to modify the settings"
1081
     " of the NIC with that index." %
1082
     (constants.DDM_ADD, constants.DDM_REMOVE)),
1083
    ("disks", ht.EmptyList, ht.TList, "List of disk changes. See ``nics``."),
1084
    ("beparams", ht.EmptyDict, ht.TDict, "Per-instance backend parameters"),
1085
    ("hvparams", ht.EmptyDict, ht.TDict,
1086
     "Per-instance hypervisor parameters, hypervisor-dependent"),
1087
    ("disk_template", None, ht.TOr(ht.TNone, _CheckDiskTemplate),
1088
     "Disk template for instance"),
1089
    ("remote_node", None, ht.TMaybeString,
1090
     "Secondary node (used when changing disk template)"),
1091
    ("os_name", None, ht.TMaybeString,
1092
     "Change instance's OS name. Does not reinstall the instance."),
1093
    ("osparams", None, ht.TMaybeDict, "Per-instance OS parameters"),
994 1094
    ]
995 1095

  
996 1096

  
......
999 1099
  OP_DSC_FIELD = "instance_name"
1000 1100
  OP_PARAMS = [
1001 1101
    _PInstanceName,
1002
    ("disk", ht.NoDefault, ht.TInt, None),
1003
    ("amount", ht.NoDefault, ht.TInt, None),
1004
    ("wait_for_sync", True, ht.TBool, None),
1102
    _PWaitForSync,
1103
    ("disk", ht.NoDefault, ht.TInt, "Disk index"),
1104
    ("amount", ht.NoDefault, ht.TInt,
1105
     "Amount of disk space to add (megabytes)"),
1005 1106
    ]
1006 1107

  
1007 1108

  
......
1012 1113
  OP_DSC_FIELD = "group_name"
1013 1114
  OP_PARAMS = [
1014 1115
    _PGroupName,
1015
    ("ndparams", None, ht.TMaybeDict, None),
1016
    ("alloc_policy", None,
1017
     ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES)), None),
1116
    _PNodeGroupAllocPolicy,
1117
    _PGroupNodeParams,
1018 1118
    ]
1019 1119

  
1020 1120

  
......
1024 1124
  OP_PARAMS = [
1025 1125
    _PGroupName,
1026 1126
    _PForce,
1027
    ("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None),
1127
    ("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
1128
     "List of nodes to assign"),
1028 1129
    ]
1029 1130

  
1030 1131

  
......
1032 1133
  """Compute the list of node groups."""
1033 1134
  OP_PARAMS = [
1034 1135
    _POutputFields,
1035
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
1136
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
1137
     "Empty list to query all groups, group names otherwise"),
1036 1138
    ]
1037 1139

  
1038 1140

  
......
1041 1143
  OP_DSC_FIELD = "group_name"
1042 1144
  OP_PARAMS = [
1043 1145
    _PGroupName,
1044
    ("ndparams", None, ht.TMaybeDict, None),
1045
    ("alloc_policy", None, ht.TOr(ht.TNone,
1046
                                  ht.TElemOf(constants.VALID_ALLOC_POLICIES)), None),
1146
    _PNodeGroupAllocPolicy,
1147
    _PGroupNodeParams,
1047 1148
    ]
1048 1149

  
1049 1150

  
......
1069 1170
  """Compute the list of guest operating systems."""
1070 1171
  OP_PARAMS = [
1071 1172
    _POutputFields,
1072
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
1173
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
1174
     "Which operating systems to diagnose"),
1073 1175
    ]
1074 1176

  
1075 1177

  
......
1077 1179
class OpBackupQuery(OpCode):
1078 1180
  """Compute the list of exported images."""
1079 1181
  OP_PARAMS = [
1080
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
1081
    ("use_locking", False, ht.TBool, None),
1182
    _PUseLocking,
1183
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
1184
     "Empty list to query all nodes, node names otherwise"),
1082 1185
    ]
1083 1186

  
1084 1187

  
......
1092 1195
  OP_DSC_FIELD = "instance_name"
1093 1196
  OP_PARAMS = [
1094 1197
    _PInstanceName,
1095
    ("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES), None),
1198
    ("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES),
1199
     "Export mode"),
1096 1200
    ]
1097 1201

  
1098 1202

  
......
1118 1222
    _PShutdownTimeout,
1119 1223
    # TODO: Rename target_node as it changes meaning for different export modes
1120 1224
    # (e.g. "destination")
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),
1225
    ("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList),
1226
     "Destination information, depends on export mode"),
1227
    ("shutdown", True, ht.TBool, "Whether to shutdown instance before export"),
1228
    ("remove_instance", False, ht.TBool,
1229
     "Whether to remove instance after export"),
1230
    ("ignore_remove_failures", False, ht.TBool,
1231
     "Whether to ignore failures while removing instances"),
1232
    ("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES),
1233
     "Export mode"),
1234
    ("x509_key_name", None, ht.TOr(ht.TList, ht.TNone),
1235
     "Name of X509 key (remote export only)"),
1236
    ("destination_x509_ca", None, ht.TMaybeString,
1237
     "Destination X509 CA (remote export only)"),
1128 1238
    ]
1129 1239

  
1130 1240

  
......
1223 1333
    ("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES), None),
1224 1334
    ("name", ht.NoDefault, ht.TNonEmptyString, None),
1225 1335
    ("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf(
1226
      ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]),
1227
               ht.TOr(ht.TNone, ht.TNonEmptyString)))), None),
1336
     ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]),
1337
                ht.TOr(ht.TNone, ht.TNonEmptyString)))), None),
1228 1338
    ("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList), None),
1229 1339
    ("hypervisor", None, ht.TMaybeString, None),
1230 1340
    ("allocator", None, ht.TMaybeString, None),
......
1233 1343
    ("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
1234 1344
    ("os", None, ht.TMaybeString, None),
1235 1345
    ("disk_template", None, ht.TMaybeString, None),
1236
    ("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)), None),
1346
    ("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
1347
     None),
1237 1348
    ]
1238 1349

  
1239 1350

  
b/test/ganeti.opcodes_unittest.py
30 30
from ganeti import ht
31 31
from ganeti import constants
32 32
from ganeti import errors
33
from ganeti import compat
33 34

  
34 35
import testutils
35 36

  
......
156 157
        self.assert_(test is None or test is ht.NoType or callable(test),
157 158
                     msg=("Invalid type check for %s.%s" %
158 159
                          (cls.OP_ID, attr_name)))
159
        self.assertTrue(doc is None)
160
        self.assertTrue(doc is None or isinstance(doc, basestring))
160 161

  
161 162
        if callable(aval):
162 163
          self.assertFalse(callable(aval()),
163 164
                           msg="Default value returned by function is callable")
164 165

  
166
      # If any parameter has documentation, all others need to have it as well
167
      has_doc = [doc is not None for (_, _, _, doc) in cls.OP_PARAMS]
168
      self.assertTrue(not compat.any(has_doc) or compat.all(has_doc),
169
                      msg="%s does not document all parameters" % cls)
170

  
165 171
  def testValidateNoModification(self):
166 172
    class OpTest(opcodes.OpCode):
167 173
      OP_PARAMS = [

Also available in: Unified diff