Revision 0bff0b12 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
57 | 57 |
from ganeti import ht |
58 | 58 |
from ganeti import query |
59 | 59 |
from ganeti import qlang |
60 |
from ganeti import opcodes |
|
60 | 61 |
|
61 | 62 |
import ganeti.masterd.instance # pylint: disable-msg=W0611 |
62 | 63 |
|
63 |
# Common opcode attributes |
|
64 |
|
|
65 |
#: output fields for a query operation |
|
66 |
_POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)) |
|
67 |
|
|
68 |
|
|
69 |
#: the shutdown timeout |
|
70 |
_PShutdownTimeout = ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, |
|
71 |
ht.TPositiveInt) |
|
72 |
|
|
73 |
#: the force parameter |
|
74 |
_PForce = ("force", False, ht.TBool) |
|
75 |
|
|
76 |
#: a required instance name (for single-instance LUs) |
|
77 |
_PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString) |
|
78 |
|
|
79 |
#: Whether to ignore offline nodes |
|
80 |
_PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool) |
|
81 |
|
|
82 |
#: a required node name (for single-node LUs) |
|
83 |
_PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString) |
|
84 |
|
|
85 |
#: a required node group name (for single-group LUs) |
|
86 |
_PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString) |
|
87 |
|
|
88 |
#: the migration type (live/non-live) |
|
89 |
_PMigrationMode = ("mode", None, |
|
90 |
ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES))) |
|
91 |
|
|
92 |
#: the obsolete 'live' mode (boolean) |
|
93 |
_PMigrationLive = ("live", None, ht.TMaybeBool) |
|
94 |
|
|
95 | 64 |
|
96 | 65 |
def _SupportsOob(cfg, node): |
97 | 66 |
"""Tells if node supports OOB. |
... | ... | |
123 | 92 |
|
124 | 93 |
@ivar dry_run_result: the value (if any) that will be returned to the caller |
125 | 94 |
in dry-run mode (signalled by opcode dry_run parameter) |
126 |
@cvar _OP_PARAMS: a list of opcode attributes, the default values |
|
127 |
they should get if not already defined, and types they must match |
|
128 | 95 |
|
129 | 96 |
""" |
130 | 97 |
HPATH = None |
131 | 98 |
HTYPE = None |
132 |
_OP_PARAMS = [] |
|
133 | 99 |
REQ_BGL = True |
134 | 100 |
|
135 | 101 |
def __init__(self, processor, op, context, rpc): |
... | ... | |
170 | 136 |
|
171 | 137 |
# The new kind-of-type-system |
172 | 138 |
op_id = self.op.OP_ID |
173 |
for attr_name, aval, test in self._OP_PARAMS:
|
|
139 |
for attr_name, aval, test in self.op.GetAllParams():
|
|
174 | 140 |
if not hasattr(op, attr_name): |
175 | 141 |
if aval == ht.NoDefault: |
176 | 142 |
raise errors.OpPrereqError("Required parameter '%s.%s' missing" % |
... | ... | |
788 | 754 |
raise errors.OpExecError(msg) |
789 | 755 |
|
790 | 756 |
|
791 |
def _RequireFileStorage(): |
|
792 |
"""Checks that file storage is enabled. |
|
793 |
|
|
794 |
@raise errors.OpPrereqError: when file storage is disabled |
|
795 |
|
|
796 |
""" |
|
797 |
if not constants.ENABLE_FILE_STORAGE: |
|
798 |
raise errors.OpPrereqError("File storage disabled at configure time", |
|
799 |
errors.ECODE_INVAL) |
|
800 |
|
|
801 |
|
|
802 |
def _CheckDiskTemplate(template): |
|
803 |
"""Ensure a given disk template is valid. |
|
804 |
|
|
805 |
""" |
|
806 |
if template not in constants.DISK_TEMPLATES: |
|
807 |
msg = ("Invalid disk template name '%s', valid templates are: %s" % |
|
808 |
(template, utils.CommaJoin(constants.DISK_TEMPLATES))) |
|
809 |
raise errors.OpPrereqError(msg, errors.ECODE_INVAL) |
|
810 |
if template == constants.DT_FILE: |
|
811 |
_RequireFileStorage() |
|
812 |
return True |
|
813 |
|
|
814 |
|
|
815 |
def _CheckStorageType(storage_type): |
|
816 |
"""Ensure a given storage type is valid. |
|
817 |
|
|
818 |
""" |
|
819 |
if storage_type not in constants.VALID_STORAGE_TYPES: |
|
820 |
raise errors.OpPrereqError("Unknown storage type: %s" % storage_type, |
|
821 |
errors.ECODE_INVAL) |
|
822 |
if storage_type == constants.ST_FILE: |
|
823 |
_RequireFileStorage() |
|
824 |
return True |
|
825 |
|
|
826 |
|
|
827 | 757 |
def _GetClusterDomainSecret(): |
828 | 758 |
"""Reads the cluster domain secret. |
829 | 759 |
|
... | ... | |
1300 | 1230 |
""" |
1301 | 1231 |
HPATH = "cluster-verify" |
1302 | 1232 |
HTYPE = constants.HTYPE_CLUSTER |
1303 |
_OP_PARAMS = [ |
|
1304 |
("skip_checks", ht.EmptyList, |
|
1305 |
ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS))), |
|
1306 |
("verbose", False, ht.TBool), |
|
1307 |
("error_codes", False, ht.TBool), |
|
1308 |
("debug_simulate_errors", False, ht.TBool), |
|
1309 |
] |
|
1310 | 1233 |
REQ_BGL = False |
1311 | 1234 |
|
1312 | 1235 |
TCLUSTER = "cluster" |
... | ... | |
2507 | 2430 |
"""Verifies the cluster disks sizes. |
2508 | 2431 |
|
2509 | 2432 |
""" |
2510 |
_OP_PARAMS = [("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString))] |
|
2511 | 2433 |
REQ_BGL = False |
2512 | 2434 |
|
2513 | 2435 |
def ExpandNames(self): |
... | ... | |
2625 | 2547 |
""" |
2626 | 2548 |
HPATH = "cluster-rename" |
2627 | 2549 |
HTYPE = constants.HTYPE_CLUSTER |
2628 |
_OP_PARAMS = [("name", ht.NoDefault, ht.TNonEmptyString)] |
|
2629 | 2550 |
|
2630 | 2551 |
def BuildHooksEnv(self): |
2631 | 2552 |
"""Build hooks env. |
... | ... | |
2704 | 2625 |
""" |
2705 | 2626 |
HPATH = "cluster-modify" |
2706 | 2627 |
HTYPE = constants.HTYPE_CLUSTER |
2707 |
_OP_PARAMS = [ |
|
2708 |
("vg_name", None, ht.TMaybeString), |
|
2709 |
("enabled_hypervisors", None, |
|
2710 |
ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue), |
|
2711 |
ht.TNone)), |
|
2712 |
("hvparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
|
2713 |
ht.TNone)), |
|
2714 |
("beparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
2715 |
("os_hvp", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
|
2716 |
ht.TNone)), |
|
2717 |
("osparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict), |
|
2718 |
ht.TNone)), |
|
2719 |
("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone)), |
|
2720 |
("uid_pool", None, ht.NoType), |
|
2721 |
("add_uids", None, ht.NoType), |
|
2722 |
("remove_uids", None, ht.NoType), |
|
2723 |
("maintain_node_health", None, ht.TMaybeBool), |
|
2724 |
("prealloc_wipe_disks", None, ht.TMaybeBool), |
|
2725 |
("nicparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
2726 |
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
2727 |
("drbd_helper", None, ht.TOr(ht.TString, ht.TNone)), |
|
2728 |
("default_iallocator", None, ht.TOr(ht.TString, ht.TNone)), |
|
2729 |
("master_netdev", None, ht.TOr(ht.TString, ht.TNone)), |
|
2730 |
("reserved_lvs", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone)), |
|
2731 |
("hidden_os", None, ht.TOr(ht.TListOf(\ |
|
2732 |
ht.TAnd(ht.TList, |
|
2733 |
ht.TIsLength(2), |
|
2734 |
ht.TMap(lambda v: v[0], ht.TElemOf(constants.DDMS_VALUES)))), |
|
2735 |
ht.TNone)), |
|
2736 |
("blacklisted_os", None, ht.TOr(ht.TListOf(\ |
|
2737 |
ht.TAnd(ht.TList, |
|
2738 |
ht.TIsLength(2), |
|
2739 |
ht.TMap(lambda v: v[0], ht.TElemOf(constants.DDMS_VALUES)))), |
|
2740 |
ht.TNone)), |
|
2741 |
] |
|
2742 | 2628 |
REQ_BGL = False |
2743 | 2629 |
|
2744 | 2630 |
def CheckArguments(self): |
... | ... | |
3263 | 3149 |
"""Logical unit for OOB handling. |
3264 | 3150 |
|
3265 | 3151 |
""" |
3266 |
_OP_PARAMS = [ |
|
3267 |
_PNodeName, |
|
3268 |
("command", None, ht.TElemOf(constants.OOB_COMMANDS)), |
|
3269 |
("timeout", constants.OOB_TIMEOUT, ht.TInt), |
|
3270 |
] |
|
3271 | 3152 |
REG_BGL = False |
3272 | 3153 |
|
3273 | 3154 |
def CheckPrereq(self): |
... | ... | |
3388 | 3269 |
"""Logical unit for OS diagnose/query. |
3389 | 3270 |
|
3390 | 3271 |
""" |
3391 |
_OP_PARAMS = [ |
|
3392 |
_POutputFields, |
|
3393 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
3394 |
] |
|
3395 | 3272 |
REQ_BGL = False |
3396 | 3273 |
_HID = "hidden" |
3397 | 3274 |
_BLK = "blacklisted" |
... | ... | |
3528 | 3405 |
""" |
3529 | 3406 |
HPATH = "node-remove" |
3530 | 3407 |
HTYPE = constants.HTYPE_NODE |
3531 |
_OP_PARAMS = [ |
|
3532 |
_PNodeName, |
|
3533 |
] |
|
3534 | 3408 |
|
3535 | 3409 |
def BuildHooksEnv(self): |
3536 | 3410 |
"""Build hooks env. |
... | ... | |
3692 | 3566 |
|
3693 | 3567 |
""" |
3694 | 3568 |
# pylint: disable-msg=W0142 |
3695 |
_OP_PARAMS = [ |
|
3696 |
_POutputFields, |
|
3697 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
3698 |
("use_locking", False, ht.TBool), |
|
3699 |
] |
|
3700 | 3569 |
REQ_BGL = False |
3701 | 3570 |
|
3702 | 3571 |
def CheckArguments(self): |
... | ... | |
3714 | 3583 |
"""Logical unit for getting volumes on node(s). |
3715 | 3584 |
|
3716 | 3585 |
""" |
3717 |
_OP_PARAMS = [ |
|
3718 |
_POutputFields, |
|
3719 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
3720 |
] |
|
3721 | 3586 |
REQ_BGL = False |
3722 | 3587 |
_FIELDS_DYNAMIC = utils.FieldSet("phys", "vg", "name", "size", "instance") |
3723 | 3588 |
_FIELDS_STATIC = utils.FieldSet("node") |
... | ... | |
3797 | 3662 |
|
3798 | 3663 |
""" |
3799 | 3664 |
_FIELDS_STATIC = utils.FieldSet(constants.SF_NODE) |
3800 |
_OP_PARAMS = [ |
|
3801 |
_POutputFields, |
|
3802 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
3803 |
("storage_type", ht.NoDefault, _CheckStorageType), |
|
3804 |
("name", None, ht.TMaybeString), |
|
3805 |
] |
|
3806 | 3665 |
REQ_BGL = False |
3807 | 3666 |
|
3808 | 3667 |
def CheckArguments(self): |
... | ... | |
3976 | 3835 |
|
3977 | 3836 |
""" |
3978 | 3837 |
# pylint: disable-msg=W0142 |
3979 |
_OP_PARAMS = [ |
|
3980 |
("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY)), |
|
3981 |
("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
3982 |
("filter", None, ht.TOr(ht.TNone, |
|
3983 |
ht.TListOf(ht.TOr(ht.TNonEmptyString, ht.TList)))), |
|
3984 |
] |
|
3985 | 3838 |
REQ_BGL = False |
3986 | 3839 |
|
3987 | 3840 |
def CheckArguments(self): |
... | ... | |
4005 | 3858 |
|
4006 | 3859 |
""" |
4007 | 3860 |
# pylint: disable-msg=W0142 |
4008 |
_OP_PARAMS = [ |
|
4009 |
("what", ht.NoDefault, ht.TElemOf(constants.QR_OP_QUERY)), |
|
4010 |
("fields", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))), |
|
4011 |
] |
|
4012 | 3861 |
REQ_BGL = False |
4013 | 3862 |
|
4014 | 3863 |
def CheckArguments(self): |
... | ... | |
4025 | 3874 |
"""Logical unit for modifying a storage volume on a node. |
4026 | 3875 |
|
4027 | 3876 |
""" |
4028 |
_OP_PARAMS = [ |
|
4029 |
_PNodeName, |
|
4030 |
("storage_type", ht.NoDefault, _CheckStorageType), |
|
4031 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
4032 |
("changes", ht.NoDefault, ht.TDict), |
|
4033 |
] |
|
4034 | 3877 |
REQ_BGL = False |
4035 | 3878 |
|
4036 | 3879 |
def CheckArguments(self): |
... | ... | |
4075 | 3918 |
""" |
4076 | 3919 |
HPATH = "node-add" |
4077 | 3920 |
HTYPE = constants.HTYPE_NODE |
4078 |
_OP_PARAMS = [ |
|
4079 |
_PNodeName, |
|
4080 |
("primary_ip", None, ht.NoType), |
|
4081 |
("secondary_ip", None, ht.TMaybeString), |
|
4082 |
("readd", False, ht.TBool), |
|
4083 |
("group", None, ht.TMaybeString), |
|
4084 |
("master_capable", None, ht.TMaybeBool), |
|
4085 |
("vm_capable", None, ht.TMaybeBool), |
|
4086 |
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
4087 |
] |
|
4088 | 3921 |
_NFLAGS = ["master_capable", "vm_capable"] |
4089 | 3922 |
|
4090 | 3923 |
def CheckArguments(self): |
... | ... | |
4352 | 4185 |
""" |
4353 | 4186 |
HPATH = "node-modify" |
4354 | 4187 |
HTYPE = constants.HTYPE_NODE |
4355 |
_OP_PARAMS = [ |
|
4356 |
_PNodeName, |
|
4357 |
("master_candidate", None, ht.TMaybeBool), |
|
4358 |
("offline", None, ht.TMaybeBool), |
|
4359 |
("drained", None, ht.TMaybeBool), |
|
4360 |
("auto_promote", False, ht.TBool), |
|
4361 |
("master_capable", None, ht.TMaybeBool), |
|
4362 |
("vm_capable", None, ht.TMaybeBool), |
|
4363 |
("secondary_ip", None, ht.TMaybeString), |
|
4364 |
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
4365 |
("powered", None, ht.TMaybeBool), |
|
4366 |
_PForce, |
|
4367 |
] |
|
4368 | 4188 |
REQ_BGL = False |
4369 | 4189 |
(_ROLE_CANDIDATE, _ROLE_DRAINED, _ROLE_OFFLINE, _ROLE_REGULAR) = range(4) |
4370 | 4190 |
_F2R = { |
... | ... | |
4651 | 4471 |
"""Powercycles a node. |
4652 | 4472 |
|
4653 | 4473 |
""" |
4654 |
_OP_PARAMS = [ |
|
4655 |
_PNodeName, |
|
4656 |
_PForce, |
|
4657 |
] |
|
4658 | 4474 |
REQ_BGL = False |
4659 | 4475 |
|
4660 | 4476 |
def CheckArguments(self): |
... | ... | |
4752 | 4568 |
"""Return configuration values. |
4753 | 4569 |
|
4754 | 4570 |
""" |
4755 |
_OP_PARAMS = [_POutputFields] |
|
4756 | 4571 |
REQ_BGL = False |
4757 | 4572 |
_FIELDS_DYNAMIC = utils.FieldSet() |
4758 | 4573 |
_FIELDS_STATIC = utils.FieldSet("cluster_name", "master_node", "drain_flag", |
... | ... | |
4792 | 4607 |
"""Bring up an instance's disks. |
4793 | 4608 |
|
4794 | 4609 |
""" |
4795 |
_OP_PARAMS = [ |
|
4796 |
_PInstanceName, |
|
4797 |
("ignore_size", False, ht.TBool), |
|
4798 |
] |
|
4799 | 4610 |
REQ_BGL = False |
4800 | 4611 |
|
4801 | 4612 |
def ExpandNames(self): |
... | ... | |
4938 | 4749 |
"""Shutdown an instance's disks. |
4939 | 4750 |
|
4940 | 4751 |
""" |
4941 |
_OP_PARAMS = [ |
|
4942 |
_PInstanceName, |
|
4943 |
] |
|
4944 | 4752 |
REQ_BGL = False |
4945 | 4753 |
|
4946 | 4754 |
def ExpandNames(self): |
... | ... | |
5129 | 4937 |
""" |
5130 | 4938 |
HPATH = "instance-start" |
5131 | 4939 |
HTYPE = constants.HTYPE_INSTANCE |
5132 |
_OP_PARAMS = [ |
|
5133 |
_PInstanceName, |
|
5134 |
_PForce, |
|
5135 |
_PIgnoreOfflineNodes, |
|
5136 |
("hvparams", ht.EmptyDict, ht.TDict), |
|
5137 |
("beparams", ht.EmptyDict, ht.TDict), |
|
5138 |
] |
|
5139 | 4940 |
REQ_BGL = False |
5140 | 4941 |
|
5141 | 4942 |
def CheckArguments(self): |
... | ... | |
5237 | 5038 |
""" |
5238 | 5039 |
HPATH = "instance-reboot" |
5239 | 5040 |
HTYPE = constants.HTYPE_INSTANCE |
5240 |
_OP_PARAMS = [ |
|
5241 |
_PInstanceName, |
|
5242 |
("ignore_secondaries", False, ht.TBool), |
|
5243 |
("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES)), |
|
5244 |
_PShutdownTimeout, |
|
5245 |
] |
|
5246 | 5041 |
REQ_BGL = False |
5247 | 5042 |
|
5248 | 5043 |
def ExpandNames(self): |
... | ... | |
5318 | 5113 |
""" |
5319 | 5114 |
HPATH = "instance-stop" |
5320 | 5115 |
HTYPE = constants.HTYPE_INSTANCE |
5321 |
_OP_PARAMS = [ |
|
5322 |
_PInstanceName, |
|
5323 |
_PIgnoreOfflineNodes, |
|
5324 |
("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt), |
|
5325 |
] |
|
5326 | 5116 |
REQ_BGL = False |
5327 | 5117 |
|
5328 | 5118 |
def ExpandNames(self): |
... | ... | |
5385 | 5175 |
""" |
5386 | 5176 |
HPATH = "instance-reinstall" |
5387 | 5177 |
HTYPE = constants.HTYPE_INSTANCE |
5388 |
_OP_PARAMS = [ |
|
5389 |
_PInstanceName, |
|
5390 |
("os_type", None, ht.TMaybeString), |
|
5391 |
("force_variant", False, ht.TBool), |
|
5392 |
("osparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
5393 |
] |
|
5394 | 5178 |
REQ_BGL = False |
5395 | 5179 |
|
5396 | 5180 |
def ExpandNames(self): |
... | ... | |
5477 | 5261 |
""" |
5478 | 5262 |
HPATH = "instance-recreate-disks" |
5479 | 5263 |
HTYPE = constants.HTYPE_INSTANCE |
5480 |
_OP_PARAMS = [ |
|
5481 |
_PInstanceName, |
|
5482 |
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt)), |
|
5483 |
] |
|
5484 | 5264 |
REQ_BGL = False |
5485 | 5265 |
|
5486 | 5266 |
def ExpandNames(self): |
... | ... | |
5541 | 5321 |
""" |
5542 | 5322 |
HPATH = "instance-rename" |
5543 | 5323 |
HTYPE = constants.HTYPE_INSTANCE |
5544 |
_OP_PARAMS = [ |
|
5545 |
_PInstanceName, |
|
5546 |
("new_name", ht.NoDefault, ht.TNonEmptyString), |
|
5547 |
("ip_check", False, ht.TBool), |
|
5548 |
("name_check", True, ht.TBool), |
|
5549 |
] |
|
5550 | 5324 |
|
5551 | 5325 |
def CheckArguments(self): |
5552 | 5326 |
"""Check arguments. |
... | ... | |
5652 | 5426 |
""" |
5653 | 5427 |
HPATH = "instance-remove" |
5654 | 5428 |
HTYPE = constants.HTYPE_INSTANCE |
5655 |
_OP_PARAMS = [ |
|
5656 |
_PInstanceName, |
|
5657 |
("ignore_failures", False, ht.TBool), |
|
5658 |
_PShutdownTimeout, |
|
5659 |
] |
|
5660 | 5429 |
REQ_BGL = False |
5661 | 5430 |
|
5662 | 5431 |
def ExpandNames(self): |
... | ... | |
5739 | 5508 |
|
5740 | 5509 |
""" |
5741 | 5510 |
# pylint: disable-msg=W0142 |
5742 |
_OP_PARAMS = [ |
|
5743 |
_POutputFields, |
|
5744 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
5745 |
("use_locking", False, ht.TBool), |
|
5746 |
] |
|
5747 | 5511 |
REQ_BGL = False |
5748 | 5512 |
|
5749 | 5513 |
def CheckArguments(self): |
... | ... | |
5766 | 5530 |
""" |
5767 | 5531 |
HPATH = "instance-failover" |
5768 | 5532 |
HTYPE = constants.HTYPE_INSTANCE |
5769 |
_OP_PARAMS = [ |
|
5770 |
_PInstanceName, |
|
5771 |
("ignore_consistency", False, ht.TBool), |
|
5772 |
_PShutdownTimeout, |
|
5773 |
] |
|
5774 | 5533 |
REQ_BGL = False |
5775 | 5534 |
|
5776 | 5535 |
def ExpandNames(self): |
... | ... | |
5921 | 5680 |
""" |
5922 | 5681 |
HPATH = "instance-migrate" |
5923 | 5682 |
HTYPE = constants.HTYPE_INSTANCE |
5924 |
_OP_PARAMS = [ |
|
5925 |
_PInstanceName, |
|
5926 |
_PMigrationMode, |
|
5927 |
_PMigrationLive, |
|
5928 |
("cleanup", False, ht.TBool), |
|
5929 |
] |
|
5930 |
|
|
5931 | 5683 |
REQ_BGL = False |
5932 | 5684 |
|
5933 | 5685 |
def ExpandNames(self): |
... | ... | |
5974 | 5726 |
""" |
5975 | 5727 |
HPATH = "instance-move" |
5976 | 5728 |
HTYPE = constants.HTYPE_INSTANCE |
5977 |
_OP_PARAMS = [ |
|
5978 |
_PInstanceName, |
|
5979 |
("target_node", ht.NoDefault, ht.TNonEmptyString), |
|
5980 |
_PShutdownTimeout, |
|
5981 |
] |
|
5982 | 5729 |
REQ_BGL = False |
5983 | 5730 |
|
5984 | 5731 |
def ExpandNames(self): |
... | ... | |
6154 | 5901 |
""" |
6155 | 5902 |
HPATH = "node-migrate" |
6156 | 5903 |
HTYPE = constants.HTYPE_NODE |
6157 |
_OP_PARAMS = [ |
|
6158 |
_PNodeName, |
|
6159 |
_PMigrationMode, |
|
6160 |
_PMigrationLive, |
|
6161 |
] |
|
6162 | 5904 |
REQ_BGL = False |
6163 | 5905 |
|
6164 | 5906 |
def ExpandNames(self): |
... | ... | |
6721 | 6463 |
if len(secondary_nodes) != 0: |
6722 | 6464 |
raise errors.ProgrammerError("Wrong template configuration") |
6723 | 6465 |
|
6724 |
_RequireFileStorage()
|
|
6466 |
opcodes.RequireFileStorage()
|
|
6725 | 6467 |
|
6726 | 6468 |
for idx, disk in enumerate(disk_info): |
6727 | 6469 |
disk_index = idx + base_index |
... | ... | |
7002 | 6744 |
""" |
7003 | 6745 |
HPATH = "instance-add" |
7004 | 6746 |
HTYPE = constants.HTYPE_INSTANCE |
7005 |
_OP_PARAMS = [ |
|
7006 |
_PInstanceName, |
|
7007 |
("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES)), |
|
7008 |
("start", True, ht.TBool), |
|
7009 |
("wait_for_sync", True, ht.TBool), |
|
7010 |
("ip_check", True, ht.TBool), |
|
7011 |
("name_check", True, ht.TBool), |
|
7012 |
("disks", ht.NoDefault, ht.TListOf(ht.TDict)), |
|
7013 |
("nics", ht.NoDefault, ht.TListOf(ht.TDict)), |
|
7014 |
("hvparams", ht.EmptyDict, ht.TDict), |
|
7015 |
("beparams", ht.EmptyDict, ht.TDict), |
|
7016 |
("osparams", ht.EmptyDict, ht.TDict), |
|
7017 |
("no_install", None, ht.TMaybeBool), |
|
7018 |
("os_type", None, ht.TMaybeString), |
|
7019 |
("force_variant", False, ht.TBool), |
|
7020 |
("source_handshake", None, ht.TOr(ht.TList, ht.TNone)), |
|
7021 |
("source_x509_ca", None, ht.TMaybeString), |
|
7022 |
("source_instance_name", None, ht.TMaybeString), |
|
7023 |
("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, |
|
7024 |
ht.TPositiveInt), |
|
7025 |
("src_node", None, ht.TMaybeString), |
|
7026 |
("src_path", None, ht.TMaybeString), |
|
7027 |
("pnode", None, ht.TMaybeString), |
|
7028 |
("snode", None, ht.TMaybeString), |
|
7029 |
("iallocator", None, ht.TMaybeString), |
|
7030 |
("hypervisor", None, ht.TMaybeString), |
|
7031 |
("disk_template", ht.NoDefault, _CheckDiskTemplate), |
|
7032 |
("identify_defaults", False, ht.TBool), |
|
7033 |
("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER))), |
|
7034 |
("file_storage_dir", None, ht.TMaybeString), |
|
7035 |
] |
|
7036 | 6747 |
REQ_BGL = False |
7037 | 6748 |
|
7038 | 6749 |
def CheckArguments(self): |
... | ... | |
7456 | 7167 |
export_info = self._ReadExportInfo() |
7457 | 7168 |
self._ReadExportParams(export_info) |
7458 | 7169 |
|
7459 |
_CheckDiskTemplate(self.op.disk_template) |
|
7460 |
|
|
7461 | 7170 |
if (not self.cfg.GetVGName() and |
7462 | 7171 |
self.op.disk_template not in constants.DTS_NOT_LVM): |
7463 | 7172 |
raise errors.OpPrereqError("Cluster does not support lvm-based" |
... | ... | |
7948 | 7657 |
console. |
7949 | 7658 |
|
7950 | 7659 |
""" |
7951 |
_OP_PARAMS = [ |
|
7952 |
_PInstanceName |
|
7953 |
] |
|
7954 | 7660 |
REQ_BGL = False |
7955 | 7661 |
|
7956 | 7662 |
def ExpandNames(self): |
... | ... | |
8006 | 7712 |
""" |
8007 | 7713 |
HPATH = "mirrors-replace" |
8008 | 7714 |
HTYPE = constants.HTYPE_INSTANCE |
8009 |
_OP_PARAMS = [ |
|
8010 |
_PInstanceName, |
|
8011 |
("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES)), |
|
8012 |
("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt)), |
|
8013 |
("remote_node", None, ht.TMaybeString), |
|
8014 |
("iallocator", None, ht.TMaybeString), |
|
8015 |
("early_release", False, ht.TBool), |
|
8016 |
] |
|
8017 | 7715 |
REQ_BGL = False |
8018 | 7716 |
|
8019 | 7717 |
def CheckArguments(self): |
... | ... | |
8750 | 8448 |
"""Repairs the volume group on a node. |
8751 | 8449 |
|
8752 | 8450 |
""" |
8753 |
_OP_PARAMS = [ |
|
8754 |
_PNodeName, |
|
8755 |
("storage_type", ht.NoDefault, _CheckStorageType), |
|
8756 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
8757 |
("ignore_consistency", False, ht.TBool), |
|
8758 |
] |
|
8759 | 8451 |
REQ_BGL = False |
8760 | 8452 |
|
8761 | 8453 |
def CheckArguments(self): |
... | ... | |
8818 | 8510 |
"""Computes the node evacuation strategy. |
8819 | 8511 |
|
8820 | 8512 |
""" |
8821 |
_OP_PARAMS = [ |
|
8822 |
("nodes", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
8823 |
("remote_node", None, ht.TMaybeString), |
|
8824 |
("iallocator", None, ht.TMaybeString), |
|
8825 |
] |
|
8826 | 8513 |
REQ_BGL = False |
8827 | 8514 |
|
8828 | 8515 |
def CheckArguments(self): |
... | ... | |
8869 | 8556 |
""" |
8870 | 8557 |
HPATH = "disk-grow" |
8871 | 8558 |
HTYPE = constants.HTYPE_INSTANCE |
8872 |
_OP_PARAMS = [ |
|
8873 |
_PInstanceName, |
|
8874 |
("disk", ht.NoDefault, ht.TInt), |
|
8875 |
("amount", ht.NoDefault, ht.TInt), |
|
8876 |
("wait_for_sync", True, ht.TBool), |
|
8877 |
] |
|
8878 | 8559 |
REQ_BGL = False |
8879 | 8560 |
|
8880 | 8561 |
def ExpandNames(self): |
... | ... | |
8969 | 8650 |
"""Query runtime instance data. |
8970 | 8651 |
|
8971 | 8652 |
""" |
8972 |
_OP_PARAMS = [ |
|
8973 |
("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
8974 |
("static", False, ht.TBool), |
|
8975 |
] |
|
8976 | 8653 |
REQ_BGL = False |
8977 | 8654 |
|
8978 | 8655 |
def ExpandNames(self): |
... | ... | |
9129 | 8806 |
""" |
9130 | 8807 |
HPATH = "instance-modify" |
9131 | 8808 |
HTYPE = constants.HTYPE_INSTANCE |
9132 |
_OP_PARAMS = [ |
|
9133 |
_PInstanceName, |
|
9134 |
("nics", ht.EmptyList, ht.TList), |
|
9135 |
("disks", ht.EmptyList, ht.TList), |
|
9136 |
("beparams", ht.EmptyDict, ht.TDict), |
|
9137 |
("hvparams", ht.EmptyDict, ht.TDict), |
|
9138 |
("disk_template", None, ht.TMaybeString), |
|
9139 |
("remote_node", None, ht.TMaybeString), |
|
9140 |
("os_name", None, ht.TMaybeString), |
|
9141 |
("force_variant", False, ht.TBool), |
|
9142 |
("osparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
9143 |
_PForce, |
|
9144 |
] |
|
9145 | 8809 |
REQ_BGL = False |
9146 | 8810 |
|
9147 | 8811 |
def CheckArguments(self): |
... | ... | |
9198 | 8862 |
" changes not supported at the same time", |
9199 | 8863 |
errors.ECODE_INVAL) |
9200 | 8864 |
|
9201 |
if self.op.disk_template: |
|
9202 |
_CheckDiskTemplate(self.op.disk_template) |
|
9203 |
if (self.op.disk_template in constants.DTS_NET_MIRROR and |
|
9204 |
self.op.remote_node is None): |
|
9205 |
raise errors.OpPrereqError("Changing the disk template to a mirrored" |
|
9206 |
" one requires specifying a secondary node", |
|
9207 |
errors.ECODE_INVAL) |
|
8865 |
if (self.op.disk_template and |
|
8866 |
self.op.disk_template in constants.DTS_NET_MIRROR and |
|
8867 |
self.op.remote_node is None): |
|
8868 |
raise errors.OpPrereqError("Changing the disk template to a mirrored" |
|
8869 |
" one requires specifying a secondary node", |
|
8870 |
errors.ECODE_INVAL) |
|
9208 | 8871 |
|
9209 | 8872 |
# NIC validation |
9210 | 8873 |
nic_addremove = 0 |
... | ... | |
9796 | 9459 |
"""Query the exports list |
9797 | 9460 |
|
9798 | 9461 |
""" |
9799 |
_OP_PARAMS = [ |
|
9800 |
("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
9801 |
("use_locking", False, ht.TBool), |
|
9802 |
] |
|
9803 | 9462 |
REQ_BGL = False |
9804 | 9463 |
|
9805 | 9464 |
def ExpandNames(self): |
... | ... | |
9836 | 9495 |
"""Prepares an instance for an export and returns useful information. |
9837 | 9496 |
|
9838 | 9497 |
""" |
9839 |
_OP_PARAMS = [ |
|
9840 |
_PInstanceName, |
|
9841 |
("mode", ht.NoDefault, ht.TElemOf(constants.EXPORT_MODES)), |
|
9842 |
] |
|
9843 | 9498 |
REQ_BGL = False |
9844 | 9499 |
|
9845 | 9500 |
def ExpandNames(self): |
... | ... | |
9893 | 9548 |
""" |
9894 | 9549 |
HPATH = "instance-export" |
9895 | 9550 |
HTYPE = constants.HTYPE_INSTANCE |
9896 |
_OP_PARAMS = [ |
|
9897 |
_PInstanceName, |
|
9898 |
("target_node", ht.NoDefault, ht.TOr(ht.TNonEmptyString, ht.TList)), |
|
9899 |
("shutdown", True, ht.TBool), |
|
9900 |
_PShutdownTimeout, |
|
9901 |
("remove_instance", False, ht.TBool), |
|
9902 |
("ignore_remove_failures", False, ht.TBool), |
|
9903 |
("mode", constants.EXPORT_MODE_LOCAL, ht.TElemOf(constants.EXPORT_MODES)), |
|
9904 |
("x509_key_name", None, ht.TOr(ht.TList, ht.TNone)), |
|
9905 |
("destination_x509_ca", None, ht.TMaybeString), |
|
9906 |
] |
|
9907 | 9551 |
REQ_BGL = False |
9908 | 9552 |
|
9909 | 9553 |
def CheckArguments(self): |
... | ... | |
10190 | 9834 |
"""Remove exports related to the named instance. |
10191 | 9835 |
|
10192 | 9836 |
""" |
10193 |
_OP_PARAMS = [ |
|
10194 |
_PInstanceName, |
|
10195 |
] |
|
10196 | 9837 |
REQ_BGL = False |
10197 | 9838 |
|
10198 | 9839 |
def ExpandNames(self): |
... | ... | |
10242 | 9883 |
""" |
10243 | 9884 |
HPATH = "group-add" |
10244 | 9885 |
HTYPE = constants.HTYPE_GROUP |
10245 |
|
|
10246 |
_OP_PARAMS = [ |
|
10247 |
_PGroupName, |
|
10248 |
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
10249 |
("alloc_policy", None, ht.TOr(ht.TNone, |
|
10250 |
ht.TElemOf(constants.VALID_ALLOC_POLICIES))), |
|
10251 |
] |
|
10252 |
|
|
10253 | 9886 |
REQ_BGL = False |
10254 | 9887 |
|
10255 | 9888 |
def ExpandNames(self): |
... | ... | |
10308 | 9941 |
|
10309 | 9942 |
""" |
10310 | 9943 |
# pylint: disable-msg=W0142 |
10311 |
_OP_PARAMS = [ |
|
10312 |
_POutputFields, |
|
10313 |
("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
10314 |
] |
|
10315 |
|
|
10316 | 9944 |
REQ_BGL = False |
10317 |
|
|
10318 | 9945 |
_FIELDS_DYNAMIC = utils.FieldSet() |
10319 |
|
|
10320 | 9946 |
_SIMPLE_FIELDS = ["name", "uuid", "alloc_policy", |
10321 | 9947 |
"ctime", "mtime", "serial_no"] |
10322 |
|
|
10323 |
_FIELDS_STATIC = utils.FieldSet( |
|
10324 |
"node_cnt", "node_list", "pinst_cnt", "pinst_list", *_SIMPLE_FIELDS) |
|
9948 |
_FIELDS_STATIC = utils.FieldSet("node_cnt", "node_list", "pinst_cnt", |
|
9949 |
"pinst_list", *_SIMPLE_FIELDS) |
|
10325 | 9950 |
|
10326 | 9951 |
def CheckArguments(self): |
10327 | 9952 |
_CheckOutputFields(static=self._FIELDS_STATIC, |
... | ... | |
10418 | 10043 |
""" |
10419 | 10044 |
HPATH = "group-modify" |
10420 | 10045 |
HTYPE = constants.HTYPE_GROUP |
10421 |
|
|
10422 |
_OP_PARAMS = [ |
|
10423 |
_PGroupName, |
|
10424 |
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
10425 |
("alloc_policy", None, ht.TOr(ht.TNone, |
|
10426 |
ht.TElemOf(constants.VALID_ALLOC_POLICIES))), |
|
10427 |
] |
|
10428 |
|
|
10429 | 10046 |
REQ_BGL = False |
10430 | 10047 |
|
10431 | 10048 |
def CheckArguments(self): |
... | ... | |
10492 | 10109 |
class LURemoveGroup(LogicalUnit): |
10493 | 10110 |
HPATH = "group-remove" |
10494 | 10111 |
HTYPE = constants.HTYPE_GROUP |
10495 |
|
|
10496 |
_OP_PARAMS = [ |
|
10497 |
_PGroupName, |
|
10498 |
] |
|
10499 |
|
|
10500 | 10112 |
REQ_BGL = False |
10501 | 10113 |
|
10502 | 10114 |
def ExpandNames(self): |
... | ... | |
10559 | 10171 |
class LURenameGroup(LogicalUnit): |
10560 | 10172 |
HPATH = "group-rename" |
10561 | 10173 |
HTYPE = constants.HTYPE_GROUP |
10562 |
|
|
10563 |
_OP_PARAMS = [ |
|
10564 |
("old_name", ht.NoDefault, ht.TNonEmptyString), |
|
10565 |
("new_name", ht.NoDefault, ht.TNonEmptyString), |
|
10566 |
] |
|
10567 |
|
|
10568 | 10174 |
REQ_BGL = False |
10569 | 10175 |
|
10570 | 10176 |
def ExpandNames(self): |
... | ... | |
10666 | 10272 |
"""Returns the tags of a given object. |
10667 | 10273 |
|
10668 | 10274 |
""" |
10669 |
_OP_PARAMS = [ |
|
10670 |
("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES)), |
|
10671 |
# Name is only meaningful for nodes and instances |
|
10672 |
("name", ht.NoDefault, ht.TMaybeString), |
|
10673 |
] |
|
10674 | 10275 |
REQ_BGL = False |
10675 | 10276 |
|
10676 | 10277 |
def ExpandNames(self): |
... | ... | |
10690 | 10291 |
"""Searches the tags for a given pattern. |
10691 | 10292 |
|
10692 | 10293 |
""" |
10693 |
_OP_PARAMS = [ |
|
10694 |
("pattern", ht.NoDefault, ht.TNonEmptyString), |
|
10695 |
] |
|
10696 | 10294 |
REQ_BGL = False |
10697 | 10295 |
|
10698 | 10296 |
def ExpandNames(self): |
... | ... | |
10732 | 10330 |
"""Sets a tag on a given object. |
10733 | 10331 |
|
10734 | 10332 |
""" |
10735 |
_OP_PARAMS = [ |
|
10736 |
("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES)), |
|
10737 |
# Name is only meaningful for nodes and instances |
|
10738 |
("name", ht.NoDefault, ht.TMaybeString), |
|
10739 |
("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
10740 |
] |
|
10741 | 10333 |
REQ_BGL = False |
10742 | 10334 |
|
10743 | 10335 |
def CheckPrereq(self): |
... | ... | |
10766 | 10358 |
"""Delete a list of tags from a given object. |
10767 | 10359 |
|
10768 | 10360 |
""" |
10769 |
_OP_PARAMS = [ |
|
10770 |
("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES)), |
|
10771 |
# Name is only meaningful for nodes and instances |
|
10772 |
("name", ht.NoDefault, ht.TMaybeString), |
|
10773 |
("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString)), |
|
10774 |
] |
|
10775 | 10361 |
REQ_BGL = False |
10776 | 10362 |
|
10777 | 10363 |
def CheckPrereq(self): |
... | ... | |
10809 | 10395 |
time. |
10810 | 10396 |
|
10811 | 10397 |
""" |
10812 |
_OP_PARAMS = [ |
|
10813 |
("duration", ht.NoDefault, ht.TFloat), |
|
10814 |
("on_master", True, ht.TBool), |
|
10815 |
("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
10816 |
("repeat", 0, ht.TPositiveInt) |
|
10817 |
] |
|
10818 | 10398 |
REQ_BGL = False |
10819 | 10399 |
|
10820 | 10400 |
def ExpandNames(self): |
... | ... | |
10860 | 10440 |
"""Utility LU to test some aspects of the job queue. |
10861 | 10441 |
|
10862 | 10442 |
""" |
10863 |
_OP_PARAMS = [ |
|
10864 |
("notify_waitlock", False, ht.TBool), |
|
10865 |
("notify_exec", False, ht.TBool), |
|
10866 |
("log_messages", ht.EmptyList, ht.TListOf(ht.TString)), |
|
10867 |
("fail", False, ht.TBool), |
|
10868 |
] |
|
10869 | 10443 |
REQ_BGL = False |
10870 | 10444 |
|
10871 | 10445 |
# Must be lower than default timeout for WaitForJobChange to see whether it |
... | ... | |
11363 | 10937 |
This LU runs the allocator tests |
11364 | 10938 |
|
11365 | 10939 |
""" |
11366 |
_OP_PARAMS = [ |
|
11367 |
("direction", ht.NoDefault, |
|
11368 |
ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)), |
|
11369 |
("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES)), |
|
11370 |
("name", ht.NoDefault, ht.TNonEmptyString), |
|
11371 |
("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf( |
|
11372 |
ht.TDictOf(ht.TElemOf(["mac", "ip", "bridge"]), |
|
11373 |
ht.TOr(ht.TNone, ht.TNonEmptyString))))), |
|
11374 |
("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList)), |
|
11375 |
("hypervisor", None, ht.TMaybeString), |
|
11376 |
("allocator", None, ht.TMaybeString), |
|
11377 |
("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString)), |
|
11378 |
("mem_size", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
|
11379 |
("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt)), |
|
11380 |
("os", None, ht.TMaybeString), |
|
11381 |
("disk_template", None, ht.TMaybeString), |
|
11382 |
("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString))), |
|
11383 |
] |
|
11384 |
|
|
11385 | 10940 |
def CheckPrereq(self): |
11386 | 10941 |
"""Check prerequisites. |
11387 | 10942 |
|
Also available in: Unified diff