summaryrefslogtreecommitdiffstats
path: root/func/patches/0002-Adding-freemem-functionality.patch
diff options
context:
space:
mode:
Diffstat (limited to 'func/patches/0002-Adding-freemem-functionality.patch')
-rw-r--r--func/patches/0002-Adding-freemem-functionality.patch43
1 files changed, 43 insertions, 0 deletions
diff --git a/func/patches/0002-Adding-freemem-functionality.patch b/func/patches/0002-Adding-freemem-functionality.patch
new file mode 100644
index 0000000..15938d2
--- /dev/null
+++ b/func/patches/0002-Adding-freemem-functionality.patch
@@ -0,0 +1,43 @@
+From 4cec34948da30acfb6d0724019f12db596807ce2 Mon Sep 17 00:00:00 2001
+From: Matthew Hicks <mhicks@mhicks-host.usersys.redhat.com>
+Date: Tue, 17 Jun 2008 19:56:18 -0400
+Subject: [PATCH] Adding freemem functionality
+ - Calculates the amount of memory available to virtual
+ machines assuming Domain-0 can be reduced to 256M
+
+---
+ func/minion/modules/virt.py | 18 ++++++++++++++++++
+ 1 files changed, 18 insertions(+), 0 deletions(-)
+
+diff --git a/func/minion/modules/virt.py b/func/minion/modules/virt.py
+index 92107fe..40ae274 100644
+--- a/func/minion/modules/virt.py
++++ b/func/minion/modules/virt.py
+@@ -184,6 +184,24 @@ class Virt(func_module.FuncModule):
+ pass
+ return results
+
++ 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):
+
+ """
+--
+1.5.3.6
+