Changeset 816
- Timestamp:
- Aug 2, 2008, 8:28:18 PM (16 years ago)
- Location:
- trunk/packages
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-base/files/usr/sbin/invirt-getconf
r802 r816 17 17 """ 18 18 19 from invirt.config import load19 from invirt.config import default_src_path, default_cache_path, load 20 20 from sys import argv, exit, stderr, stdout 21 21 from optparse import OptionParser … … 28 28 description = __doc__.strip().split('\n\n')[0]) 29 29 parser.add_option('-s', '--src', 30 default = '/etc/invirt/master.yaml',30 default = default_src_path, 31 31 help = 'the source YAML configuration file to read from') 32 32 parser.add_option('-c', '--cache', 33 default = '/var/lib/invirt/invirt.json',33 default = default_cache_path, 34 34 help = 'path to the JSON cache') 35 35 parser.add_option('-r', '--refresh', … … 81 81 else: 82 82 import yaml 83 try: dumper = yaml.CSafeDumper 84 except: dumper = yaml.SafeDumper 83 85 yaml.dump(conf, stdout, 84 Dumper =yaml.CSafeDumper, default_flow_style=False)86 Dumper = dumper, default_flow_style = False) 85 87 except invirt_exception, ex: 86 88 print >> stderr, ex -
trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/config.py
r807 r816 1 1 import json 2 2 from invirt.common import * 3 from os import rename 3 4 from os.path import getmtime 4 5 … … 75 76 lambda f: f.write(json.write(ns.cfg))) 76 77 except: pass # silent failure 77 else: os.rename(cache_path + '.tmp', cache_path)78 else: rename(cache_path + '.tmp', cache_path) 78 79 except IOError: 79 80 ns.cfg = with_closing(file(src_path)) ( -
trunk/packages/sipb-xen-remote-server/config.todo
r810 r816 2 2 files/usr/sbin/sipb-xen-remconffs: db uri 3 3 files/usr/sbin/sipb-xen-remote-proxy: any one host name 4 files/usr/sbin/sipb-xen-remote-create: host hostnames5 files/usr/sbin/sipb-xen-remote-listvms: host hostnames6 4 files/usr/sbin/sipb-xen-remctl-help: remote-proxy hostname -
trunk/packages/sipb-xen-remote-server/files/usr/sbin/sipb-xen-remote-create
r665 r816 1 1 #!/usr/bin/python 2 2 3 """ 3 4 Picks a host to "create" (boot) a VM on, and does so. … … 8 9 """ 9 10 10 11 from invirt.remote import bcast 11 12 from subprocess import PIPE, Popen, call 12 13 import sys 13 14 import yaml 14 15 15 16 16 def choose_host(): 17 17 # Query each of the hosts. 18 # TODO get `servers` from a real list of all the VM hosts (instead of19 # hardcoding the list here)20 servers = ['black-mesa.mit.edu', 'sx-blade-2.mit.edu']21 pipes = [(server,22 Popen(['remctl', server, 'remote', 'web', 'info'], stdout=PIPE))23 for server in servers]24 outputs = [(s, p.communicate()[0]) for (s, p) in pipes]25 for (s, p) in pipes:26 if p.returncode != 0:27 raise RuntimeError("remctl to host %s returned non-zero exit status %d"28 % (s, p.returncode))29 results = [(s, yaml.load(o, yaml.CSafeLoader)) for (s, o) in outputs]30 18 # XXX will the output of 'xm info' always be parseable YAML? 31 32 return max( (int(o['free_memory']), s) for (s, o) in results )[1] 33 19 results = bcast('info') 20 return max((int(o['free_memory']), s) for (s, o) in results)[1] 34 21 35 22 def main(argv): 36 23 if len(argv) < 2: 37 print >> sys.stderr, "usage: sipb-xen-remote-create <machine> [<other args...>]"24 print >> sys.stderr, "usage: sipb-xen-remote-create <machine> [<other args...>]" 38 25 return 2 39 26 machine_name = argv[1] 40 27 args = argv[2:] 41 42 28 43 29 p = Popen(['/usr/sbin/sipb-xen-remote-proxy-web', 'listvms'], stdout=PIPE) … … 50 36 if machine_name in vms: 51 37 host = vms[machine_name]['host'] 52 print >> sys.stderr, ("machine '%s' is already running on host %s"53 % (machine_name, host))38 print >> sys.stderr, ("machine '%s' is already running on host %s" 39 % (machine_name, host)) 54 40 return 1 55 56 41 57 42 host = choose_host() -
trunk/packages/sipb-xen-remote-server/files/usr/sbin/sipb-xen-remote-listvms
r623 r816 6 6 """ 7 7 8 from subprocess import PIPE, Popen8 from invirt.remote import bcast 9 9 import sys 10 10 import yaml 11 11 12 12 def main(argv): 13 # Query each of the server for their VMs. 14 # TODO get `servers` from a real list of all the VM hosts (instead of 15 # hardcoding the list here) 16 servers = ['black-mesa.mit.edu', 'sx-blade-2.mit.edu'] 17 # XXX 18 pipes = [(server, 19 Popen(['remctl', server, 'remote', 'web', 'listvms'], stdout=PIPE)) 20 for server in servers] 21 outputs = [(s, p.communicate()[0]) for (s, p) in pipes] 22 for (s, p) in pipes: 23 if p.returncode != 0: 24 raise RuntimeError("remctl to host %s returned non-zero exit status %d" 25 % (s, p.returncode)) 26 results = [(s, yaml.load(o, yaml.CSafeLoader)) for (s, o) in outputs] 27 results = filter(lambda (_, x): x is not None, results) 13 # Query each of the hosts. 14 results = filter(lambda (_, x): x is not None, bcast('listvms')) 28 15 29 16 # Merge the results and print. … … 37 24 38 25 if __name__ == '__main__': 39 main(sys.argv)26 sys.exit(main(sys.argv)) 40 27 41 28 # vim:et:sw=4:ts=4
Note: See TracChangeset
for help on using the changeset viewer.