summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorMichael Scherer <mscherer@users.noreply.github.com>2016-08-31 17:08:12 +0200
committerToshio Kuratomi <a.badger@gmail.com>2016-08-31 08:08:12 -0700
commit2e7cd6e02a12c43e3e6663f3db11f0356a2cfc09 (patch)
treec6e65ed9f73845e874caf34c87a5421b039aec91 /database
parentc091a3e9acdb1de8ba83fb5c770dc29823ec2b3a (diff)
downloadansible-modules-core-2e7cd6e02a12c43e3e6663f3db11f0356a2cfc09.tar.gz
Port postgresql module to python3 (#4579)
Iteritems is no longer a dict method in Python3, replace it with the six wrapper.
Diffstat (limited to 'database')
-rw-r--r--database/postgresql/postgresql_db.py3
-rw-r--r--database/postgresql/postgresql_user.py7
2 files changed, 6 insertions, 4 deletions
diff --git a/database/postgresql/postgresql_db.py b/database/postgresql/postgresql_db.py
index bfb2f7e0..33e812bc 100644
--- a/database/postgresql/postgresql_db.py
+++ b/database/postgresql/postgresql_db.py
@@ -114,6 +114,7 @@ except ImportError:
postgresqldb_found = False
else:
postgresqldb_found = True
+from ansible.module_utils.six import iteritems
class NotSupportedError(Exception):
pass
@@ -261,7 +262,7 @@ def main():
"login_password":"password",
"port":"port"
}
- kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems()
+ kw = dict( (params_map[k], v) for (k, v) in iteritems(module.params)
if k in params_map and v != '' )
# If a login_unix_socket is specified, incorporate it here.
diff --git a/database/postgresql/postgresql_user.py b/database/postgresql/postgresql_user.py
index caa1dc2d..7a3bb559 100644
--- a/database/postgresql/postgresql_user.py
+++ b/database/postgresql/postgresql_user.py
@@ -170,6 +170,7 @@ except ImportError:
postgresqldb_found = False
else:
postgresqldb_found = True
+from ansible.module_utils.six import iteritems
_flags = ('SUPERUSER', 'CREATEROLE', 'CREATEUSER', 'CREATEDB', 'INHERIT', 'LOGIN', 'REPLICATION')
VALID_FLAGS = frozenset(itertools.chain(_flags, ('NO%s' % f for f in _flags)))
@@ -433,7 +434,7 @@ def revoke_privileges(cursor, user, privs):
changed = False
for type_ in privs:
- for name, privileges in privs[type_].iteritems():
+ for name, privileges in iteritems(privs[type_]):
# Check that any of the privileges requested to be removed are
# currently granted to the user
differences = check_funcs[type_](cursor, user, name, privileges)
@@ -451,7 +452,7 @@ def grant_privileges(cursor, user, privs):
changed = False
for type_ in privs:
- for name, privileges in privs[type_].iteritems():
+ for name, privileges in iteritems(privs[type_]):
# Check that any of the privileges requested for the user are
# currently missing
differences = check_funcs[type_](cursor, user, name, privileges)
@@ -595,7 +596,7 @@ def main():
"port":"port",
"db":"database"
}
- kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems()
+ kw = dict( (params_map[k], v) for (k, v) in iteritems(module.params)
if k in params_map and v != "" )
# If a login_unix_socket is specified, incorporate it here.