Revision b8812691 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
246 | 246 |
|
247 | 247 |
@ivar dry_run_result: the value (if any) that will be returned to the caller |
248 | 248 |
in dry-run mode (signalled by opcode dry_run parameter) |
249 |
@cvar _OP_DEFS: a list of opcode attributes and the defaults values
|
|
250 |
they should get if not already existing
|
|
249 |
@cvar _OP_PARAMS: a list of opcode attributes, their defaults values
|
|
250 |
they should get if not already defined, and types they must match
|
|
251 | 251 |
|
252 | 252 |
""" |
253 | 253 |
HPATH = None |
254 | 254 |
HTYPE = None |
255 |
_OP_REQP = [] |
|
256 |
_OP_DEFS = [] |
|
255 |
_OP_PARAMS = [] |
|
257 | 256 |
REQ_BGL = True |
258 | 257 |
|
259 | 258 |
def __init__(self, processor, op, context, rpc): |
... | ... | |
291 | 290 |
# Tasklets |
292 | 291 |
self.tasklets = None |
293 | 292 |
|
294 |
for aname, aval in self._OP_DEFS: |
|
295 |
if not hasattr(self.op, aname): |
|
296 |
if callable(aval): |
|
297 |
dval = aval() |
|
298 |
else: |
|
299 |
dval = aval |
|
300 |
setattr(self.op, aname, dval) |
|
301 |
|
|
302 |
for attr_name, test in self._OP_REQP: |
|
293 |
# The new kind-of-type-system |
|
294 |
op_id = self.op.OP_ID |
|
295 |
for attr_name, aval, test in self._OP_PARAMS: |
|
303 | 296 |
if not hasattr(op, attr_name): |
304 |
raise errors.OpPrereqError("Required parameter '%s' missing" % |
|
305 |
attr_name, errors.ECODE_INVAL) |
|
306 |
attr_val = getattr(op, attr_name, None) |
|
297 |
if aval == _NoDefault: |
|
298 |
raise errors.OpPrereqError("Required parameter '%s.%s' missing" % |
|
299 |
(op_id, attr_name), errors.ECODE_INVAL) |
|
300 |
else: |
|
301 |
if callable(aval): |
|
302 |
dval = aval() |
|
303 |
else: |
|
304 |
dval = aval |
|
305 |
setattr(self.op, attr_name, dval) |
|
306 |
attr_val = getattr(op, attr_name) |
|
307 |
if test == _NoType: |
|
308 |
# no tests here |
|
309 |
continue |
|
307 | 310 |
if not callable(test): |
308 |
raise errors.ProgrammerError("Validation for parameter '%s' failed," |
|
311 |
raise errors.ProgrammerError("Validation for parameter '%s.%s' failed,"
|
|
309 | 312 |
" given type is not a proper type (%s)" % |
310 |
(attr_name, test)) |
|
313 |
(op_id, attr_name, test))
|
|
311 | 314 |
if not test(attr_val): |
312 | 315 |
logging.error("OpCode %s, parameter %s, has invalid type %s/value %s", |
313 | 316 |
self.op.OP_ID, attr_name, type(attr_val), attr_val) |
314 |
raise errors.OpPrereqError("Parameter '%s' has invalid type" %
|
|
315 |
attr_name, errors.ECODE_INVAL)
|
|
317 |
raise errors.OpPrereqError("Parameter '%s.%s' fails validation" %
|
|
318 |
(op_id, attr_name), errors.ECODE_INVAL)
|
|
316 | 319 |
|
317 | 320 |
self.CheckArguments() |
318 | 321 |
|
... | ... | |
1160 | 1163 |
""" |
1161 | 1164 |
HPATH = "cluster-init" |
1162 | 1165 |
HTYPE = constants.HTYPE_CLUSTER |
1163 |
_OP_REQP = [] |
|
1164 | 1166 |
|
1165 | 1167 |
def BuildHooksEnv(self): |
1166 | 1168 |
"""Build hooks env. |
... | ... | |
1183 | 1185 |
""" |
1184 | 1186 |
HPATH = "cluster-destroy" |
1185 | 1187 |
HTYPE = constants.HTYPE_CLUSTER |
1186 |
_OP_REQP = [] |
|
1187 | 1188 |
|
1188 | 1189 |
def BuildHooksEnv(self): |
1189 | 1190 |
"""Build hooks env. |
... | ... | |
1278 | 1279 |
""" |
1279 | 1280 |
HPATH = "cluster-verify" |
1280 | 1281 |
HTYPE = constants.HTYPE_CLUSTER |
1281 |
_OP_REQP = [ |
|
1282 |
("skip_checks", _TListOf(_TElemOf(constants.VERIFY_OPTIONAL_CHECKS))), |
|
1283 |
("verbose", _TBool), |
|
1284 |
("error_codes", _TBool), |
|
1285 |
("debug_simulate_errors", _TBool), |
|
1282 |
_OP_PARAMS = [ |
|
1283 |
("skip_checks", _EmptyList, |
|
1284 |
_TListOf(_TElemOf(constants.VERIFY_OPTIONAL_CHECKS))), |
|
1285 |
("verbose", False, _TBool), |
|
1286 |
("error_codes", False, _TBool), |
|
1287 |
("debug_simulate_errors", False, _TBool), |
|
1286 | 1288 |
] |
1287 | 1289 |
REQ_BGL = False |
1288 | 1290 |
|
... | ... | |
2261 | 2263 |
"""Verifies the cluster disks status. |
2262 | 2264 |
|
2263 | 2265 |
""" |
2264 |
_OP_REQP = [] |
|
2265 | 2266 |
REQ_BGL = False |
2266 | 2267 |
|
2267 | 2268 |
def ExpandNames(self): |
... | ... | |
2336 | 2337 |
"""Verifies the cluster disks sizes. |
2337 | 2338 |
|
2338 | 2339 |
""" |
2339 |
_OP_REQP = [("instances", _TListOf(_TNonEmptyString))]
|
|
2340 |
_OP_PARAMS = [("instances", _EmptyList, _TListOf(_TNonEmptyString))]
|
|
2340 | 2341 |
REQ_BGL = False |
2341 | 2342 |
|
2342 | 2343 |
def ExpandNames(self): |
... | ... | |
2454 | 2455 |
""" |
2455 | 2456 |
HPATH = "cluster-rename" |
2456 | 2457 |
HTYPE = constants.HTYPE_CLUSTER |
2457 |
_OP_REQP = [("name", _TNonEmptyString)]
|
|
2458 |
_OP_PARAMS = [("name", _NoDefault, _TNonEmptyString)]
|
|
2458 | 2459 |
|
2459 | 2460 |
def BuildHooksEnv(self): |
2460 | 2461 |
"""Build hooks env. |
... | ... | |
2554 | 2555 |
""" |
2555 | 2556 |
HPATH = "cluster-modify" |
2556 | 2557 |
HTYPE = constants.HTYPE_CLUSTER |
2557 |
_OP_REQP = [ |
|
2558 |
("hvparams", _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2559 |
("os_hvp", _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2560 |
("osparams", _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2561 |
("enabled_hypervisors", |
|
2558 |
_OP_PARAMS = [ |
|
2559 |
("vg_name", None, _TMaybeString), |
|
2560 |
("enabled_hypervisors", None, |
|
2562 | 2561 |
_TOr(_TAnd(_TListOf(_TElemOf(constants.HYPER_TYPES)), _TTrue), _TNone)), |
2563 |
] |
|
2564 |
_OP_DEFS = [ |
|
2565 |
("candidate_pool_size", None), |
|
2566 |
("uid_pool", None), |
|
2567 |
("add_uids", None), |
|
2568 |
("remove_uids", None), |
|
2569 |
("hvparams", None), |
|
2570 |
("os_hvp", None), |
|
2571 |
("osparams", None), |
|
2562 |
("hvparams", None, _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2563 |
("beparams", None, _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2564 |
("os_hvp", None, _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2565 |
("osparams", None, _TOr(_TDictOf(_TNonEmptyString, _TDict), _TNone)), |
|
2566 |
("candidate_pool_size", None, _TOr(_TStrictPositiveInt, _TNone)), |
|
2567 |
("uid_pool", None, _NoType), |
|
2568 |
("add_uids", None, _NoType), |
|
2569 |
("remove_uids", None, _NoType), |
|
2570 |
("maintain_node_health", None, _TMaybeBool), |
|
2571 |
("nicparams", None, _TOr(_TDict, _TNone)), |
|
2572 | 2572 |
] |
2573 | 2573 |
REQ_BGL = False |
2574 | 2574 |
|
... | ... | |
2576 | 2576 |
"""Check parameters |
2577 | 2577 |
|
2578 | 2578 |
""" |
2579 |
if self.op.candidate_pool_size is not None: |
|
2580 |
try: |
|
2581 |
self.op.candidate_pool_size = int(self.op.candidate_pool_size) |
|
2582 |
except (ValueError, TypeError), err: |
|
2583 |
raise errors.OpPrereqError("Invalid candidate_pool_size value: %s" % |
|
2584 |
str(err), errors.ECODE_INVAL) |
|
2585 |
if self.op.candidate_pool_size < 1: |
|
2586 |
raise errors.OpPrereqError("At least one master candidate needed", |
|
2587 |
errors.ECODE_INVAL) |
|
2588 |
|
|
2589 |
_CheckBooleanOpField(self.op, "maintain_node_health") |
|
2590 |
|
|
2591 | 2579 |
if self.op.uid_pool: |
2592 | 2580 |
uidpool.CheckUidPool(self.op.uid_pool) |
2593 | 2581 |
|
... | ... | |
2865 | 2853 |
This is a very simple LU. |
2866 | 2854 |
|
2867 | 2855 |
""" |
2868 |
_OP_REQP = [] |
|
2869 | 2856 |
REQ_BGL = False |
2870 | 2857 |
|
2871 | 2858 |
def ExpandNames(self): |
... | ... | |
2995 | 2982 |
"""Logical unit for OS diagnose/query. |
2996 | 2983 |
|
2997 | 2984 |
""" |
2998 |
_OP_REQP = [
|
|
2999 |
("output_fields", _TListOf(_TNonEmptyString)),
|
|
3000 |
("names", _TListOf(_TNonEmptyString)), |
|
2985 |
_OP_PARAMS = [
|
|
2986 |
_POutputFields,
|
|
2987 |
("names", _EmptyList, _TListOf(_TNonEmptyString)),
|
|
3001 | 2988 |
] |
3002 | 2989 |
REQ_BGL = False |
3003 | 2990 |
_FIELDS_STATIC = utils.FieldSet() |
... | ... | |
3119 | 3106 |
""" |
3120 | 3107 |
HPATH = "node-remove" |
3121 | 3108 |
HTYPE = constants.HTYPE_NODE |
3122 |
_OP_REQP = [("node_name", _TNonEmptyString)] |
|
3109 |
_OP_PARAMS = [ |
|
3110 |
_PNodeName, |
|
3111 |
] |
|
3123 | 3112 |
|
3124 | 3113 |
def BuildHooksEnv(self): |
3125 | 3114 |
"""Build hooks env. |
... | ... | |
3212 | 3201 |
|
3213 | 3202 |
""" |
3214 | 3203 |
# pylint: disable-msg=W0142 |
3215 |
_OP_REQP = [
|
|
3216 |
("output_fields", _TListOf(_TNonEmptyString)),
|
|
3217 |
("names", _TListOf(_TNonEmptyString)), |
|
3218 |
("use_locking", _TBool), |
|
3204 |
_OP_PARAMS = [
|
|
3205 |
_POutputFields,
|
|
3206 |
("names", _EmptyList, _TListOf(_TNonEmptyString)),
|
|
3207 |
("use_locking", False, _TBool),
|
|
3219 | 3208 |
] |
3220 | 3209 |
REQ_BGL = False |
3221 | 3210 |
|
... | ... | |
3369 | 3358 |
"""Logical unit for getting volumes on node(s). |
3370 | 3359 |
|
3371 | 3360 |
""" |
3372 |
_OP_REQP = [
|
|
3373 |
("nodes", _TListOf(_TNonEmptyString)), |
|
3374 |
("output_fields", _TListOf(_TNonEmptyString)), |
|
3361 |
_OP_PARAMS = [
|
|
3362 |
("nodes", _EmptyList, _TListOf(_TNonEmptyString)),
|
|
3363 |
("output_fields", _NoDefault, _TListOf(_TNonEmptyString)),
|
|
3375 | 3364 |
] |
3376 | 3365 |
REQ_BGL = False |
3377 | 3366 |
_FIELDS_DYNAMIC = utils.FieldSet("phys", "vg", "name", "size", "instance") |
... | ... | |
3452 | 3441 |
|
3453 | 3442 |
""" |
3454 | 3443 |
_FIELDS_STATIC = utils.FieldSet(constants.SF_NODE) |
3455 |
_OP_REQP = [ |
|
3456 |
("nodes", _TListOf(_TNonEmptyString)), |
|
3457 |
("storage_type", _CheckStorageType), |
|
3458 |
("output_fields", _TListOf(_TNonEmptyString)), |
|
3444 |
_OP_PARAMS = [ |
|
3445 |
("nodes", _EmptyList, _TListOf(_TNonEmptyString)), |
|
3446 |
("storage_type", _NoDefault, _CheckStorageType), |
|
3447 |
("output_fields", _NoDefault, _TListOf(_TNonEmptyString)), |
|
3448 |
("name", None, _TMaybeString), |
|
3459 | 3449 |
] |
3460 |
_OP_DEFS = [("name", None)] |
|
3461 | 3450 |
REQ_BGL = False |
3462 | 3451 |
|
3463 | 3452 |
def CheckArguments(self): |
... | ... | |
3540 | 3529 |
"""Logical unit for modifying a storage volume on a node. |
3541 | 3530 |
|
3542 | 3531 |
""" |
3543 |
_OP_REQP = [
|
|
3544 |
("node_name", _TNonEmptyString),
|
|
3545 |
("storage_type", _CheckStorageType), |
|
3546 |
("name", _TNonEmptyString), |
|
3547 |
("changes", _TDict), |
|
3532 |
_OP_PARAMS = [
|
|
3533 |
_PNodeName,
|
|
3534 |
("storage_type", _NoDefault, _CheckStorageType),
|
|
3535 |
("name", _NoDefault, _TNonEmptyString),
|
|
3536 |
("changes", _NoDefault, _TDict),
|
|
3548 | 3537 |
] |
3549 | 3538 |
REQ_BGL = False |
3550 | 3539 |
|
... | ... | |
3590 | 3579 |
""" |
3591 | 3580 |
HPATH = "node-add" |
3592 | 3581 |
HTYPE = constants.HTYPE_NODE |
3593 |
_OP_REQP = [ |
|
3594 |
("node_name", _TNonEmptyString), |
|
3582 |
_OP_PARAMS = [ |
|
3583 |
_PNodeName, |
|
3584 |
("primary_ip", None, _NoType), |
|
3585 |
("secondary_ip", None, _TMaybeString), |
|
3586 |
("readd", False, _TBool), |
|
3595 | 3587 |
] |
3596 |
_OP_DEFS = [("secondary_ip", None)] |
|
3597 | 3588 |
|
3598 | 3589 |
def CheckArguments(self): |
3599 | 3590 |
# validate/normalize the node name |
... | ... | |
3823 | 3814 |
""" |
3824 | 3815 |
HPATH = "node-modify" |
3825 | 3816 |
HTYPE = constants.HTYPE_NODE |
3826 |
_OP_REQP = [("node_name", _TNonEmptyString)] |
|
3817 |
_OP_PARAMS = [ |
|
3818 |
_PNodeName, |
|
3819 |
("master_candidate", None, _TMaybeBool), |
|
3820 |
("offline", None, _TMaybeBool), |
|
3821 |
("drained", None, _TMaybeBool), |
|
3822 |
("auto_promote", False, _TBool), |
|
3823 |
_PForce, |
|
3824 |
] |
|
3827 | 3825 |
REQ_BGL = False |
3828 | 3826 |
|
3829 | 3827 |
def CheckArguments(self): |
3830 | 3828 |
self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name) |
3831 |
_CheckBooleanOpField(self.op, 'master_candidate') |
|
3832 |
_CheckBooleanOpField(self.op, 'offline') |
|
3833 |
_CheckBooleanOpField(self.op, 'drained') |
|
3834 |
_CheckBooleanOpField(self.op, 'auto_promote') |
|
3835 | 3829 |
all_mods = [self.op.offline, self.op.master_candidate, self.op.drained] |
3836 | 3830 |
if all_mods.count(None) == 3: |
3837 | 3831 |
raise errors.OpPrereqError("Please pass at least one modification", |
... | ... | |
3984 | 3978 |
"""Powercycles a node. |
3985 | 3979 |
|
3986 | 3980 |
""" |
3987 |
_OP_REQP = [
|
|
3988 |
("node_name", _TNonEmptyString),
|
|
3989 |
("force", _TBool),
|
|
3981 |
_OP_PARAMS = [
|
|
3982 |
_PNodeName,
|
|
3983 |
_PForce,
|
|
3990 | 3984 |
] |
3991 | 3985 |
REQ_BGL = False |
3992 | 3986 |
|
... | ... | |
4020 | 4014 |
"""Query cluster configuration. |
4021 | 4015 |
|
4022 | 4016 |
""" |
4023 |
_OP_REQP = [] |
|
4024 | 4017 |
REQ_BGL = False |
4025 | 4018 |
|
4026 | 4019 |
def ExpandNames(self): |
... | ... | |
4076 | 4069 |
"""Return configuration values. |
4077 | 4070 |
|
4078 | 4071 |
""" |
4079 |
_OP_REQP = []
|
|
4072 |
_OP_PARAMS = [_POutputFields]
|
|
4080 | 4073 |
REQ_BGL = False |
4081 | 4074 |
_FIELDS_DYNAMIC = utils.FieldSet() |
4082 | 4075 |
_FIELDS_STATIC = utils.FieldSet("cluster_name", "master_node", "drain_flag", |
... | ... | |
4114 | 4107 |
"""Bring up an instance's disks. |
4115 | 4108 |
|
4116 | 4109 |
""" |
4117 |
_OP_REQP = [("instance_name", _TNonEmptyString)] |
|
4118 |
_OP_DEFS = [("ignore_size", False)] |
|
4110 |
_OP_PARAMS = [ |
|
4111 |
_PInstanceName, |
|
4112 |
("ignore_size", False, _TBool), |
|
4113 |
] |
|
4119 | 4114 |
REQ_BGL = False |
4120 | 4115 |
|
4121 | 4116 |
def ExpandNames(self): |
... | ... | |
4258 | 4253 |
"""Shutdown an instance's disks. |
4259 | 4254 |
|
4260 | 4255 |
""" |
4261 |
_OP_REQP = [("instance_name", _TNonEmptyString)] |
|
4256 |
_OP_PARAMS = [ |
|
4257 |
_PInstanceName, |
|
4258 |
] |
|
4262 | 4259 |
REQ_BGL = False |
4263 | 4260 |
|
4264 | 4261 |
def ExpandNames(self): |
... | ... | |
4421 | 4418 |
""" |
4422 | 4419 |
HPATH = "instance-start" |
4423 | 4420 |
HTYPE = constants.HTYPE_INSTANCE |
4424 |
_OP_REQP = [ |
|
4425 |
("instance_name", _TNonEmptyString), |
|
4426 |
("force", _TBool), |
|
4427 |
("beparams", _TDict), |
|
4428 |
("hvparams", _TDict), |
|
4429 |
] |
|
4430 |
_OP_DEFS = [ |
|
4431 |
("beparams", _EmptyDict), |
|
4432 |
("hvparams", _EmptyDict), |
|
4421 |
_OP_PARAMS = [ |
|
4422 |
_PInstanceName, |
|
4423 |
_PForce, |
|
4424 |
("hvparams", _EmptyDict, _TDict), |
|
4425 |
("beparams", _EmptyDict, _TDict), |
|
4433 | 4426 |
] |
4434 | 4427 |
REQ_BGL = False |
4435 | 4428 |
|
... | ... | |
4519 | 4512 |
""" |
4520 | 4513 |
HPATH = "instance-reboot" |
4521 | 4514 |
HTYPE = constants.HTYPE_INSTANCE |
4522 |
_OP_REQP = [ |
|
4523 |
("instance_name", _TNonEmptyString), |
|
4524 |
("ignore_secondaries", _TBool), |
|
4525 |
("reboot_type", _TElemOf(constants.REBOOT_TYPES)), |
|
4515 |
_OP_PARAMS = [ |
|
4516 |
_PInstanceName, |
|
4517 |
("ignore_secondaries", False, _TBool), |
|
4518 |
("reboot_type", _NoDefault, _TElemOf(constants.REBOOT_TYPES)), |
|
4519 |
_PShutdownTimeout, |
|
4526 | 4520 |
] |
4527 |
_OP_DEFS = [("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT)] |
|
4528 | 4521 |
REQ_BGL = False |
4529 | 4522 |
|
4530 | 4523 |
def ExpandNames(self): |
... | ... | |
4600 | 4593 |
""" |
4601 | 4594 |
HPATH = "instance-stop" |
4602 | 4595 |
HTYPE = constants.HTYPE_INSTANCE |
4603 |
_OP_REQP = [("instance_name", _TNonEmptyString)] |
|
4604 |
_OP_DEFS = [("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT)] |
|
4596 |
_OP_PARAMS = [ |
|
4597 |
_PInstanceName, |
|
4598 |
("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, _TPositiveInt), |
|
4599 |
] |
|
4605 | 4600 |
REQ_BGL = False |
4606 | 4601 |
|
4607 | 4602 |
def ExpandNames(self): |
... | ... | |
4651 | 4646 |
""" |
4652 | 4647 |
HPATH = "instance-reinstall" |
4653 | 4648 |
HTYPE = constants.HTYPE_INSTANCE |
4654 |
_OP_REQP = [("instance_name", _TNonEmptyString)]
|
|
4655 |
_OP_DEFS = [
|
|
4656 |
("os_type", None), |
|
4657 |
("force_variant", False), |
|
4649 |
_OP_PARAMS = [
|
|
4650 |
_PInstanceName,
|
|
4651 |
("os_type", None, _TMaybeString),
|
|
4652 |
("force_variant", False, _TBool),
|
|
4658 | 4653 |
] |
4659 | 4654 |
REQ_BGL = False |
4660 | 4655 |
|
... | ... | |
4724 | 4719 |
""" |
4725 | 4720 |
HPATH = "instance-recreate-disks" |
4726 | 4721 |
HTYPE = constants.HTYPE_INSTANCE |
4727 |
_OP_REQP = [
|
|
4728 |
("instance_name", _TNonEmptyString),
|
|
4729 |
("disks", _TListOf(_TPositiveInt)), |
|
4722 |
_OP_PARAMS = [
|
|
4723 |
_PInstanceName,
|
|
4724 |
("disks", _EmptyList, _TListOf(_TPositiveInt)),
|
|
4730 | 4725 |
] |
4731 | 4726 |
REQ_BGL = False |
4732 | 4727 |
|
... | ... | |
4788 | 4783 |
""" |
4789 | 4784 |
HPATH = "instance-rename" |
4790 | 4785 |
HTYPE = constants.HTYPE_INSTANCE |
4791 |
_OP_REQP = [
|
|
4792 |
("instance_name", _TNonEmptyString),
|
|
4793 |
("new_name", _TNonEmptyString), |
|
4794 |
("ignore_ip", _TBool), |
|
4795 |
("check_name", _TBool), |
|
4786 |
_OP_PARAMS = [
|
|
4787 |
_PInstanceName,
|
|
4788 |
("new_name", _NoDefault, _TNonEmptyString),
|
|
4789 |
("ignore_ip", False, _TBool),
|
|
4790 |
("check_name", True, _TBool),
|
|
4796 | 4791 |
] |
4797 |
_OP_DEFS = [("ignore_ip", False), ("check_name", True)] |
|
4798 | 4792 |
|
4799 | 4793 |
def BuildHooksEnv(self): |
4800 | 4794 |
"""Build hooks env. |
... | ... | |
4887 | 4881 |
""" |
4888 | 4882 |
HPATH = "instance-remove" |
4889 | 4883 |
HTYPE = constants.HTYPE_INSTANCE |
4890 |
_OP_REQP = [ |
|
4891 |
("instance_name", _TNonEmptyString), |
|
4892 |
("ignore_failures", _TBool), |
|
4884 |
_OP_PARAMS = [ |
|
4885 |
_PInstanceName, |
|
4886 |
("ignore_failures", False, _TBool), |
|
4887 |
_PShutdownTimeout, |
|
4893 | 4888 |
] |
4894 |
_OP_DEFS = [("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT)] |
|
4895 | 4889 |
REQ_BGL = False |
4896 | 4890 |
|
4897 | 4891 |
def ExpandNames(self): |
... | ... | |
4974 | 4968 |
|
4975 | 4969 |
""" |
4976 | 4970 |
# pylint: disable-msg=W0142 |
4977 |
_OP_REQP = [
|
|
4978 |
("output_fields", _TListOf(_TNonEmptyString)), |
|
4979 |
("names", _TListOf(_TNonEmptyString)), |
|
4980 |
("use_locking", _TBool), |
|
4971 |
_OP_PARAMS = [
|
|
4972 |
("output_fields", _NoDefault, _TListOf(_TNonEmptyString)),
|
|
4973 |
("names", _EmptyList, _TListOf(_TNonEmptyString)),
|
|
4974 |
("use_locking", False, _TBool),
|
|
4981 | 4975 |
] |
4982 | 4976 |
REQ_BGL = False |
4983 | 4977 |
_SIMPLE_FIELDS = ["name", "os", "network_port", "hypervisor", |
... | ... | |
5256 | 5250 |
""" |
5257 | 5251 |
HPATH = "instance-failover" |
5258 | 5252 |
HTYPE = constants.HTYPE_INSTANCE |
5259 |
_OP_REQP = [ |
|
5260 |
("instance_name", _TNonEmptyString), |
|
5261 |
("ignore_consistency", _TBool), |
|
5253 |
_OP_PARAMS = [ |
|
5254 |
_PInstanceName, |
|
5255 |
("ignore_consistency", False, _TBool), |
|
5256 |
_PShutdownTimeout, |
|
5262 | 5257 |
] |
5263 |
_OP_DEFS = [("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT)] |
|
5264 | 5258 |
REQ_BGL = False |
5265 | 5259 |
|
5266 | 5260 |
def ExpandNames(self): |
... | ... | |
5410 | 5404 |
""" |
5411 | 5405 |
HPATH = "instance-migrate" |
5412 | 5406 |
HTYPE = constants.HTYPE_INSTANCE |
5413 |
_OP_REQP = [
|
|
5414 |
("instance_name", _TNonEmptyString),
|
|
5415 |
("live", _TBool), |
|
5416 |
("cleanup", _TBool), |
|
5407 |
_OP_PARAMS = [
|
|
5408 |
_PInstanceName,
|
|
5409 |
("live", True, _TBool),
|
|
5410 |
("cleanup", False, _TBool),
|
|
5417 | 5411 |
] |
5418 | 5412 |
|
5419 | 5413 |
REQ_BGL = False |
... | ... | |
5462 | 5456 |
""" |
5463 | 5457 |
HPATH = "instance-move" |
5464 | 5458 |
HTYPE = constants.HTYPE_INSTANCE |
5465 |
_OP_REQP = [ |
|
5466 |
("instance_name", _TNonEmptyString), |
|
5467 |
("target_node", _TNonEmptyString), |
|
5459 |
_OP_PARAMS = [ |
|
5460 |
_PInstanceName, |
|
5461 |
("target_node", _NoDefault, _TNonEmptyString), |
|
5462 |
_PShutdownTimeout, |
|
5468 | 5463 |
] |
5469 |
_OP_DEFS = [("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT)] |
|
5470 | 5464 |
REQ_BGL = False |
5471 | 5465 |
|
5472 | 5466 |
def ExpandNames(self): |
... | ... | |
5641 | 5635 |
""" |
5642 | 5636 |
HPATH = "node-migrate" |
5643 | 5637 |
HTYPE = constants.HTYPE_NODE |
5644 |
_OP_REQP = [
|
|
5645 |
("node_name", _TNonEmptyString),
|
|
5646 |
("live", _TBool), |
|
5638 |
_OP_PARAMS = [
|
|
5639 |
_PNodeName,
|
|
5640 |
("live", False, _TBool),
|
|
5647 | 5641 |
] |
5648 | 5642 |
REQ_BGL = False |
5649 | 5643 |
|
... | ... | |
6378 | 6372 |
""" |
6379 | 6373 |
HPATH = "instance-add" |
6380 | 6374 |
HTYPE = constants.HTYPE_INSTANCE |
6381 |
_OP_REQP = [ |
|
6382 |
("instance_name", _TNonEmptyString), |
|
6383 |
("mode", _TElemOf(constants.INSTANCE_CREATE_MODES)), |
|
6384 |
("start", _TBool), |
|
6385 |
("wait_for_sync", _TBool), |
|
6386 |
("ip_check", _TBool), |
|
6387 |
("disks", _TListOf(_TDict)), |
|
6388 |
("nics", _TListOf(_TDict)), |
|
6389 |
("hvparams", _TDict), |
|
6390 |
("beparams", _TDict), |
|
6391 |
("osparams", _TDict), |
|
6392 |
] |
|
6393 |
_OP_DEFS = [ |
|
6394 |
("name_check", True), |
|
6395 |
("no_install", False), |
|
6396 |
("os_type", None), |
|
6397 |
("force_variant", False), |
|
6398 |
("source_handshake", None), |
|
6399 |
("source_x509_ca", None), |
|
6400 |
("source_instance_name", None), |
|
6401 |
("src_node", None), |
|
6402 |
("src_path", None), |
|
6403 |
("pnode", None), |
|
6404 |
("snode", None), |
|
6405 |
("iallocator", None), |
|
6406 |
("hypervisor", None), |
|
6407 |
("disk_template", None), |
|
6408 |
("identify_defaults", None), |
|
6375 |
_OP_PARAMS = [ |
|
6376 |
_PInstanceName, |
|
6377 |
("mode", _NoDefault, _TElemOf(constants.INSTANCE_CREATE_MODES)), |
|
6378 |
("start", True, _TBool), |
|
6379 |
("wait_for_sync", True, _TBool), |
|
6380 |
("ip_check", True, _TBool), |
|
6381 |
("name_check", True, _TBool), |
|
6382 |
("disks", _NoDefault, _TListOf(_TDict)), |
|
6383 |
("nics", _NoDefault, _TListOf(_TDict)), |
|
6384 |
("hvparams", _NoDefault, _TDict), |
|
6385 |
("beparams", _NoDefault, _TDict), |
|
6386 |
("osparams", _NoDefault, _TDict), |
|
6387 |
("no_install", None, _TMaybeBool), |
|
6388 |
("os_type", None, _TMaybeString), |
|
6389 |
("force_variant", False, _TBool), |
|
6390 |
("source_handshake", None, _TOr(_TList, _TNone)), |
|
6391 |
("source_x509_ca", None, _TOr(_TList, _TNone)), |
|
6392 |
("source_instance_name", None, _TMaybeString), |
|
6393 |
("src_node", None, _TMaybeString), |
|
6394 |
("src_path", None, _TMaybeString), |
|
6395 |
("pnode", None, _TMaybeString), |
|
6396 |
("snode", None, _TMaybeString), |
|
6397 |
("iallocator", None, _TMaybeString), |
|
6398 |
("hypervisor", None, _TMaybeString), |
|
6399 |
("disk_template", _NoDefault, _CheckDiskTemplate), |
|
6400 |
("identify_defaults", False, _TBool), |
|
6401 |
("file_driver", None, _TOr(_TNone, _TElemOf(constants.FILE_DRIVER))), |
|
6402 |
("file_storage_dir", None, _TMaybeString), |
|
6403 |
("dry_run", False, _TBool), |
|
6409 | 6404 |
] |
6410 | 6405 |
REQ_BGL = False |
6411 | 6406 |
|
... | ... | |
7287 | 7282 |
console. |
7288 | 7283 |
|
7289 | 7284 |
""" |
7290 |
_OP_REQP = [("instance_name", _TNonEmptyString)] |
|
7285 |
_OP_PARAMS = [ |
|
7286 |
_PInstanceName |
|
7287 |
] |
|
7291 | 7288 |
REQ_BGL = False |
7292 | 7289 |
|
7293 | 7290 |
def ExpandNames(self): |
... | ... | |
7338 | 7335 |
""" |
7339 | 7336 |
HPATH = "mirrors-replace" |
7340 | 7337 |
HTYPE = constants.HTYPE_INSTANCE |
7341 |
_OP_REQP = [ |
|
7342 |
("instance_name", _TNonEmptyString), |
|
7343 |
("mode", _TElemOf(constants.REPLACE_MODES)), |
|
7344 |
("disks", _TListOf(_TPositiveInt)), |
|
7345 |
] |
|
7346 |
_OP_DEFS = [ |
|
7347 |
("remote_node", None), |
|
7348 |
("iallocator", None), |
|
7349 |
("early_release", None), |
|
7338 |
_OP_PARAMS = [ |
|
7339 |
_PInstanceName, |
|
7340 |
("mode", _NoDefault, _TElemOf(constants.REPLACE_MODES)), |
|
7341 |
("disks", _EmptyList, _TListOf(_TPositiveInt)), |
|
7342 |
("remote_node", None, _TMaybeString), |
|
7343 |
("iallocator", None, _TMaybeString), |
|
7344 |
("early_release", False, _TBool), |
|
7350 | 7345 |
] |
7351 | 7346 |
REQ_BGL = False |
7352 | 7347 |
|
... | ... | |
8083 | 8078 |
"""Repairs the volume group on a node. |
8084 | 8079 |
|
8085 | 8080 |
""" |
8086 |
_OP_REQP = [("node_name", _TNonEmptyString)] |
|
8081 |
_OP_PARAMS = [ |
|
8082 |
_PNodeName, |
|
8083 |
("storage_type", _NoDefault, _CheckStorageType), |
|
8084 |
("name", _NoDefault, _TNonEmptyString), |
|
8085 |
("ignore_consistency", False, _TBool), |
|
8086 |
] |
|
8087 | 8087 |
REQ_BGL = False |
8088 | 8088 |
|
8089 | 8089 |
def CheckArguments(self): |
8090 | 8090 |
self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name) |
8091 | 8091 |
|
8092 |
_CheckStorageType(self.op.storage_type) |
|
8093 |
|
|
8094 | 8092 |
storage_type = self.op.storage_type |
8095 | 8093 |
|
8096 | 8094 |
if (constants.SO_FIX_CONSISTENCY not in |
... | ... | |
8148 | 8146 |
"""Computes the node evacuation strategy. |
8149 | 8147 |
|
8150 | 8148 |
""" |
8151 |
_OP_REQP = [("nodes", _TListOf(_TNonEmptyString))]
|
|
8152 |
_OP_DEFS = [
|
|
8153 |
("remote_node", None), |
|
8154 |
("iallocator", None), |
|
8149 |
_OP_PARAMS = [
|
|
8150 |
("nodes", _NoDefault, _TListOf(_TNonEmptyString)),
|
|
8151 |
("remote_node", None, _TMaybeString),
|
|
8152 |
("iallocator", None, _TMaybeString),
|
|
8155 | 8153 |
] |
8156 | 8154 |
REQ_BGL = False |
8157 | 8155 |
|
... | ... | |
8201 | 8199 |
""" |
8202 | 8200 |
HPATH = "disk-grow" |
8203 | 8201 |
HTYPE = constants.HTYPE_INSTANCE |
8204 |
_OP_REQP = [
|
|
8205 |
("instance_name", _TNonEmptyString),
|
|
8206 |
("disk", _TInt), |
|
8207 |
("amount", _TInt), |
|
8208 |
("wait_for_sync", _TBool), |
|
8202 |
_OP_PARAMS = [
|
|
8203 |
_PInstanceName,
|
|
8204 |
("disk", _NoDefault, _TInt),
|
|
8205 |
("amount", _NoDefault, _TInt),
|
|
8206 |
("wait_for_sync", True, _TBool),
|
|
8209 | 8207 |
] |
8210 | 8208 |
REQ_BGL = False |
8211 | 8209 |
|
... | ... | |
8300 | 8298 |
"""Query runtime instance data. |
8301 | 8299 |
|
8302 | 8300 |
""" |
8303 |
_OP_REQP = [
|
|
8304 |
("instances", _TListOf(_TNonEmptyString)), |
|
8305 |
("static", _TBool), |
|
8301 |
_OP_PARAMS = [
|
|
8302 |
("instances", _EmptyList, _TListOf(_TNonEmptyString)),
|
|
8303 |
("static", False, _TBool),
|
|
8306 | 8304 |
] |
8307 | 8305 |
REQ_BGL = False |
8308 | 8306 |
|
... | ... | |
8460 | 8458 |
""" |
8461 | 8459 |
HPATH = "instance-modify" |
8462 | 8460 |
HTYPE = constants.HTYPE_INSTANCE |
8463 |
_OP_REQP = [("instance_name", _TNonEmptyString)]
|
|
8464 |
_OP_DEFS = [
|
|
8465 |
("nics", _EmptyList), |
|
8466 |
("disks", _EmptyList), |
|
8467 |
("beparams", _EmptyDict), |
|
8468 |
("hvparams", _EmptyDict), |
|
8469 |
("disk_template", None), |
|
8470 |
("remote_node", None), |
|
8471 |
("os_name", None), |
|
8472 |
("force_variant", False), |
|
8473 |
("osparams", None), |
|
8474 |
("force", False),
|
|
8461 |
_OP_PARAMS = [
|
|
8462 |
_PInstanceName,
|
|
8463 |
("nics", _EmptyList, _TList),
|
|
8464 |
("disks", _EmptyList, _TList),
|
|
8465 |
("beparams", _EmptyDict, _TDict),
|
|
8466 |
("hvparams", _EmptyDict, _TDict),
|
|
8467 |
("disk_template", None, _TMaybeString),
|
|
8468 |
("remote_node", None, _TMaybeString),
|
|
8469 |
("os_name", None, _TMaybeString),
|
|
8470 |
("force_variant", False, _TBool),
|
|
8471 |
("osparams", None, _TOr(_TDict, _TNone)),
|
|
8472 |
_PForce,
|
|
8475 | 8473 |
] |
8476 | 8474 |
REQ_BGL = False |
8477 | 8475 |
|
... | ... | |
9122 | 9120 |
"""Query the exports list |
9123 | 9121 |
|
9124 | 9122 |
""" |
9125 |
_OP_REQP = [("nodes", _TListOf(_TNonEmptyString))] |
|
9123 |
_OP_PARAMS = [ |
|
9124 |
("nodes", _EmptyList, _TListOf(_TNonEmptyString)), |
|
9125 |
("use_locking", False, _TBool), |
|
9126 |
] |
|
9126 | 9127 |
REQ_BGL = False |
9127 | 9128 |
|
9128 | 9129 |
def ExpandNames(self): |
... | ... | |
9159 | 9160 |
"""Prepares an instance for an export and returns useful information. |
9160 | 9161 |
|
9161 | 9162 |
""" |
9162 |
_OP_REQP = [
|
|
9163 |
("instance_name", _TNonEmptyString),
|
|
9164 |
("mode", _TElemOf(constants.EXPORT_MODES)), |
|
9163 |
_OP_PARAMS = [
|
|
9164 |
_PInstanceName,
|
|
9165 |
("mode", _NoDefault, _TElemOf(constants.EXPORT_MODES)),
|
|
9165 | 9166 |
] |
9166 | 9167 |
REQ_BGL = False |
9167 | 9168 |
|
... | ... | |
9216 | 9217 |
""" |
9217 | 9218 |
HPATH = "instance-export" |
9218 | 9219 |
HTYPE = constants.HTYPE_INSTANCE |
9219 |
_OP_REQP = [ |
|
9220 |
("instance_name", _TNonEmptyString), |
|
9221 |
("target_node", _TNonEmptyString), |
|
9222 |
("shutdown", _TBool), |
|
9223 |
("mode", _TElemOf(constants.EXPORT_MODES)), |
|
9224 |
] |
|
9225 |
_OP_DEFS = [ |
|
9226 |
("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT), |
|
9227 |
("remove_instance", False), |
|
9228 |
("ignore_remove_failures", False), |
|
9229 |
("mode", constants.EXPORT_MODE_LOCAL), |
|
9230 |
("x509_key_name", None), |
|
9231 |
("destination_x509_ca", None), |
|
9220 |
_OP_PARAMS = [ |
|
9221 |
_PInstanceName, |
|
9222 |
("target_node", _NoDefault, _TOr(_TNonEmptyString, _TList)), |
|
9223 |
("shutdown", True, _TBool), |
|
9224 |
_PShutdownTimeout, |
|
9225 |
("remove_instance", False, _TBool), |
|
9226 |
("ignore_remove_failures", False, _TBool), |
|
9227 |
("mode", constants.EXPORT_MODE_LOCAL, _TElemOf(constants.EXPORT_MODES)), |
|
9228 |
("x509_key_name", None, _TOr(_TList, _TNone)), |
|
9229 |
("destination_x509_ca", None, _TMaybeString), |
|
9232 | 9230 |
] |
9233 | 9231 |
REQ_BGL = False |
9234 | 9232 |
|
... | ... | |
9505 | 9503 |
"""Remove exports related to the named instance. |
9506 | 9504 |
|
9507 | 9505 |
""" |
9508 |
_OP_REQP = [("instance_name", _TNonEmptyString)] |
|
9506 |
_OP_PARAMS = [ |
|
9507 |
_PInstanceName, |
|
9508 |
] |
|
9509 | 9509 |
REQ_BGL = False |
9510 | 9510 |
|
9511 | 9511 |
def ExpandNames(self): |
... | ... | |
9584 | 9584 |
"""Returns the tags of a given object. |
9585 | 9585 |
|
9586 | 9586 |
""" |
9587 |
_OP_REQP = [
|
|
9588 |
("kind", _TElemOf(constants.VALID_TAG_TYPES)), |
|
9589 |
("name", _TNonEmptyString), |
|
9587 |
_OP_PARAMS = [
|
|
9588 |
("kind", _NoDefault, _TElemOf(constants.VALID_TAG_TYPES)),
|
|
9589 |
("name", _NoDefault, _TNonEmptyString),
|
|
9590 | 9590 |
] |
9591 | 9591 |
REQ_BGL = False |
9592 | 9592 |
|
... | ... | |
9601 | 9601 |
"""Searches the tags for a given pattern. |
9602 | 9602 |
|
9603 | 9603 |
""" |
9604 |
_OP_REQP = [("pattern", _TNonEmptyString)] |
|
9604 |
_OP_PARAMS = [ |
|
9605 |
("pattern", _NoDefault, _TNonEmptyString), |
|
9606 |
] |
|
9605 | 9607 |
REQ_BGL = False |
9606 | 9608 |
|
9607 | 9609 |
def ExpandNames(self): |
... | ... | |
9641 | 9643 |
"""Sets a tag on a given object. |
9642 | 9644 |
|
9643 | 9645 |
""" |
9644 |
_OP_REQP = [
|
|
9645 |
("kind", _TElemOf(constants.VALID_TAG_TYPES)), |
|
9646 |
("name", _TNonEmptyString), |
|
9647 |
("tags", _TListOf(objects.TaggableObject.ValidateTag)),
|
|
9646 |
_OP_PARAMS = [
|
|
9647 |
("kind", _NoDefault, _TElemOf(constants.VALID_TAG_TYPES)),
|
|
9648 |
("name", _NoDefault, _TNonEmptyString),
|
|
9649 |
("tags", _NoDefault, _TListOf(_TNonEmptyString)),
|
|
9648 | 9650 |
] |
9649 | 9651 |
REQ_BGL = False |
9650 | 9652 |
|
... | ... | |
9674 | 9676 |
"""Delete a list of tags from a given object. |
9675 | 9677 |
|
9676 | 9678 |
""" |
9677 |
_OP_REQP = [
|
|
9678 |
("kind", _TElemOf(constants.VALID_TAG_TYPES)), |
|
9679 |
("name", _TNonEmptyString), |
|
9680 |
("tags", _TListOf(objects.TaggableObject.ValidateTag)),
|
|
9679 |
_OP_PARAMS = [
|
|
9680 |
("kind", _NoDefault, _TElemOf(constants.VALID_TAG_TYPES)),
|
|
9681 |
("name", _NoDefault, _TNonEmptyString),
|
|
9682 |
("tags", _NoDefault, _TListOf(_TNonEmptyString)),
|
|
9681 | 9683 |
] |
9682 | 9684 |
REQ_BGL = False |
9683 | 9685 |
|
... | ... | |
9715 | 9717 |
time. |
9716 | 9718 |
|
9717 | 9719 |
""" |
9718 |
_OP_REQP = [ |
|
9719 |
("duration", _TFloat), |
|
9720 |
("on_master", _TBool), |
|
9721 |
("on_nodes", _TListOf(_TNonEmptyString)), |
|
9722 |
("repeat", _TPositiveInt) |
|
9723 |
] |
|
9724 |
_OP_DEFS = [ |
|
9725 |
("repeat", 0), |
|
9720 |
_OP_PARAMS = [ |
|
9721 |
("duration", _NoDefault, _TFloat), |
|
9722 |
("on_master", True, _TBool), |
|
9723 |
("on_nodes", _EmptyList, _TListOf(_TNonEmptyString)), |
|
9724 |
("repeat", 0, _TPositiveInt) |
|
9726 | 9725 |
] |
9727 | 9726 |
REQ_BGL = False |
9728 | 9727 |
|
... | ... | |
10097 | 10096 |
This LU runs the allocator tests |
10098 | 10097 |
|
10099 | 10098 |
""" |
10100 |
_OP_REQP = [
|
|
10101 |
("direction", _TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)), |
|
10102 |
("mode", _TElemOf(constants.VALID_IALLOCATOR_MODES)), |
|
10103 |
("name", _TNonEmptyString), |
|
10104 |
("nics", _TOr(_TNone, _TListOf( |
|
10099 |
_OP_PARAMS = [
|
|
10100 |
("direction", _NoDefault, _TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)),
|
|
10101 |
("mode", _NoDefault, _TElemOf(constants.VALID_IALLOCATOR_MODES)),
|
|
10102 |
("name", _NoDefault, _TNonEmptyString),
|
|
10103 |
("nics", _NoDefault, _TOr(_TNone, _TListOf(
|
|
10105 | 10104 |
_TDictOf(_TElemOf(["mac", "ip", "bridge"]), |
10106 | 10105 |
_TOr(_TNone, _TNonEmptyString))))), |
10107 |
("disks", _TOr(_TNone, _TList)), |
|
10108 |
] |
|
10109 |
_OP_DEFS = [ |
|
10110 |
("hypervisor", None), |
|
10111 |
("allocator", None), |
|
10112 |
("nics", None), |
|
10113 |
("disks", None), |
|
10106 |
("disks", _NoDefault, _TOr(_TNone, _TList)), |
|
10107 |
("hypervisor", None, _TMaybeString), |
|
10108 |
("allocator", None, _TMaybeString), |
|
10109 |
("tags", _EmptyList, _TListOf(_TNonEmptyString)), |
|
10110 |
("mem_size", None, _TOr(_TNone, _TPositiveInt)), |
|
10111 |
("vcpus", None, _TOr(_TNone, _TPositiveInt)), |
|
10112 |
("os", None, _TMaybeString), |
|
10113 |
("disk_template", None, _TMaybeString), |
|
10114 |
("evac_nodes", None, _TOr(_TNone, _TListOf(_TNonEmptyString))), |
|
10114 | 10115 |
] |
10115 | 10116 |
|
10116 | 10117 |
def CheckPrereq(self): |
Also available in: Unified diff