projects
/
invirt/packages/invirt-remote.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stupid thinko
[invirt/packages/invirt-remote.git]
/
host
/
usr
/
sbin
/
invirt-availability
diff --git
a/host/usr/sbin/invirt-availability
b/host/usr/sbin/invirt-availability
index
0122a8d
..
729c229
100644
(file)
--- a/
host/usr/sbin/invirt-availability
+++ b/
host/usr/sbin/invirt-availability
@@
-6,19
+6,15
@@
Gathers availability data for the VM host it's running on.
from subprocess import PIPE, Popen, call
import sys
import yaml
from subprocess import PIPE, Popen, call
import sys
import yaml
-
-# return the amount of memory in kilobytes represented by s
-def parseUnits(s):
- num, unit = s.split(' ')
- return int(num) * {'kb':1, 'mb':1024}[unit.lower()]
+import os
def main(argv):
"""
Calculate the amount of memory available for new VMs
def main(argv):
"""
Calculate the amount of memory available for new VMs
- The numbers returned by xm info and xm info -c are in MB
- The numbers in /proc/xen/balloon have nice units
- All math is done in kilobytes for consistency
- Output is in MB
+ The numbers returned by xm info and xm info -c are in MiB
+ The numbers in /proc/xen/balloon are in KiB
+ All math is done in kibibytes for consistency
+ Output is in MiB
Bail if /etc/invirt/nocreate exists
"""
Bail if /etc/invirt/nocreate exists
"""
@@
-38,10
+34,8
@@
def main(argv):
free_memory = int(xminfo['free_memory']) * 1024
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 = int(open('/sys/devices/system/xen_memory/xen_memory0/info/current_kb', 'r').read())
+ minimumtarget = int(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:
p = Popen(['/usr/sbin/xm', 'info', '-c'], stdout=PIPE)
output = p.communicate()[0]
if p.returncode != 0:
@@
-49,7
+43,7
@@
def main(argv):
% ('/usr/sbin/xm info -c', p.returncode))
xminfoc = yaml.load(output, yaml.CSafeLoader)
% ('/usr/sbin/xm info -c', p.returncode))
xminfoc = yaml.load(output, yaml.CSafeLoader)
- # In kilobytes
+ # In kibibytes
dom0minmem = int(xminfoc['dom0-min-mem']) * 1024
dom0_spare_memory = currentallocation - max(minimumtarget, dom0minmem)
dom0minmem = int(xminfoc['dom0-min-mem']) * 1024
dom0_spare_memory = currentallocation - max(minimumtarget, dom0minmem)