Revision 1f350e0f lib/backend.py
b/lib/backend.py | ||
---|---|---|
1355 | 1355 |
_Fail("Hypervisor error: %s", err, exc=True) |
1356 | 1356 |
|
1357 | 1357 |
|
1358 |
def InstanceShutdown(instance, timeout): |
|
1358 |
def InstanceShutdown(instance, timeout, reason, store_reason=True):
|
|
1359 | 1359 |
"""Shut an instance down. |
1360 | 1360 |
|
1361 | 1361 |
@note: this functions uses polling with a hardcoded timeout. |
... | ... | |
1364 | 1364 |
@param instance: the instance object |
1365 | 1365 |
@type timeout: integer |
1366 | 1366 |
@param timeout: maximum timeout for soft shutdown |
1367 |
@type reason: list of reasons |
|
1368 |
@param reason: the reason trail for this shutdown |
|
1369 |
@type store_reason: boolean |
|
1370 |
@param store_reason: whether to store the shutdown reason trail on file |
|
1367 | 1371 |
@rtype: None |
1368 | 1372 |
|
1369 | 1373 |
""" |
... | ... | |
1385 | 1389 |
|
1386 | 1390 |
try: |
1387 | 1391 |
hyper.StopInstance(instance, retry=self.tried_once) |
1392 |
if store_reason: |
|
1393 |
_StoreInstReasonTrail(instance.name, reason) |
|
1388 | 1394 |
except errors.HypervisorError, err: |
1389 | 1395 |
if iname not in hyper.ListInstances(): |
1390 | 1396 |
# if the instance is no longer existing, consider this a |
... | ... | |
1460 | 1466 |
_Fail("Failed to soft reboot instance %s: %s", instance.name, err) |
1461 | 1467 |
elif reboot_type == constants.INSTANCE_REBOOT_HARD: |
1462 | 1468 |
try: |
1463 |
InstanceShutdown(instance, shutdown_timeout) |
|
1469 |
InstanceShutdown(instance, shutdown_timeout, reason, store_reason=False)
|
|
1464 | 1470 |
result = StartInstance(instance, False) |
1465 | 1471 |
_StoreInstReasonTrail(instance.name, reason) |
1466 | 1472 |
return result |
Also available in: Unified diff