diff options
Diffstat (limited to 'extras')
-rwxr-xr-x | extras/prot_filter.py | 12 | ||||
-rwxr-xr-x | extras/rebalance.py | 38 | ||||
-rw-r--r-- | extras/volfilter.py | 14 |
3 files changed, 32 insertions, 32 deletions
diff --git a/extras/prot_filter.py b/extras/prot_filter.py index 099832fc08a..e2b81218f40 100755 --- a/extras/prot_filter.py +++ b/extras/prot_filter.py @@ -43,7 +43,7 @@ def load (path): # If it's a string, open it; otherwise, assume it's already a # file-like object (most notably from urllib*). if type(path) in (str,): - fp = file(path,"r") + fp = file(path, "r") else: fp = path all_xlators = {} @@ -86,7 +86,7 @@ def load (path): def generate (graph, last, stream=sys.stdout): for sv in last.subvols: if not sv.dumped: - generate(graph,sv,stream) + generate(graph, sv, stream) print("", file=stream) sv.dumped = True print("volume %s" % last.name, file=stream) @@ -133,13 +133,13 @@ if __name__ == "__main__": sys.exit(0) for v in graph.values(): if v.xl_type == "cluster/distribute": - push_filter(graph,v,"features/prot_dht") + push_filter(graph, v, "features/prot_dht") elif v.xl_type == "protocol/client": - push_filter(graph,v,"features/prot_client") + push_filter(graph, v, "features/prot_client") # We push debug/trace so that every fop gets a real frame, because DHT # gets confused if STACK_WIND_TAIL causes certain fops to be invoked # from anything other than a direct child. for v in graph.values(): if v.xl_type == "features/prot_client": - push_filter(graph,v,"debug/trace") - generate(graph,last,stream=open(path,"w")) + push_filter(graph, v, "debug/trace") + generate(graph, last, stream=open(path, "w")) diff --git a/extras/rebalance.py b/extras/rebalance.py index 871b06682d5..32ca067b32d 100755 --- a/extras/rebalance.py +++ b/extras/rebalance.py @@ -39,13 +39,13 @@ class Brick: def get_bricks (host, vol): t = pipes.Template() - t.prepend("gluster --remote-host=%s system getspec %s"%(host,vol),".-") - return t.open(None,"r") + t.prepend("gluster --remote-host=%s system getspec %s"%(host, vol), ".-") + return t.open(None, "r") def generate_stanza (vf, all_xlators, cur_subvol): sv_list = [] for sv in cur_subvol.subvols: - generate_stanza(vf,all_xlators,sv) + generate_stanza(vf, all_xlators, sv) sv_list.append(sv.name) vf.write("volume %s\n"%cur_subvol.name) vf.write(" type %s\n"%cur_subvol.type) @@ -60,14 +60,14 @@ def mount_brick (localpath, all_xlators, dht_subvol): # Generate a volfile. vf_name = localpath + ".vol" - vf = open(vf_name,"w") - generate_stanza(vf,all_xlators,dht_subvol) + vf = open(vf_name, "w") + generate_stanza(vf, all_xlators, dht_subvol) vf.flush() vf.close() # Create a brick directory and mount the brick there. os.mkdir(localpath) - subprocess.call(["glusterfs","-f",vf_name,localpath]) + subprocess.call(["glusterfs", "-f", vf_name, localpath]) # We use the command-line tools because there's no getxattr support in the # Python standard library (which is ridiculous IMO). Adding the xattr package @@ -81,16 +81,16 @@ def mount_brick (localpath, all_xlators, dht_subvol): def get_range (brick): t = pipes.Template() cmd = "getfattr -e hex -n trusted.glusterfs.dht %s 2> /dev/null" - t.prepend(cmd%brick,".-") - t.append("grep ^trusted.glusterfs.dht=","--") - f = t.open(None,"r") + t.prepend(cmd%brick, ".-") + t.append("grep ^trusted.glusterfs.dht=", "--") + f = t.open(None, "r") try: value = f.readline().rstrip().split('=')[1][2:] except: print("could not get layout for %s (might be OK)" % brick) return None - v_start = int("0x"+value[16:24],16) - v_end = int("0x"+value[24:32],16) + v_start = int("0x"+value[16:24], 16) + v_end = int("0x"+value[24:32], 16) return (v_start, v_end) def calc_sizes (bricks, total): @@ -186,7 +186,7 @@ if __name__ == "__main__": if options.verbose: print("Cleaning up %s" % work_dir) for b in bricks: - subprocess.call(["umount",b.path]) + subprocess.call(["umount", b.path]) shutil.rmtree(work_dir) if not options.leave_mounted: atexit.register(cleanup_workdir) @@ -196,7 +196,7 @@ if __name__ == "__main__": if options.verbose: print("Mounting subvolumes...") index = 0 - volfile_pipe = get_bricks(hostname,volname) + volfile_pipe = get_bricks(hostname, volname) all_xlators, last_xlator = volfilter.load(volfile_pipe) for dht_vol in all_xlators.itervalues(): if dht_vol.type == "cluster/distribute": @@ -208,8 +208,8 @@ if __name__ == "__main__": #print "found subvol %s" % sv.name lpath = "%s/brick%s" % (work_dir, index) index += 1 - mount_brick(lpath,all_xlators,sv) - bricks.append(Brick(lpath,sv.name)) + mount_brick(lpath, all_xlators, sv) + bricks.append(Brick(lpath, sv.name)) if index == 0: print("no bricks") sys.exit(1) @@ -251,11 +251,11 @@ if __name__ == "__main__": if rs > re: print("%s has backwards hash range" % b.path) sys.exit(1) - b.set_range(hash_range[0],hash_range[1]) + b.set_range(hash_range[0], hash_range[1]) if options.verbose: print("Calculating new layouts...") - calc_sizes(bricks,total) + calc_sizes(bricks, total) bricks, used = normalize(bricks) # We can't afford O(n!) here, but O(n^2) should be OK and the result @@ -266,7 +266,7 @@ if __name__ == "__main__": for i in range(used): new_bricks = bricks[:] del new_bricks[used] - new_bricks.insert(i,bricks[used]) + new_bricks.insert(i, bricks[used]) new_score = get_score(new_bricks) if new_score > best_score: best_place = i @@ -274,7 +274,7 @@ if __name__ == "__main__": if best_place != used: nb = bricks[used] del bricks[used] - bricks.insert(best_place,nb) + bricks.insert(best_place, nb) used += 1 # Finalize whatever we decided on. diff --git a/extras/volfilter.py b/extras/volfilter.py index 515a6408bb9..da0a0e62ddb 100644 --- a/extras/volfilter.py +++ b/extras/volfilter.py @@ -36,7 +36,7 @@ good_xlators = [ "storage/posix", ] -def copy_stack (old_xl,suffix,recursive=False): +def copy_stack (old_xl, suffix, recursive=False): if recursive: new_name = old_xl.name + "-" + suffix else: @@ -46,7 +46,7 @@ def copy_stack (old_xl,suffix,recursive=False): # The results with normal assignment here are . . . amusing. new_xl.opts = copy.deepcopy(old_xl.opts) for sv in old_xl.subvols: - new_xl.subvols.append(copy_stack(sv,suffix,True)) + new_xl.subvols.append(copy_stack(sv, suffix, True)) # Patch up the path at the bottom. if new_xl.type == "storage/posix": new_xl.opts["directory"] += ("/" + suffix) @@ -64,10 +64,10 @@ def cleanup (parent, graph): parent.opts["transport-type"] = "ssl" sv = [] for child in parent.subvols: - sv.append(cleanup(child,graph)) + sv.append(cleanup(child, graph)) parent.subvols = sv else: - parent = cleanup(parent.subvols[0],graph) + parent = cleanup(parent.subvols[0], graph) return parent class Translator: @@ -84,7 +84,7 @@ def load (path): # If it's a string, open it; otherwise, assume it's already a # file-like object (most notably from urllib*). if type(path) in (str,): - fp = file(path,"r") + fp = file(path, "r") else: fp = path all_xlators = {} @@ -127,7 +127,7 @@ def load (path): def generate (graph, last, stream=sys.stdout): for sv in last.subvols: if not sv.dumped: - generate(graph,sv,stream) + generate(graph, sv, stream) print("", file=stream) sv.dumped = True print("volume %s" % last.name, file=stream) @@ -165,4 +165,4 @@ def delete (graph, victim): if __name__ == "__main__": graph, last = load(sys.argv[1]) - generate(graph,last) + generate(graph, last) |