Commit ebe466d8 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add instance_balloon_memory rpc


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 2e2fb795
......@@ -1376,6 +1376,27 @@ def InstanceReboot(instance, reboot_type, shutdown_timeout):
_Fail("Invalid reboot_type received: %s", reboot_type)
def InstanceBalloonMemory(instance, memory):
"""Resize an instance's memory.
@type instance: L{objects.Instance}
@param instance: the instance object
@type memory: int
@param memory: new memory amount in MB
@rtype: None
"""
hyper = hypervisor.GetHypervisor(instance.hypervisor)
running = hyper.ListInstances()
if instance.name not in running:
logging.info("Instance %s is not running, cannot balloon", instance.name)
return
try:
hyper.BalloonInstanceMemory(instance, memory)
except errors.HypervisorError, err:
_Fail("Failed to balloon instance memory: %s", err, exc=True)
def MigrationInfo(instance):
"""Gather information about an instance to be migrated.
......
......@@ -224,6 +224,10 @@ _INSTANCE_CALLS = [
("instance", ED_INST_DICT, "Instance object"),
("timeout", None, None),
], None, None, "Stops an instance"),
("instance_balloon_memory", SINGLE, None, TMO_NORMAL, [
("instance", ED_INST_DICT, "Instance object"),
("memory", None, None),
], None, None, "Modify the amount of an instance's runtime memory"),
("instance_run_rename", SINGLE, None, TMO_SLOW, [
("instance", ED_INST_DICT, "Instance object"),
("old_name", None, None),
......
......@@ -621,6 +621,15 @@ class NodeHttpServer(http.server.HttpServer):
shutdown_timeout = params[2]
return backend.InstanceReboot(instance, reboot_type, shutdown_timeout)
@staticmethod
def perspective_instance_balloon_memory(params):
"""Modify instance runtime memory.
"""
instance_dict, memory = params
instance = objects.Instance.FromDict(instance_dict)
return backend.InstanceBalloonMemory(instance, memory)
@staticmethod
def perspective_instance_info(params):
"""Query instance information.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment