xen-drbd

changeset 26:e859a316802b

fixes + debug
author igor
date Tue Feb 19 19:11:25 2008 +0200 (2008-02-19)
parents 50d097b46c8d
children a1403dbe68c0
files xen-drbd.py
line diff
     1.1 --- a/xen-drbd.py	Tue Feb 19 18:32:26 2008 +0200
     1.2 +++ b/xen-drbd.py	Tue Feb 19 19:11:25 2008 +0200
     1.3 @@ -1,6 +1,7 @@
     1.4  #!/usr/bin/python
     1.5  
     1.6  network='od'
     1.7 +debug=2
     1.8  
     1.9  import sys,os,imp
    1.10  from commands import mkarg
    1.11 @@ -30,9 +31,11 @@
    1.12  
    1.13  def run_now(command,node=i_am):
    1.14      if node == i_am:
    1.15 -        line=command+" > /dev/stderr"
    1.16 +        line=command+" > /dev/stderr 2>&1"
    1.17      else:
    1.18 -        line="ssh %s %s < /dev/null > /dev/stderr"  % (node,mkarg(command))
    1.19 +        line="ssh %s %s < /dev/null > /dev/stderr 2>&1"  % (node,mkarg(command))
    1.20 +    if debug > 2:
    1.21 +        print "debug:", line
    1.22      (p, child_stdout, child_stderr) = os.popen3(line)
    1.23      output = child_stderr.read()
    1.24      #p = os.popen(line)
    1.25 @@ -56,17 +59,22 @@
    1.26          else:
    1.27              disk.append((disk_description.split(':'))[1])
    1.28      return disk
    1.29 -    
    1.30  
    1.31  def set_drbd_primary(domain, node=i_am):
    1.32 +    res=""
    1.33      drbd_resources=get_drbd_resources(domain)
    1.34      for drbd in drbd_resources:
    1.35 -        print run("drbdadm primary %s"%(drbd),node)
    1.36 +        res += run("drbdadm primary %s"%(drbd),node)
    1.37 +        print "DRBD resource <%s> on the node <%s> is <%s> now" % (drbd,node,get_drbd_state(drbd,node))
    1.38 +    return res
    1.39  
    1.40  def set_drbd_secondary(domain, node=i_am):
    1.41 +    res=""
    1.42      drbd_resources=get_drbd_resources(domain)
    1.43      for drbd in drbd_resources:
    1.44 -        print run("drbdadm secondary %s"%(drbd),node)
    1.45 +        res += run("drbdadm secondary %s"%(drbd),node)
    1.46 +        print "DRBD resource <%s> on the node <%s> is <%s> now" % (drbd,node,get_drbd_state(drbd,node))
    1.47 +    return res
    1.48  
    1.49  def get_domain_id(domain,node=i_am):
    1.50      """
    1.51 @@ -107,9 +115,9 @@
    1.52          log_error("Domain %s is running already on the node %s" % (domain,he_is))
    1.53          return -1
    1.54      another_node=the_peer_of(node)
    1.55 -    set_drbd_secondary(domain,another_node)
    1.56 -    set_drbd_primary(domain,node)
    1.57 -    run(domain_create_line % domain)
    1.58 +    print set_drbd_secondary(domain,another_node)
    1.59 +    print set_drbd_primary(domain,node)
    1.60 +    print run(domain_create_line % domain)
    1.61  
    1.62  def migrate_domain_out(domain,node=i_am):
    1.63      if (get_domain_id(domain,node) == -1):