Revision ebe466d8
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 |
|
b/lib/rpc_defs.py | ||
---|---|---|
224 | 224 |
("instance", ED_INST_DICT, "Instance object"), |
225 | 225 |
("timeout", None, None), |
226 | 226 |
], None, None, "Stops an instance"), |
227 |
("instance_balloon_memory", SINGLE, None, TMO_NORMAL, [ |
|
228 |
("instance", ED_INST_DICT, "Instance object"), |
|
229 |
("memory", None, None), |
|
230 |
], None, None, "Modify the amount of an instance's runtime memory"), |
|
227 | 231 |
("instance_run_rename", SINGLE, None, TMO_SLOW, [ |
228 | 232 |
("instance", ED_INST_DICT, "Instance object"), |
229 | 233 |
("old_name", None, None), |
b/lib/server/noded.py | ||
---|---|---|
622 | 622 |
return backend.InstanceReboot(instance, reboot_type, shutdown_timeout) |
623 | 623 |
|
624 | 624 |
@staticmethod |
625 |
def perspective_instance_balloon_memory(params): |
|
626 |
"""Modify instance runtime memory. |
|
627 |
|
|
628 |
""" |
|
629 |
instance_dict, memory = params |
|
630 |
instance = objects.Instance.FromDict(instance_dict) |
|
631 |
return backend.InstanceBalloonMemory(instance, memory) |
|
632 |
|
|
633 |
@staticmethod |
|
625 | 634 |
def perspective_instance_info(params): |
626 | 635 |
"""Query instance information. |
627 | 636 |
|
Also available in: Unified diff