Revision a82d9394
b/lib/opcodes.py | ||
---|---|---|
1452 | 1452 |
("reboot_type", ht.NoDefault, ht.TElemOf(constants.REBOOT_TYPES), |
1453 | 1453 |
"How to reboot instance"), |
1454 | 1454 |
("reason", (constants.INSTANCE_REASON_SOURCE_UNKNOWN, None), |
1455 |
ht.TAnd(ht.TOr(ht.TList, ht.TTuple), |
|
1456 |
ht.TIsLength(2), |
|
1455 |
ht.TAnd(ht.TIsLength(2), |
|
1457 | 1456 |
ht.TItems([ |
1458 |
ht.TElemOf(constants.INSTANCE_REASON_SOURCES), |
|
1459 |
ht.TMaybeString, |
|
1460 |
]) |
|
1461 |
), |
|
1457 |
ht.TElemOf(constants.INSTANCE_REASON_SOURCES), |
|
1458 |
ht.TMaybeString, |
|
1459 |
])), |
|
1462 | 1460 |
"The reason why the reboot is happening"), |
1463 | 1461 |
] |
1464 | 1462 |
OP_RESULT = ht.TNone |
b/lib/rapi/rlib2.py | ||
---|---|---|
1040 | 1040 |
self.queryargs.get("type", [constants.INSTANCE_REBOOT_HARD])[0], |
1041 | 1041 |
"ignore_secondaries": bool(self._checkIntVariable("ignore_secondaries")), |
1042 | 1042 |
"dry_run": self.dryRun(), |
1043 |
"reason": ( |
|
1044 |
constants.INSTANCE_REASON_SOURCE_RAPI, |
|
1045 |
self._checkStringVariable("reason_text", |
|
1046 |
default=constants.INSTANCE_REASON_REBOOT), |
|
1047 |
) |
|
1043 |
"reason": |
|
1044 |
(constants.INSTANCE_REASON_SOURCE_RAPI, |
|
1045 |
self._checkStringVariable("reason_text", |
|
1046 |
default=constants.INSTANCE_REASON_REBOOT)), |
|
1048 | 1047 |
}) |
1049 | 1048 |
|
1050 | 1049 |
|
b/lib/server/noded.py | ||
---|---|---|
113 | 113 |
|
114 | 114 |
|
115 | 115 |
def _DefaultAlternative(value, default): |
116 |
"""Returns the given value, unless it is None. In that case, returns a |
|
117 |
default alternative. |
|
116 |
"""Returns value or, if evaluating to False, a default value. |
|
118 | 117 |
|
119 |
@param value: The value to return if it is not None. |
|
120 |
@param default: The value to return as a default alternative. |
|
121 |
@return: The given value or the default alternative.\ |
|
118 |
Returns the given value, unless it evaluates to False. In the latter case the |
|
119 |
default value is returned. |
|
120 |
|
|
121 |
@param value: Value to return if it doesn't evaluate to False |
|
122 |
@param default: Default value |
|
123 |
@return: Given value or the default |
|
122 | 124 |
|
123 | 125 |
""" |
124 | 126 |
if value: |
b/test/py/ganeti.rapi.rlib2_unittest.py | ||
---|---|---|
370 | 370 |
handler = _CreateHandler(rlib2.R_2_instances_name_reboot, ["inst847"], { |
371 | 371 |
"dry-run": ["1"], |
372 | 372 |
"ignore_secondaries": ["1"], |
373 |
"reason_text": ["System update"] |
|
373 |
"reason_text": ["System update"],
|
|
374 | 374 |
}, {}, clfactory) |
375 | 375 |
job_id = handler.POST() |
376 | 376 |
|
... | ... | |
385 | 385 |
self.assertTrue(op.ignore_secondaries) |
386 | 386 |
self.assertTrue(op.dry_run) |
387 | 387 |
self.assertEqual(op.reason, |
388 |
(constants.INSTANCE_REASON_SOURCE_RAPI, |
|
389 |
"System update", |
|
390 |
)) |
|
388 |
(constants.INSTANCE_REASON_SOURCE_RAPI, "System update")) |
|
391 | 389 |
|
392 | 390 |
self.assertRaises(IndexError, cl.GetNextSubmittedJob) |
393 | 391 |
|
Also available in: Unified diff