- Timestamp:
- Feb 12, 2009, 11:26:48 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-remote/host/usr/sbin/invirt-availability
r2104 r2107 14 14 15 15 def main(argv): 16 """ 17 Calculate the amount of memory available for new VMs 18 The numbers returned by xm info and xm info -c are in MB 19 The numbers in /proc/xen/balloon have nice units 20 All math is done in kilobytes for consistency 21 Output is in MB 22 """ 16 23 p = Popen(['/usr/sbin/xm', 'info'], stdout=PIPE) 17 24 output = p.communicate()[0] 18 25 if p.returncode != 0: 19 26 raise RuntimeError("Command '%s' returned non-zero exit status %d" 20 % (' invirt-availability', p.returncode))27 % ('/usr/sbin/xm info', p.returncode)) 21 28 xminfo = yaml.load(output, yaml.CSafeLoader) 22 29 23 # In kilobytes24 30 free_memory = int(xminfo['free_memory']) * 1024 25 31 26 f = open('/proc/xen/balloon', 'r') 27 ballooninfo = yaml.load(f.read()) 28 f.close() 32 ballooninfo = yaml.load(open('/proc/xen/balloon', 'r').read()) 29 33 currentallocation = parseUnits(ballooninfo['Current allocation']) 30 34 minimumtarget = parseUnits(ballooninfo['Minimum target']) … … 34 38 if p.returncode != 0: 35 39 raise RuntimeError("Command '%s' returned non-zero exit status %d" 36 % (' invirt-availability', p.returncode))40 % ('/usr/sbin/xm info -c', p.returncode)) 37 41 xminfoc = yaml.load(output, yaml.CSafeLoader) 38 42
Note: See TracChangeset
for help on using the changeset viewer.