scripts/cfs_add_tenant.py | 34 +++++++++++++++++++++++++---------
scripts/cfs_delete_tenant.py | 4 ++++
scripts/cfs_start_volume.py | 19 ++++++++-----------
scripts/styles/cfgmain.css | 3 ++-
scripts/views/tenants.html | 16 ++++++++++++++--
5 files changed, 53 insertions(+), 23 deletions(-)
New commits:
commit f193cd2eb6d605c8c531ae149b115f0883549f86
Author: Kaleb S. KEITHLEY <kkeithle(a)redhat.com>
Date: Fri Jun 10 11:50:34 2011 -0400
Add configuration of per tenant uid and gid ranges to UI; both web
and cli.
This change breaks the /var/lib/cloudfs/config.db.*. Before applying
this update you should use the UI to delete all tenants and volumes,
then delete /var/lib/cloudfs/config.db.*. After updating you will
need to reconfigure, adding back the volumes and tenants you had
previously configured.
cfs_add_tenant.py (CLI) now takes six parameters (instead of two):
cfs_add_tenant.py <name> <password> <uid_low> <uid_high> <gid_low> <gid_high>
Possible enhancements include scanning all uids/gids to determine
the start of the next available range and populating that in the
relevant fields of of the web form, and using default values in the
CLI when they aren't given on the command line.
diff --git a/scripts/cfs_add_tenant.py b/scripts/cfs_add_tenant.py
index d460367..3636c26 100755
--- a/scripts/cfs_add_tenant.py
+++ b/scripts/cfs_add_tenant.py
@@ -12,25 +12,33 @@ from bottle import request, template
import cfs_utils
import cfs_paths
-def add_local (tn_name, tn_pw):
+def add_local (tn_name, tn_pw, tn_uid_low, tn_uid_high, tn_gid_low, tn_gid_high):
# TBD: all sorts of input-validity checking
db_obj = cfs_utils.open_db()
db_obj["tp_"+tn_name] = tn_pw
+ db_obj["tul_"+tn_name] = tn_uid_low
+ db_obj["tuh_"+tn_name] = tn_uid_high
+ db_obj["tgl_"+tn_name] = tn_gid_low
+ db_obj["tgh_"+tn_name] = tn_gid_high
db_obj["tv_"+tn_name] = ""
return "add_local(%s) OK on %s" % (tn_name, socket.gethostname())
-def run_common (tn_name, tn_pw):
+def run_common (tn_name, tn_pw, tn_uid_low, tn_uid_high, tn_gid_low, tn_gid_high):
node_list = cfs_utils.get_members()
blob = []
for node in node_list:
scratch = [node, []]
- if socket.gethostbyname(node) in cfs_utils.local_addrs:
- url_obj = [add_local(tn_name,tn_pw)]
+ if node in cfs_utils.local_addrs:
+ url_obj = [add_local(tn_name,tn_pw,tn_uid_low,tn_uid_high,tn_gid_low,tn_gid_high)]
else:
url = "http://%s:%d/tenants/add_local" % (
node, cfs_paths.CLOUDFSD_PORT)
data = urllib.urlencode([("tn_name",tn_name),
- ("tn_pw",tn_pw)])
+ ("tn_pw",tn_pw),
+ ("tn_uid_low",tn_uid_low),
+ ("tn_uid_high",tn_uid_high),
+ ("tn_gid_low",tn_gid_low),
+ ("tn_gid_high",tn_gid_high)])
url_obj = urllib2.urlopen(url,data=data)
for line in url_obj:
scratch[1].append(line)
@@ -40,16 +48,24 @@ def run_common (tn_name, tn_pw):
def run_www ():
tn_name = request.forms.get("tn_name")
tn_pw = request.forms.get("tn_pw")
- blob = run_common(tn_name,tn_pw)
+ tn_uid_low = request.forms.get("tn_uid_low")
+ tn_uid_high = request.forms.get("tn_uid_high")
+ tn_gid_low = request.forms.get("tn_gid_low")
+ tn_gid_high = request.forms.get("tn_gid_high")
+ blob = run_common(tn_name,tn_pw,tn_uid_low,tn_uid_high,tn_gid_low,tn_gid_high)
return template("tn_act_done.html",name=tn_name,action="added",
- blob=blob);
+ blob=blob)
if __name__ == "__main__":
- if len(sys.argv) != 3:
+ if len(sys.argv) != 7:
print >> sys.stderr, "Usage: %s name password" % sys.argv[0]
sys.exit(1)
tn_name = sys.argv[1]
tn_pw = sys.argv[2]
- blob = run_common(tn_name,tn_pw)
+ tn_uid_low = sys.argv[3]
+ tn_uid_high = sys.argv[4]
+ tn_gid_low = sys.argv[5]
+ tn_gid_high = sys.argv[6]
+ blob = run_common(tn_name,tn_pw,tn_uid_low,tn_uid_high,tn_gid_low,tn_gid_high)
print "Tenant %s added." % tn_name
cfs_utils.print_blob(blob)
diff --git a/scripts/cfs_delete_tenant.py b/scripts/cfs_delete_tenant.py
index 92c11d7..1326fba 100755
--- a/scripts/cfs_delete_tenant.py
+++ b/scripts/cfs_delete_tenant.py
@@ -15,6 +15,10 @@ def delete_local (tn_name):
# TBD: all sorts of input-validity checking
db_obj = cfs_utils.open_db()
del db_obj["tp_"+tn_name]
+ del db_obj["tul_"+tn_name]
+ del db_obj["tuh_"+tn_name]
+ del db_obj["tgl_"+tn_name]
+ del db_obj["tgh_"+tn_name]
del db_obj["tv_"+tn_name]
return "delete_local(%s) OK on %s" % (tn_name, socket.gethostname())
diff --git a/scripts/cfs_start_volume.py b/scripts/cfs_start_volume.py
index 1c60935..288b052 100755
--- a/scripts/cfs_start_volume.py
+++ b/scripts/cfs_start_volume.py
@@ -96,7 +96,11 @@ def parse_user_file (vol_name):
for name in user_list:
print "found user %s" % name
pw = db_obj["tp_"+name]
- users.append([name,pw])
+ ul = db_obj["tul_"+name]
+ uh = db_obj["tuh_"+name]
+ gl = db_obj["tgl_"+name]
+ gh = db_obj["tgh_"+name]
+ users.append([name,pw,ul,uh,gl,gh])
return users
def cloudify_server (input, output, users, port):
@@ -119,20 +123,13 @@ def cloudify_server (input, output, users, port):
print "# stripping auth option %s = %s" % (opt, last.opts[opt])
del last.opts[opt]
- uid_base = 10000
- uid_incr = 1000
- gid_base = 10000
- gid_incr = 1000
uidmap_opts = dict()
-
last.subvols = []
- for user, pw in users:
+ for user, pw, ul, uh, gl, gh in users:
uidmap_opts[user] = dict()
uidmap_opts[user]["uidmap-plugin"] = "libmaprbtree.so"
- uidmap_opts[user]["uid-range"] = "%d-%d" % (uid_base, uid_base + uid_incr - 1)
- uidmap_opts[user]["gid-range"] = "%d-%d" % (gid_base, gid_base + uid_incr - 1)
- uid_base = uid_base + uid_incr
- gid_base = gid_base + gid_incr
+ uidmap_opts[user]["uid-range"] = "%s-%s" % (ul, uh)
+ uidmap_opts[user]["gid-range"] = "%s-%s" % (gl, gh)
new_stack = volfilter.copy_stack(old_stack,user)
volfilter.push_filter(graph, new_stack, "features/uidmap", uidmap_opts[user])
last.subvols.append(new_stack)
diff --git a/scripts/views/tenants.html b/scripts/views/tenants.html
index 6b5d069..b9cc257 100644
--- a/scripts/views/tenants.html
+++ b/scripts/views/tenants.html
@@ -11,12 +11,20 @@
<div class="content">
<h2>Existing Tenants:</h2>
<table>
- <tr><th>Name</th><th>Password</th><th></th></tr>
+ <tr><th>Name</th><th>Password</th
+ ><th>UID low</th><th>UID high</th>
+ <th>GID low</th><th>GID high</th><th></th></tr>
%tn_list = tenants.keys()
%tn_list.sort()
%for tn_name in [t[3:] for t in tn_list if t.startswith("tp_")]:
%tn_pw = tenants["tp_"+tn_name]
+ %tn_uid_low = tenants["tul_"+tn_name]
+ %tn_uid_high = tenants["tuh_"+tn_name]
+ %tn_gid_low = tenants["tgl_"+tn_name]
+ %tn_gid_high = tenants["tgh_"+tn_name]
<tr><td>{{tn_name}}</td><td>{{tn_pw}}</td>
+ <td>{{tn_uid_low}}</td><td>{{tn_uid_high}}</td>
+ <td>{{tn_gid_low}}</td><td>{{tn_gid_high}}</td>
<td><a href="/tenants/{{tn_name}}/volumes">volumes</a>
<a href="/tenants/{{tn_name}}/delete">delete</a></td>
</tr>
@@ -27,7 +35,11 @@
<form method="post" action="/tenants/add">
Tenant Name: <input type="text" name="tn_name" size="20" />
Tenant Password: <input type="text" name="tn_pw" size="20" />
- <input type="submit" name="PROVISION" value="Add" />
+ <br>Tenant UID Range: Low: <input type="text" name="tn_uid_low" size="5" />
+ High: <input type="text" name="tn_uid_high" size="5" />
+ <br>Tenant GID Range: Low: <input type="text" name="tn_gid_low" size="5" />
+ High: <input type="text" name="tn_gid_high" size="5" />
+ <br><input type="submit" name="PROVISION" value="Add" />
</form>
</div>
</body></html>
commit 8636809eb3102d2fcda0b3551ddf7d0f37c9e3b5
Author: Kaleb S. KEITHLEY <kkeithle(a)redhat.com>
Date: Fri Jun 10 11:49:59 2011 -0400
change header/banner bg color to Fedora Blue (v. RHEL Red) since
we'll be releasing on Fedora first
diff --git a/scripts/styles/cfgmain.css b/scripts/styles/cfgmain.css
index 82043e8..4e7f1f7 100644
--- a/scripts/styles/cfgmain.css
+++ b/scripts/styles/cfgmain.css
@@ -11,7 +11,8 @@ body {
text-align: center;
margin: 0;
padding: 0.6em 2em 0.4em;
- background-color: #900;
+ /* background-color: fedora=#2a5694, rhel=#990000 */
+ background-color: #2a5694;
color: #fff;
font-weight: bold;
font-size: 1.75em;