|
From: <fcr...@us...> - 2012-04-06 13:21:31
|
Revision: 818
http://safekeep.svn.sourceforge.net/safekeep/?rev=818&view=rev
Author: fcrawford
Date: 2012-04-06 13:21:23 +0000 (Fri, 06 Apr 2012)
Log Message:
-----------
- generate a working "password file" for PostgreSQL by
Marco Bozzolan <ma...@s1...>
- set "nouuid" mount option for snapshots based on XFS filesystems from code by
Robert Jordan <rj...@no...> and
Alexander 'Leo' Bergolth <le...@st...>
- added attribute to supply mount options for snapshots as suggested by
Bryan Talbot <bt...@ae...>
- cleaned up coding for tempfile
Modified Paths:
--------------
safekeep/trunk/safekeep
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2012-02-18 13:26:47 UTC (rev 817)
+++ safekeep/trunk/safekeep 2012-04-06 13:21:23 UTC (rev 818)
@@ -68,6 +68,7 @@
base_dir = None
current_pid = os.getpid()
default_bandwidth = {}
+default_mountoptions = { 'xfs' : 'nouuid' }
PROTOCOL = "1.2"
VERSION = "1.4.0"
@@ -196,7 +197,6 @@
return (proc.wait(), lines)
else:
return (0, lines)
-
def _spawn(args, stdin=None, stdout=False):
if isinstance(args, types.StringTypes):
@@ -338,7 +338,8 @@
tags.append(tag.strip())
elif is_client:
warn('Device: %s: empty tag in taglist: %s' % (device, tag_el))
- return { 'device' : device, 'size' : size, 'tags' : tags }
+ mountoptions = snap_el.getAttribute('mount-options')
+ return { 'device' : device, 'size' : size, 'tags' : tags, 'mountoptions' : mountoptions }
def parse_clude(clude_el):
path = clude_el.getAttribute('path')
@@ -474,7 +475,7 @@
'/var/named/chroot/dev', '/var/named/chroot/proc',
'/var/named/chroot/var/run', '/var/named/chroot/var/tmp' ]
cludes = [{ 'type' : 'exclude', 'path' : path, 'glob' : None, 'regexp' : None } for path in path_xcludes]
-
+
return { 'id': cfg_id, 'host' : host, 'port' : port, 'nice' : nice, 'user' : user, 'key_ctrl' : key_ctrl, 'key_data' : key_data,
'dir' : repo_dir, 'retention' : retention, 'dumps' : dumps, 'snaps' : snaps, 'script' : script,
'cludes' : cludes, 'data_options' : data_options, 'options' : options, 'bw' : bw}
@@ -574,7 +575,7 @@
if dump['dbpasswd']:
(fd, passwdfile) = tempfile.mkstemp()
f = os.fdopen(fd, 'w')
- f.write(dump['dbpasswd'])
+ f.write('*:*:*:*:%s' % dump['dbpasswd'])
f.close()
elif dbtype in ('mysql'):
@@ -599,7 +600,6 @@
cmd = ' '.join([commands.mkarg(arg) for arg in args])
cmd = '%s > %s' % (cmd, commands.mkarg(dump['file']))
-
if passwdfile:
os.environ['PGPASSFILE'] = passwdfile
try:
@@ -711,7 +711,12 @@
warn('Can not snapshot the device: %s' % device)
continue
# no need to mkdir since the mountpoint already exists
- args = ['mount', '-t', snaptyp, snapdev, snapmnt]
+ args = ['mount', '-t', snaptyp]
+ if snap['mountoptions']:
+ args.extend(['-o', snap['mountoptions']])
+ elif snaptyp in default_mountoptions:
+ args.extend(['-o', default_mountoptions[snaptyp]])
+ args.extend([snapdev, snapmnt])
ec = spawn(args)
if ec:
warn('Can not mount the snapshot: %s' % device)
@@ -822,7 +827,7 @@
ret = spawn(['modprobe', 'dm-snapshot'])
if ret:
warn('modprobe dm-snapshot failed, continuing')
- bdir = tempfile.mkdtemp("-rbind", "safekeep-%d-" % current_pid, "/mnt")
+ bdir = tempfile.mkdtemp(suffix="-rbind", prefix="safekeep-%d-" % current_pid, dir="/mnt")
ret = do_rbind(cfg, '/', bdir)
if ret:
warn('mount --rbind failed, snapshotting will be disabled')
@@ -1003,6 +1008,7 @@
if script_loc == 'server':
if not script_dir:
script_dir = tempfile.mkdtemp(prefix="safekeep-%d-" % current_pid)
+ tempfile.tempdir = script_dir
script = os.path.basename(script)
(fd, cfg['script']) = tempfile.mkstemp(prefix="%s-" % script, dir=script_dir)
script_file = os.fdopen(fd, 'w')
@@ -1059,6 +1065,7 @@
if not script_file.closed: script_file.close()
os.remove(cfg['script'])
if script_dir:
+ tempfile.tempdir = None
try:
os.rmdir(script_dir)
except OSError, e:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|