import yaml
import os
-# return the amount of memory in kibibytes represented by s
-def parseUnits(s):
- num, unit = s.split(' ')
- assert unit == 'kB', "unexpected unit"
- return int(num)
-
def main(argv):
"""
Calculate the amount of memory available for new VMs
free_memory = int(xminfo['free_memory']) * 1024
- ballooninfo = yaml.load(open('/proc/xen/balloon', 'r').read())
- currentallocation = parseUnits(ballooninfo['Current allocation'])
- minimumtarget = parseUnits(ballooninfo['Minimum target'])
-
+ currentallocation = open('/sys/devices/system/xen_memory/xen_memory0/info/current_kb', 'r').read()
+ minimumtarget = open('/sys/devices/system/xen_memory/xen_memory0/target_kb', 'r').read()
p = Popen(['/usr/sbin/xm', 'info', '-c'], stdout=PIPE)
output = p.communicate()[0]
if p.returncode != 0: