Ignore:
Timestamp:
Feb 12, 2009, 11:26:48 PM (16 years ago)
Author:
iannucci
Message:

Clean-up suggestions from price. Whitespace fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-remote/host/usr/sbin/invirt-availability

    r2104 r2107  
    1414
    1515def 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    """
    1623    p = Popen(['/usr/sbin/xm', 'info'], stdout=PIPE)
    1724    output = p.communicate()[0]
    1825    if p.returncode != 0:
    1926        raise RuntimeError("Command '%s' returned non-zero exit status %d"
    20                            % ('invirt-availability', p.returncode))
     27                           % ('/usr/sbin/xm info', p.returncode))
    2128    xminfo = yaml.load(output, yaml.CSafeLoader)
    2229
    23     # In kilobytes
    2430    free_memory = int(xminfo['free_memory']) * 1024
    2531
    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())
    2933    currentallocation = parseUnits(ballooninfo['Current allocation'])
    3034    minimumtarget = parseUnits(ballooninfo['Minimum target'])
     
    3438    if p.returncode != 0:
    3539        raise RuntimeError("Command '%s' returned non-zero exit status %d"
    36                            % ('invirt-availability', p.returncode))
     40                           % ('/usr/sbin/xm info -c', p.returncode))
    3741    xminfoc = yaml.load(output, yaml.CSafeLoader)
    3842
Note: See TracChangeset for help on using the changeset viewer.