https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113791
Revision: 113791
Author: laner
Date: 2012-03-14 01:23:01 +0000 (Wed, 14 Mar 2012)
Log Message:
-----------
Fixing global sharing to use NFS, and make it read only. Also ensuring that all
volumes are shared with all bricks, by IP address (since hostname seemed to
fail).
Modified Paths:
--------------
trunk/tools/subversion/user-management/manage-volumes
Modified: trunk/tools/subversion/user-management/manage-volumes
===================================================================
--- trunk/tools/subversion/user-management/manage-volumes 2012-03-14
00:51:04 UTC (rev 113790)
+++ trunk/tools/subversion/user-management/manage-volumes 2012-03-14
01:23:01 UTC (rev 113791)
@@ -20,7 +20,7 @@
self.gluster_vol_dir = '/etc/glusterd/'
# Volumes in projects listed as global; so: { 'dumps': ['xml']
} would be
# an xml share in the dumps project being listed as global.
- self.global_shares = {}
+ self.global_shares = {'publicdata': ['project']}
self.volume_quotas = {'home': '50GB','default': '300GB'}
self.default_options = ['nfs.disable on']
self.bricks = ['labstore1.pmtpa.wmnet',
'labstore2.pmtpa.wmnet', 'labstore3.pmtpa.wmnet', 'labstore4.pmtpa.wmnet']
@@ -57,6 +57,11 @@
project_name = project[1]["cn"][0]
hosts = []
if project_name in project_hosts:
+ brick_ips = []
+ for brick in self.bricks:
+
brick_ips.append(socket.gethostbyname(brick))
+ hosts.extend(brick_ips)
+ hosts = list(set(hosts))
hosts = project_hosts[project_name]
hosts.sort()
for volume_name in self.volume_names:
@@ -83,10 +88,13 @@
volume_hosts.sort()
if project_name in self.global_shares and
volume_name in self.global_shares[project_name]:
# This is a global share
- if volume_hosts != ['*']:
-
self.setallow(project_name,volume_name,['*'])
- elif hosts:
# A host has been added or deleted,
modify the auth.allow
+ volume_nfs_hosts = ''
+ if project_volume in project_volumes
and 'nfs.rpc-auth-allow' in project_volumes[project_volume]:
+ volume_nfs_hosts =
project_volumes[project_volume]['nfs.rpc-auth-allow']
+ if volume_nfs_hosts != '*':
+
self.setglobal(project_name,volume_name)
+ if hosts:
if volume_hosts != hosts:
self.setallow(project_name,volume_name,hosts)
else:
@@ -134,9 +142,15 @@
else:
hosts = 'NONE'
volume = project_name + '-' + volume_name
- self.ssh_exec_command('sudo gluster volume set ' + volume + '
auth.allow ' +hosts, True)
+ self.ssh_exec_command('sudo gluster volume set ' + volume + '
auth.allow ' + hosts, True)
self.log("Modified auth.allow for: " + volume)
+ def setglobal(self, project_name, volume_name):
+ volume = project_name + '-' + volume_name
+ self.ssh_exec_command('sudo gluster volume set ' + volume + '
nfs.disable ' + 'off', True)
+ self.ssh_exec_command('sudo gluster volume set ' + volume + '
nfs.volume-access ' + 'read-only', True)
+ self.ssh_exec_command('sudo gluster volume set ' + volume + '
nfs.rpc-auth-allow ' + '\*', True)
+
def ssh_exec_command(self, command, single=False, return_stdout=False):
if single:
# Only run this on a single brick, we arbitrarily pick
the first one
@@ -163,6 +177,8 @@
self.log(brick + ' - "' + command + '"')
chan.exec_command(command)
ret = chan.recv_exit_status()
+ if self.loglevel >= DEBUG:
+ self.log("Return value: " + str(ret))
if return_stdout:
# Since we are using a channel, we need to keep
reading until there isn't
# any output left
@@ -202,19 +218,21 @@
current_volume = ''
for line in volumedata:
line = line.strip()
+ if not line:
+ current_volume = ''
+ continue
line_arr = line.split(': ')
if len(line_arr) == 2 and line_arr[0] ==
"Volume Name":
current_volume = line_arr[1]
+ volumes[current_volume] = {}
elif len(line_arr) == 2 and line_arr[0] ==
"auth.allow":
if line_arr[1] == "NONE":
hosts = []
else:
hosts = line_arr[1].split(',')
- volumes[current_volume] =
{'auth.allow': hosts}
- # Let's reset the current_volume, in
case there are any
- # weird formatting errors, we wouldn't
want to add another
- # project's IPs to this volume.
- current_volume = ''
+ volumes[current_volume]['auth.allow'] =
hosts
+ elif len(line_arr) == 2 and line_arr[0] ==
"nfs.rpc-auth-allow":
+
volumes[current_volume]['nfs.rpc-auth-allow'] = line_arr[1]
return volumes
def search_s(self,ds,base,scope,query,attrlist=None):
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs