#
#
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
_IES_CA_FILE = "ca"
#: Valid LVS output line regex
-_LVSLINE_REGEX = re.compile("^ *([^|]+)\|([^|]+)\|([0-9.]+)\|([^|]{6})\|?$")
+_LVSLINE_REGEX = re.compile("^ *([^|]+)\|([^|]+)\|([0-9.]+)\|([^|]{6,})\|?$")
# Actions for the master setup script
_MASTER_START = "start"
_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.
for pname, pvalue in os_params.items():
result["OSP_%s" % pname.upper()] = pvalue
+ # Set a default path otherwise programs called by OS scripts (or
+ # even hooks called from OS scripts) might break, and we don't want
+ # to have each script require setting a PATH variable
+ result["PATH"] = constants.HOOKS_PATH
+
return result