summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Snapshots
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-03-23 02:29:43 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-03-23 02:29:43 +0000
commit0f14d54f6a493fb398ff5c2e40fd898b64afc02c (patch)
treeb7a2dfae177457e034d7d7c8ae7d3814703274ea /src/lib/Server/Snapshots
parentf7421a97956a1e3894ebbc8434b18f15ecebf056 (diff)
downloadbcfg2-0f14d54f6a493fb398ff5c2e40fd898b64afc02c.tar.gz
bcfg2-0f14d54f6a493fb398ff5c2e40fd898b64afc02c.tar.bz2
bcfg2-0f14d54f6a493fb398ff5c2e40fd898b64afc02c.zip
Snapshots: add db url support for mysql and postgres
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5139 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Snapshots')
-rw-r--r--src/lib/Server/Snapshots/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/Server/Snapshots/__init__.py b/src/lib/Server/Snapshots/__init__.py
index b94511ebd..2168ee55f 100644
--- a/src/lib/Server/Snapshots/__init__.py
+++ b/src/lib/Server/Snapshots/__init__.py
@@ -9,8 +9,14 @@ def db_from_config(fname='/etc/bcfg2.conf'):
if driver == 'sqlite':
path = cp.get('snapshots', 'database')
return 'sqlite:///%s' % path
+ elif driver in ['mysql', 'postgres']:
+ user = cp.get('snapshots', 'user')
+ password = cp.get('snapshots', 'password')
+ host = cp.get('snapshots', 'host')
+ db = cp.get('snapshots', 'database')
+ return '%s://%s:%s@%s/@s' % (driver, user, password, host, db)
else:
- raise Exception, "not done yet"
+ raise Exception, "unsupported db driver %s" % driver
def setup_session(debug=False):