xen-drbd

changeset 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
files xen-drbd-install.py xen-drbd-start.py xen-drbd.py
line diff
     1.1 --- a/xen-drbd-install.py	Mon Sep 15 10:03:24 2008 +0300
     1.2 +++ b/xen-drbd-install.py	Thu Sep 18 11:42:52 2008 +0300
     1.3 @@ -28,8 +28,7 @@
     1.4  try:
     1.5      opts, args = getopt.getopt(sys.argv[1:], "hn:", ["help", "network="])
     1.6  except getopt.GetoptError, err:
     1.7 -    # print help information and exit:
     1.8 -    print str(err) # will print something like "option -a not recognized"
     1.9 +    print str(err)
    1.10      usage()
    1.11      sys.exit(2)
    1.12  
    1.13 @@ -47,10 +46,15 @@
    1.14      sys.exit(1)
    1.15  
    1.16  try:
    1.17 -    exec 'from %s import * ' % (network)
    1.18 -except ImportError:
    1.19 -    print "Can't find or interpret module <%s> with topology description" %(network)
    1.20 -    sys.exit(1)
    1.21 +    execfile(network)
    1.22 +except IOError:
    1.23 +    print "Network configuration file <%s> not found " % network
    1.24 +    if network == 'network':
    1.25 +        print "You can use -n option to specify network filename"
    1.26 +    sys.exit(2)
    1.27 +except NameError:
    1.28 +    domain=domains[0]
    1.29 +    execfile(network)
    1.30  
    1.31  
    1.32  drbd_base_port=7790
     2.1 --- a/xen-drbd-start.py	Mon Sep 15 10:03:24 2008 +0300
     2.2 +++ b/xen-drbd-start.py	Thu Sep 18 11:42:52 2008 +0300
     2.3 @@ -7,9 +7,10 @@
     2.4  
     2.5  import sys
     2.6  
     2.7 -sys.path.append('/etc/xen')
     2.8 +#sys.path.append('/etc/xen')
     2.9 +
    2.10  try:
    2.11 -	exec 'from %s import *' % (network)
    2.12 +	execfile(network)
    2.13  except:
    2.14  	print "Can't find or interpret module %s with topology description" %(network)
    2.15  	sys.exit(1)
    2.16 @@ -28,8 +29,15 @@
    2.17      stdvga=0
    2.18      serial='pty'
    2.19  
    2.20 -memory=mem_table[domain]
    2.21 -vcpus=vcpus_table[domain]
    2.22 +try:
    2.23 +    memory=mem_table[domain]
    2.24 +except:
    2.25 +    pass 
    2.26 +
    2.27 +try:
    2.28 +    vcpus=vcpus_table[domain]
    2.29 +except:
    2.30 +    pass 
    2.31  
    2.32  disk=[]
    2.33  if domain_types[N] == 'hvm':
     3.1 --- a/xen-drbd.py	Mon Sep 15 10:03:24 2008 +0300
     3.2 +++ b/xen-drbd.py	Thu Sep 18 11:42:52 2008 +0300
     3.3 @@ -173,6 +173,8 @@
     3.4      xen_domain="domain=\"%s\"\n" % (domain) + xen_domain
     3.5      xen_domain="network=\"%s\"\n" % (network) + xen_domain
     3.6      do_import('xen_domain_module',xen_domain)
     3.7 +    #print "domain=\"%s\"\n" % (domain)
     3.8 +    #print "network=\"%s\"\n" % (network)
     3.9      import xen_domain_module
    3.10      xen_domain_module.print_config()
    3.11  
    3.12 @@ -230,8 +232,7 @@
    3.13  try:
    3.14      opts, args = getopt.getopt(sys.argv[1:], "hn:", ["help", "network="])
    3.15  except getopt.GetoptError, err:
    3.16 -    # print help information and exit:
    3.17 -    print str(err) # will print something like "option -a not recognized"
    3.18 +    print str(err)
    3.19      usage()
    3.20      sys.exit(2)
    3.21  
    3.22 @@ -247,14 +248,20 @@
    3.23  
    3.24  debug=2
    3.25  
    3.26 -
    3.27 +if len(args) == 2:
    3.28 +    domain=args[1]
    3.29  
    3.30  sys.path.append('/etc/xen')
    3.31  try:
    3.32 -        exec 'from %s import *' % (network)
    3.33 -except ImportError:
    3.34 -        print "Can't find or interpret module <%s> with topology description" %(network)
    3.35 -        sys.exit(1)
    3.36 +    execfile(network)
    3.37 +except IOError:
    3.38 +    print "Network configuration file <%s> not found " % network
    3.39 +    if network == 'network':
    3.40 +        print "You can use -n option to specify network filename"
    3.41 +    sys.exit(2)
    3.42 +except NameError:
    3.43 +    domain=domains[0]
    3.44 +    execfile(network)
    3.45  
    3.46  xen_drbd_start="/etc/xen/xen-drbd-start"
    3.47  domain_create_line="xm create "+xen_drbd_start+" network="+network+" domain=%s"