# HG changeset patch # User igor # Date 1203441085 -7200 # Node ID e859a316802bcde433c8c5ea85cf04f9937d0dcb # Parent 50d097b46c8da9db2bd87bd033cce092b626bb14 fixes + debug diff -r 50d097b46c8d -r e859a316802b xen-drbd.py --- a/xen-drbd.py Tue Feb 19 18:32:26 2008 +0200 +++ b/xen-drbd.py Tue Feb 19 19:11:25 2008 +0200 @@ -1,6 +1,7 @@ #!/usr/bin/python network='od' +debug=2 import sys,os,imp from commands import mkarg @@ -30,9 +31,11 @@ def run_now(command,node=i_am): if node == i_am: - line=command+" > /dev/stderr" + line=command+" > /dev/stderr 2>&1" else: - line="ssh %s %s < /dev/null > /dev/stderr" % (node,mkarg(command)) + line="ssh %s %s < /dev/null > /dev/stderr 2>&1" % (node,mkarg(command)) + if debug > 2: + print "debug:", line (p, child_stdout, child_stderr) = os.popen3(line) output = child_stderr.read() #p = os.popen(line) @@ -56,17 +59,22 @@ else: disk.append((disk_description.split(':'))[1]) return disk - def set_drbd_primary(domain, node=i_am): + res="" drbd_resources=get_drbd_resources(domain) for drbd in drbd_resources: - print run("drbdadm primary %s"%(drbd),node) + res += run("drbdadm primary %s"%(drbd),node) + print "DRBD resource <%s> on the node <%s> is <%s> now" % (drbd,node,get_drbd_state(drbd,node)) + return res def set_drbd_secondary(domain, node=i_am): + res="" drbd_resources=get_drbd_resources(domain) for drbd in drbd_resources: - print run("drbdadm secondary %s"%(drbd),node) + res += run("drbdadm secondary %s"%(drbd),node) + print "DRBD resource <%s> on the node <%s> is <%s> now" % (drbd,node,get_drbd_state(drbd,node)) + return res def get_domain_id(domain,node=i_am): """ @@ -107,9 +115,9 @@ log_error("Domain %s is running already on the node %s" % (domain,he_is)) return -1 another_node=the_peer_of(node) - set_drbd_secondary(domain,another_node) - set_drbd_primary(domain,node) - run(domain_create_line % domain) + print set_drbd_secondary(domain,another_node) + print set_drbd_primary(domain,node) + print run(domain_create_line % domain) def migrate_domain_out(domain,node=i_am): if (get_domain_id(domain,node) == -1):