xen-drbd
diff xen-drbd.py @ 38:30671fe7fd79
Now you can use 'domain' variable inside netowrk topology file
author | igor@manas.xt.vpn |
---|---|
date | Thu Sep 18 11:42:52 2008 +0300 (2008-09-18) |
parents | e80bdf496aa2 |
children | 263d00b75422 |
line diff
1.1 --- a/xen-drbd.py Mon Sep 15 10:03:24 2008 +0300 1.2 +++ b/xen-drbd.py Thu Sep 18 11:42:52 2008 +0300 1.3 @@ -173,6 +173,8 @@ 1.4 xen_domain="domain=\"%s\"\n" % (domain) + xen_domain 1.5 xen_domain="network=\"%s\"\n" % (network) + xen_domain 1.6 do_import('xen_domain_module',xen_domain) 1.7 + #print "domain=\"%s\"\n" % (domain) 1.8 + #print "network=\"%s\"\n" % (network) 1.9 import xen_domain_module 1.10 xen_domain_module.print_config() 1.11 1.12 @@ -230,8 +232,7 @@ 1.13 try: 1.14 opts, args = getopt.getopt(sys.argv[1:], "hn:", ["help", "network="]) 1.15 except getopt.GetoptError, err: 1.16 - # print help information and exit: 1.17 - print str(err) # will print something like "option -a not recognized" 1.18 + print str(err) 1.19 usage() 1.20 sys.exit(2) 1.21 1.22 @@ -247,14 +248,20 @@ 1.23 1.24 debug=2 1.25 1.26 - 1.27 +if len(args) == 2: 1.28 + domain=args[1] 1.29 1.30 sys.path.append('/etc/xen') 1.31 try: 1.32 - exec 'from %s import *' % (network) 1.33 -except ImportError: 1.34 - print "Can't find or interpret module <%s> with topology description" %(network) 1.35 - sys.exit(1) 1.36 + execfile(network) 1.37 +except IOError: 1.38 + print "Network configuration file <%s> not found " % network 1.39 + if network == 'network': 1.40 + print "You can use -n option to specify network filename" 1.41 + sys.exit(2) 1.42 +except NameError: 1.43 + domain=domains[0] 1.44 + execfile(network) 1.45 1.46 xen_drbd_start="/etc/xen/xen-drbd-start" 1.47 domain_create_line="xm create "+xen_drbd_start+" network="+network+" domain=%s"