ia64/xen-unstable

changeset 1843:1908bce36fa8

bitkeeper revision 1.1108.1.2 (40fd3202hesHtZpdMd1v994DiPkgZw)

Make xend check its prerequisites more carefully.
Add python logging package (standard from python 2.3).
author mjw@wray-m-3.hpl.hp.com
date Tue Jul 20 14:53:54 2004 +0000 (2004-07-20)
parents cf5056d3e5e8
children f26582ec895e
files Makefile tools/misc/xend
line diff
     1.1 --- a/Makefile	Mon Jul 19 11:49:45 2004 +0000
     1.2 +++ b/Makefile	Tue Jul 20 14:53:54 2004 +0000
     1.3 @@ -135,6 +135,12 @@ install-twisted:
     1.4  	tar -zxf Twisted-*.tar.gz
     1.5  	( cd Twisted-* ; python setup.py install )
     1.6  
     1.7 +install-logging: LOGGING=logging-0.4.9.2
     1.8 +install-logging:
     1.9 +	[ -f $(LOGGING).tar.gz ] || wget http://www.red-dove.com/$(LOGGING).tar.gz
    1.10 +	tar -xfz $(LOGGING).tar.gz
    1.11 +	( cd $(LOGGING) && python setup.py install )
    1.12 +
    1.13  # handy target to upgrade iptables (use rpm or apt-get in preference)
    1.14  install-iptables:
    1.15  	wget http://www.netfilter.org/files/iptables-1.2.11.tar.bz2
     2.1 --- a/tools/misc/xend	Mon Jul 19 11:49:45 2004 +0000
     2.2 +++ b/tools/misc/xend	Tue Jul 20 14:53:54 2004 +0000
     2.3 @@ -20,27 +20,79 @@
     2.4  """
     2.5  import os
     2.6  import sys
     2.7 -from xen.xend.server import SrvDaemon
     2.8 +
     2.9 +class CheckError(ValueError):
    2.10 +    pass
    2.11 +
    2.12 +def hline():
    2.13 +    print >>sys.stderr, "*" * 70
    2.14 +
    2.15 +def msg(message):
    2.16 +    print >>sys.stderr, "*" * 3, message
    2.17 +
    2.18 +def check_logging():
    2.19 +    """Check python logging is installed and raise an error if not.
    2.20 +    Logging is standard from Python 2.3 on.
    2.21 +    """
    2.22 +    try:
    2.23 +        import logging
    2.24 +    except ImportError:
    2.25 +        hline()
    2.26 +        msg("Python logging is not installed.")
    2.27 +        msg("Use 'make install-logging' at the xen root to install.")
    2.28 +        msg("")
    2.29 +        msg("Alternatively download and install from")
    2.30 +        msg("http://www.red-dove.com/python_logging.html")
    2.31 +        hline()
    2.32 +        raise CheckError("logging is not installed")
    2.33  
    2.34  def check_twisted_version():
    2.35 -    """Check twisted version and print a warning if not high enough.
    2.36 +    """Check twisted is installed with a supported version and print a warning if not.
    2.37 +    Raises an error if twisted is not installed.
    2.38      """
    2.39 -    from twisted.copyright import version
    2.40      # Supported twisted release and major version.
    2.41      RELEASE = 1
    2.42      MAJOR   = 3
    2.43 +    try:
    2.44 +        from twisted.copyright import version
    2.45 +    except ImportError:
    2.46 +        hline()
    2.47 +        msg("The Twisted framework is not installed.")
    2.48 +        msg("Use 'make install-twisted' at the xen root to install.")
    2.49 +        msg("")
    2.50 +        msg("Alternatively download and install version %d.%d or higher" % (RELEASE, MAJOR))
    2.51 +        msg("from http://www.twistedmatrix.com/products")
    2.52 +        hline()
    2.53 +        raise CheckError("twisted is not installed")
    2.54 +        
    2.55 +    
    2.56      (release, major, minor) = version.split('.')
    2.57      release = int(release)
    2.58      major = int(major)
    2.59      if release > RELEASE: return
    2.60      if release == RELEASE and major >= MAJOR: return
    2.61 -    print >>sys.stderr, "*" * 60
    2.62 -    print >>sys.stderr, "*" * 3, "Warning: Twisted version not supported: %s" % version
    2.63 -    print >>sys.stderr, "*" * 3, "Use Twisted version %d.%d.0 or higher" % (RELEASE, MAJOR)
    2.64 -    print >>sys.stderr, "*" * 60
    2.65 +    hline()
    2.66 +    msg("Warning: Twisted version not supported: %s" % version)
    2.67 +    msg("Use Twisted version %d.%d.0 or higher" % (RELEASE, MAJOR))
    2.68 +    hline()
    2.69  
    2.70 +def check_user():
    2.71 +    """Check that the effective user id is 0 (root).
    2.72 +    """
    2.73 +    if os.geteuid() != 0:
    2.74 +        hline()
    2.75 +        msg("Xend must be run as root.")
    2.76 +        hline()
    2.77 +        raise CheckError("invalid user")
    2.78 +    
    2.79  def main():
    2.80 -    check_twisted_version()
    2.81 +    try:
    2.82 +        check_logging()
    2.83 +        check_twisted_version()
    2.84 +        check_user()
    2.85 +    except CheckError:
    2.86 +        sys.exit(1)
    2.87 +    from xen.xend.server import SrvDaemon
    2.88      daemon = SrvDaemon.instance()
    2.89      if not sys.argv[1:]:
    2.90          print 'usage: %s {start|stop|restart}' % sys.argv[0]