From 5525101004593056b3b9006dc1fbdce73c4563e5 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 24 Jun 2008 13:42:29 -0400 Subject: Applying Matt Hicks' patches to enhance the virt modules. --- func/minion/modules/virt.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/func/minion/modules/virt.py b/func/minion/modules/virt.py index 0828484..40ae274 100644 --- a/func/minion/modules/virt.py +++ b/func/minion/modules/virt.py @@ -184,7 +184,25 @@ class Virt(func_module.FuncModule): pass return results - def install(self, server_name, target_name, system=False): + def freemem(self): + self.conn = self.__get_conn() + # Start with the physical memory and subtract + memory = self.conn.nodeinfo()[1] + + # Take 256M off which is reserved for Domain-0 + memory = memory - 256 + + vms = self.conn.find_vm(-1) + for vm in vms: + # Exclude stopped vms and Domain-0 by using + # ids greater than 0 + if vm.ID() > 0: + # This node is active - remove its memory (in bytes) + memory = memory - int(vm.info()[2])/1024 + + return memory + + def install(self, server_name, target_name, system=False, virt_name=None, virt_path=None): """ Install a new virt system by way of a named cobbler profile. @@ -192,6 +210,7 @@ class Virt(func_module.FuncModule): # Example: # install("bootserver.example.org", "fc7webserver", True) + # install("bootserver.example.org", "client.example.org", True, "client-disk0", "HostVolGroup00") conn = self.__get_conn() @@ -204,15 +223,19 @@ class Virt(func_module.FuncModule): if system: target = "system" - # TODO: FUTURE: set --virt-path in cobbler or here koan_args = [ "/usr/bin/koan", "--virt", - "--virt-graphics", # enable VNC "--%s=%s" % (target, target_name), "--server=%s" % server_name ] + if virt_name: + koan_args.append("--virt-name=%s" % virt_name) + + if virt_path: + koan_args.append("--virt-path=%s" % virt_path) + rc = sub_process.call(koan_args,shell=False) if rc == 0: return 0 -- cgit