From 0f14d54f6a493fb398ff5c2e40fd898b64afc02c Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Mon, 23 Mar 2009 02:29:43 +0000 Subject: 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 --- src/lib/Server/Snapshots/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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): -- cgit v1.2.3-1-g7c22