scripts/cfs_utils.py scripts/cloudfsd.py scripts/views

Jeff Darcy jdarcy at fedoraproject.org
Thu Jun 9 20:24:13 UTC 2011


 scripts/cfs_utils.py       |    8 ++++----
 scripts/cloudfsd.py        |    7 ++++---
 scripts/views/volumes.html |    3 ++-
 3 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 3dae2dc365599c9f733094b3e1c8ac89f8c6bba8
Author: Kaleb S. KEITHLEY <kkeithle at redhat.com>
Date:   Thu Jun 9 12:01:14 2011 -0400

    fix nit issues in the UI in preparation for adding UI to specify uid/gid
    ranges per tenant.
      cfs_utils.py: fix use_sudo (fmt string); don't make_remote when host
        is local; use IP addr for localhost's name like all other nodes; sort
        node_list, maybe just (semantic) sugar, but will be nice for long
        lists of nodes and mounts
      cloudfsd.py: glue between cfs_utils sorted node list and printing
        nodes-and-mounts in sorted order
      views/volumes.html: utilize sorted node_list to print nodes-and-mounts
        in order

diff --git a/scripts/cfs_utils.py b/scripts/cfs_utils.py
index 39a36e0..ed6c6c4 100644
--- a/scripts/cfs_utils.py
+++ b/scripts/cfs_utils.py
@@ -40,8 +40,8 @@ def run_cmd (program, args, host=None, filters=[]):
 	for prog2, args2 in filters:
 		cmd = "%s | %s %s" % (cmd, get_path(prog2), args2)
 	if use_sudo:
-		cmd = "%s %s" % cmd
-	if host:
+		cmd = "sudo %s" % cmd
+	if host and host not in local_addrs:
 		cmd = make_remote(host,cmd)
 	if len(filters):
 		#print "executing %s using shell" % cmd
@@ -70,12 +70,12 @@ for line in run_cmd("ip","addr").stdout:
 def get_members ():
 	peer_ips = run_cmd("gluster","peer status",
 			   filters=[("grep","Hostname:")]).stdout
-	my_ip = socket.gethostbyname(socket.gethostname())
-	node_list = [socket.gethostbyaddr(my_ip)[0]]
+	node_list = [socket.gethostbyname(socket.gethostname())]
 	# For each line: strip off the trailing newline, split at colon, take
 	# item #1
 	for peer in [line[:-1].split(": ")[1] for line in peer_ips]:
 		node_list.append(peer)
+	node_list.sort()
 	return node_list
 
 # A brick list looks something like this:
diff --git a/scripts/cloudfsd.py b/scripts/cloudfsd.py
index 8255a44..145f51f 100755
--- a/scripts/cloudfsd.py
+++ b/scripts/cloudfsd.py
@@ -48,8 +48,9 @@ def add_node():
 def show_volumes():
 	brick_list = cfs_utils.get_bricks()
 	mount_list = cfs_utils.get_mounts(brick_list)
+	node_list = cfs_utils.get_members()
 	# TBD: allow adding arbitrary directories instead of just mountpoints
-	return dict(bricks=brick_list,mounts=mount_list)
+	return dict(bricks=brick_list,mounts=mount_list,nodes=node_list)
 
 @post("/volumes/add_directory")
 def add_directory ():
@@ -133,10 +134,10 @@ def delete_tenant_local (tn_name):
 def show_tenant_volumes (tn_name):
 	db_obj = cfs_utils.open_db()
 	all_vols = [v[3:] for v in db_obj.keys() if v.startswith("vt_")]
-	print all_vols
+	# print all_vols
 	active = db_obj["tv_"+tn_name].split(",")
 	active.sort()
-	print active
+	# print active
 	return dict(tn_name=tn_name,all_vols=all_vols,active=active)
 
 @post("/tenants/:tn_name/enable")
diff --git a/scripts/views/volumes.html b/scripts/views/volumes.html
index cc54f92..12ef314 100644
--- a/scripts/views/volumes.html
+++ b/scripts/views/volumes.html
@@ -40,7 +40,8 @@
 <form method="post" name="provision" action="/volumes/add_volume">
 <table>
 	%color_index = 0
-	%for node, mount_list in mounts.iteritems():
+	%for node in nodes:
+		%mount_list = mounts[node]
 		%color = "d%d" % color_index
 		%color_index = (color_index + 1) % 2
 		<tr class="{{color}}">




More information about the cloudfs-devel mailing list