[PATCH] Adding freemem functionality - Calculates the amount of memory available to virtual machines assuming Domain-0 can be reduced to 256M

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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


--------------050105050603070203070104
Content-Type: text/plain;
 name="0003-Adding-a-find_resources-script-to-look-across-minion.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename*0="0003-Adding-a-find_resources-script-to-look-across-minion.pa";
 filename*1="tch"

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux