From da5488929b36ace1078a48b2dcb7bc87316f339f Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 30 Apr 2013 22:12:17 -0700 Subject: [PATCH] fixes to modules.mongodb.db_exists --- salt/modules/mongodb.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py index 9d1eba31cd..a7c9e6325b 100644 --- a/salt/modules/mongodb.py +++ b/salt/modules/mongodb.py @@ -16,6 +16,9 @@ Module to provide MongoDB functionality to Salt # Import python libs import logging +# Import salt libs +from salt._compat import string_types + # Import third party libs try: import pymongo @@ -76,17 +79,16 @@ def db_list(user=None, password=None, host=None, port=None): return err.message -def db_exists(name, user=None, password=None, host=None, port=None, - database='admin'): +def db_exists(name, user=None, password=None, host=None, port=None): ''' Checks if a database exists in Mongodb ''' dbs = db_list(user, password, host, port) - for mdb in dbs: - if name == mdb: - return True - return False + if isinstance(dbs, string_types): + return False + + return name in dbs def db_remove(name, user=None, password=None, host=None, port=None):