Changeset 778 for trunk/packages/sipb-xen-base
- Timestamp:
- Jul 29, 2008, 1:35:57 AM (16 years ago)
- Location:
- trunk/packages/sipb-xen-base
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-base/debian/control
r774 r778 3 3 Priority: extra 4 4 Maintainer: SIPB Xen Project <sipb-xen@mit.edu> 5 Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 4.1.0) , python-json (>= 3.4-2), python-yaml (>= 3.05-1andersk1)5 Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 4.1.0) 6 6 Standards-Version: 3.7.2 7 7 8 8 Package: sipb-xen-base 9 9 Architecture: all 10 Depends: ${misc:Depends}, 10 Depends: ${misc:Depends}, python-json (>= 3.4-2), python-yaml (>= 3.05) 11 11 Description: Base configuration required for all SIPB xen servers 12 12 This package includes apt configuration, .k5login and other files that -
trunk/packages/sipb-xen-base/files/usr/sbin/invirt-getconf
r771 r778 2 2 3 3 """ 4 invirt-getconf [-f FILE] KEY prints the configuration the option named KEY from 5 the invirt configuration file FILE. Keys are dot-separated paths into the YAML 4 invirt-getconf loads an invirt configuration file (either the original YAML 5 source or the faster-to-load JSON cache) and prints the configuration option 6 with the given name (key). Keys are dot-separated paths into the YAML 6 7 configuration tree. List indexes (0-based) are also treated as path 7 8 components. 8 9 9 10 (Due to this path language, certain restrictions are placed on the keys used in 10 the YAML configuration , e.g.they cannot contain dots.)11 the YAML configuration; e.g., they cannot contain dots.) 11 12 12 13 Examples: … … 58 59 '%s: index %s out of range' % (progress, component)) 59 60 print conf 60 except (invirt_exception, OSError), ex:61 except invirt_exception, ex: 61 62 print >> stderr, ex 62 63 return 1 -
trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/config.py
r771 r778 1 1 import json, yaml 2 from invirt.common import * 2 3 from os import error, makedirs 3 4 from os.path import dirname, getmtime … … 8 9 try: default_loader = yaml.CSafeLoader 9 10 except: default_loader = yaml.SafeLoader 10 11 def wrap(rsrc, func):12 "Utility to that emulates with Python 2.5's `with closing(rsrc)`."13 try: return func(rsrc)14 finally: rsrc.close()15 11 16 12 def load(src_path = default_src_path, … … 31 27 else: do_refresh = src_mtime > cache_mtime 32 28 29 if not do_refresh: 30 # try reading from the cache first 31 try: cfg = wrap(file(cache_path), lambda f: json.read(f.read())) 32 except: do_refresh = True 33 33 34 if do_refresh: 34 35 # reload the source and regenerate the cache 35 36 cfg = wrap(file(src_path), lambda f: yaml.load(f, default_loader)) 36 wrap(file(cache_path, 'w'), lambda f: f.write(json.write(cfg))) 37 else: 38 cfg = wrap(file(cache_path), lambda f: json.read(f.read())) 37 try: wrap(file(cache_path, 'w'), lambda f: f.write(json.write(cfg))) 38 except: pass # silent failure 39 39 return cfg 40 40 41 dicts = load() 42 structs = dicts2struct(dicts) 43 41 44 # vim:et:sw=4:ts=4
Note: See TracChangeset
for help on using the changeset viewer.