ToDo | 1 -
scripts/cfs_enable_tenant.py | 10 +++++++---
scripts/cfs_start_volume.py | 28 +++++++++++-----------------
3 files changed, 18 insertions(+), 21 deletions(-)
New commits:
commit 399e471f61b471d0531f8b1cf06502304ec035a3
Author: Jeff Darcy <jdarcy(a)redhat.com>
Date: Wed May 11 17:13:54 2011 -0400
Make volume-start code use same DB as tenant add/remove/enable.
diff --git a/ToDo b/ToDo
index 8ed0469..e51d2bd 100644
--- a/ToDo
+++ b/ToDo
@@ -1,5 +1,4 @@
= High Priority =
-Use real tenant list for start/mount (no default, handle zero)
Use arbitrary directories, not just mountpoints
Create log/pid directories, move port links to /var/run
Interface to remove volumes
diff --git a/scripts/cfs_enable_tenant.py b/scripts/cfs_enable_tenant.py
index 26ca099..3855546 100644
--- a/scripts/cfs_enable_tenant.py
+++ b/scripts/cfs_enable_tenant.py
@@ -17,13 +17,17 @@ def enable_local (tn_name, vol_list):
db_obj = cfs_utils.open_db()
db_obj["tv_"+tn_name] = vol_list
for vol in [v[3:] for v in db_obj.keys() if v.startswith("vt_")]:
- vt_list = set(db_obj["vt_"+vol].split(","))
+ vt_list = db_obj["vt_"+vol].split(",")
+ if vt_list == ['']:
+ # This is one of the stupider split() behaviors.
+ vt_list = []
+ vt_list = set(vt_list)
if vol in vol_list.split(","):
print "enabling %s" % vol
- vt_list.add(vol)
+ vt_list.add(tn_name)
else:
print "disabling %s" % vol
- vt_list.discard(vol)
+ vt_list.discard(tn_name)
db_obj["vt_"+vol] = string.join(vt_list,",")
return "Volumes enabled for %s on %s" % (tn_name, socket.gethostname())
diff --git a/scripts/cfs_start_volume.py b/scripts/cfs_start_volume.py
index 4c4e7bb..26f0980 100644
--- a/scripts/cfs_start_volume.py
+++ b/scripts/cfs_start_volume.py
@@ -18,12 +18,6 @@ import cfs_utils
def check_volume_directory(vol_name):
if not os.path.exists(cfs_paths.info_dir):
os.mkdir(cfs_paths.info_dir)
- user_file = open("%s/%s" % (cfs_paths.info_dir, "default_users"),
"w")
- # TBD: big gaping security hole until other code can deal
- # with having zero users defined.
- user_file.write("alice password1\nbob password2\n")
- user_file.flush()
- user_file.close()
os.mkdir(cfs_paths.idle_subdir)
for i in range(24010, 24030):
fp = open("%s/%d" % (cfs_paths.idle_subdir, i), "w")
@@ -79,18 +73,16 @@ def allocate_port(vol_file):
# everything that uses this is in Python we could just make it a pickle/shelf
# or whatever, but it would all go away with a real volume database so it's not
# worth the trouble to re-do it now.
-def parse_user_file(vol_name):
- try:
- user_file = open("%s/%s/users" % (cfs_paths.info_dir, vol_name),
"r")
- except IOError:
- user_file = open("%s/default_users" % cfs_paths.info_dir, "r")
-
+def parse_user_file (vol_name):
+ db_obj = cfs_utils.open_db()
users = []
- for line in user_file.readlines():
- space = line.find(" ")
- if space == -1:
- print >> sys.stderr, "Bad line in userfile: %s" % line
- users.append([line[:space],line[space+1:-1]])
+ user_list = db_obj["vt_"+vol_name].split(",")
+ if user_list == ['']:
+ user_list = []
+ for name in user_list:
+ print "found user %s" % name
+ pw = db_obj["tp_"+name]
+ users.append([name,pw])
return users
def cloudify_server (input, output, users, port):
@@ -137,6 +129,8 @@ def create_tenant_dirs(vol_file):
def start_local (vol_name):
vol_base = check_volume_directory(vol_name)
users = parse_user_file(vol_name)
+ if not len(users):
+ return "no users for %s on %s" % (vol_name, socket.gethostname())
# TBD: deal with more than one brick on the same server
vf = scan_gfs_volfiles(vol_name)
new_vf = "%s/%s" % (vol_base, os.path.basename(vf))
Show replies by date