mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Merge pull request #4693 from hulu/mongodb-fixes
fixes to modules.mongodb.db_exists
This commit is contained in:
commit
e556cc31ea
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user