Revision ebe466d8 lib/backend.py
b/lib/backend.py | ||
---|---|---|
1376 | 1376 |
_Fail("Invalid reboot_type received: %s", reboot_type) |
1377 | 1377 |
|
1378 | 1378 |
|
1379 |
def InstanceBalloonMemory(instance, memory): |
|
1380 |
"""Resize an instance's memory. |
|
1381 |
|
|
1382 |
@type instance: L{objects.Instance} |
|
1383 |
@param instance: the instance object |
|
1384 |
@type memory: int |
|
1385 |
@param memory: new memory amount in MB |
|
1386 |
@rtype: None |
|
1387 |
|
|
1388 |
""" |
|
1389 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1390 |
running = hyper.ListInstances() |
|
1391 |
if instance.name not in running: |
|
1392 |
logging.info("Instance %s is not running, cannot balloon", instance.name) |
|
1393 |
return |
|
1394 |
try: |
|
1395 |
hyper.BalloonInstanceMemory(instance, memory) |
|
1396 |
except errors.HypervisorError, err: |
|
1397 |
_Fail("Failed to balloon instance memory: %s", err, exc=True) |
|
1398 |
|
|
1399 |
|
|
1379 | 1400 |
def MigrationInfo(instance): |
1380 | 1401 |
"""Gather information about an instance to be migrated. |
1381 | 1402 |
|
Also available in: Unified diff