Merge pull request #4693 from hulu/mongodb-fixes

fixes to modules.mongodb.db_exists
This commit is contained in:
Thomas S Hatch 2013-05-01 09:18:11 -07:00
commit e556cc31ea

View File

@ -16,6 +16,9 @@ Module to provide MongoDB functionality to Salt
# Import python libs # Import python libs
import logging import logging
# Import salt libs
from salt._compat import string_types
# Import third party libs # Import third party libs
try: try:
import pymongo import pymongo
@ -76,17 +79,16 @@ def db_list(user=None, password=None, host=None, port=None):
return err.message return err.message
def db_exists(name, user=None, password=None, host=None, port=None, def db_exists(name, user=None, password=None, host=None, port=None):
database='admin'):
''' '''
Checks if a database exists in Mongodb Checks if a database exists in Mongodb
''' '''
dbs = db_list(user, password, host, port) 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): def db_remove(name, user=None, password=None, host=None, port=None):