postgresql modules: remove unused imports, remove blank lines after docstrings
This commit is contained in:
parent
7733dcabd3
commit
186210af8a
12 changed files with 19 additions and 83 deletions
|
@ -180,7 +180,6 @@ from ansible.module_utils.postgres import (
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
from ansible.module_utils.six import iteritems
|
from ansible.module_utils.six import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,7 +219,6 @@ class PgCopyData(object):
|
||||||
|
|
||||||
def copy_from(self):
|
def copy_from(self):
|
||||||
"""Implements COPY FROM command behavior."""
|
"""Implements COPY FROM command behavior."""
|
||||||
|
|
||||||
self.src = self.module.params['copy_from']
|
self.src = self.module.params['copy_from']
|
||||||
self.dst = self.module.params['dst']
|
self.dst = self.module.params['dst']
|
||||||
|
|
||||||
|
@ -251,7 +249,6 @@ class PgCopyData(object):
|
||||||
|
|
||||||
def copy_to(self):
|
def copy_to(self):
|
||||||
"""Implements COPY TO command behavior."""
|
"""Implements COPY TO command behavior."""
|
||||||
|
|
||||||
self.src = self.module.params['src']
|
self.src = self.module.params['src']
|
||||||
self.dst = self.module.params['copy_to']
|
self.dst = self.module.params['copy_to']
|
||||||
|
|
||||||
|
@ -287,7 +284,6 @@ class PgCopyData(object):
|
||||||
|
|
||||||
def __transform_options(self):
|
def __transform_options(self):
|
||||||
"""Transform options dict into a suitable string."""
|
"""Transform options dict into a suitable string."""
|
||||||
|
|
||||||
for (key, val) in iteritems(self.module.params['options']):
|
for (key, val) in iteritems(self.module.params['options']):
|
||||||
if key.upper() in self.opt_need_quotes:
|
if key.upper() in self.opt_need_quotes:
|
||||||
self.module.params['options'][key] = "'%s'" % val
|
self.module.params['options'][key] = "'%s'" % val
|
||||||
|
@ -305,7 +301,6 @@ class PgCopyData(object):
|
||||||
It can be SQL SELECT statement that was passed
|
It can be SQL SELECT statement that was passed
|
||||||
instead of the table name.
|
instead of the table name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 'SELECT ' in table.upper():
|
if 'SELECT ' in table.upper():
|
||||||
# In this case table is actually SQL SELECT statement.
|
# In this case table is actually SQL SELECT statement.
|
||||||
# If SQL fails, it's handled by exec_sql():
|
# If SQL fails, it's handled by exec_sql():
|
||||||
|
|
|
@ -227,13 +227,11 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError
|
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
VALID_IDX_TYPES = ('BTREE', 'HASH', 'GIST', 'SPGIST', 'GIN', 'BRIN')
|
VALID_IDX_TYPES = ('BTREE', 'HASH', 'GIST', 'SPGIST', 'GIN', 'BRIN')
|
||||||
|
@ -295,7 +293,6 @@ class Index(object):
|
||||||
|
|
||||||
Return self.info dict.
|
Return self.info dict.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.__exists_in_db()
|
self.__exists_in_db()
|
||||||
return self.info
|
return self.info
|
||||||
|
|
||||||
|
@ -304,7 +301,6 @@ class Index(object):
|
||||||
|
|
||||||
Return True if the index exists, otherwise, return False.
|
Return True if the index exists, otherwise, return False.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = ("SELECT i.schemaname, i.tablename, i.tablespace, "
|
query = ("SELECT i.schemaname, i.tablename, i.tablespace, "
|
||||||
"pi.indisvalid, c.reloptions "
|
"pi.indisvalid, c.reloptions "
|
||||||
"FROM pg_catalog.pg_indexes AS i "
|
"FROM pg_catalog.pg_indexes AS i "
|
||||||
|
@ -347,7 +343,6 @@ class Index(object):
|
||||||
Kwargs:
|
Kwargs:
|
||||||
concurrent (bool) -- build index in concurrent mode, default True
|
concurrent (bool) -- build index in concurrent mode, default True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.exists:
|
if self.exists:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -398,7 +393,6 @@ class Index(object):
|
||||||
default False
|
default False
|
||||||
concurrent (bool) -- build index in concurrent mode, default True
|
concurrent (bool) -- build index in concurrent mode, default True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if not self.exists:
|
if not self.exists:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -474,11 +474,9 @@ except ImportError:
|
||||||
# from ansible.module_utils.postgres
|
# from ansible.module_utils.postgres
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError
|
|
||||||
from ansible.module_utils.postgres import connect_to_db, postgres_common_argument_spec
|
from ansible.module_utils.postgres import connect_to_db, postgres_common_argument_spec
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
|
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
@ -544,9 +542,7 @@ class PgClusterInfo(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
def collect(self, val_list=False):
|
def collect(self, val_list=False):
|
||||||
"""
|
"""Collect information based on 'filter' option."""
|
||||||
Collect information based on 'filter' option.
|
|
||||||
"""
|
|
||||||
subset_map = {
|
subset_map = {
|
||||||
"version": self.get_pg_version,
|
"version": self.get_pg_version,
|
||||||
"tablespaces": self.get_tablespaces,
|
"tablespaces": self.get_tablespaces,
|
||||||
|
@ -598,9 +594,7 @@ class PgClusterInfo(object):
|
||||||
return self.pg_info
|
return self.pg_info
|
||||||
|
|
||||||
def get_tablespaces(self):
|
def get_tablespaces(self):
|
||||||
"""
|
"""Get information about tablespaces."""
|
||||||
Get information about tablespaces.
|
|
||||||
"""
|
|
||||||
# Check spcoption exists:
|
# Check spcoption exists:
|
||||||
opt = self.__exec_sql("SELECT column_name "
|
opt = self.__exec_sql("SELECT column_name "
|
||||||
"FROM information_schema.columns "
|
"FROM information_schema.columns "
|
||||||
|
@ -632,9 +626,7 @@ class PgClusterInfo(object):
|
||||||
self.pg_info["tablespaces"] = ts_dict
|
self.pg_info["tablespaces"] = ts_dict
|
||||||
|
|
||||||
def get_ext_info(self):
|
def get_ext_info(self):
|
||||||
"""
|
"""Get information about existing extensions."""
|
||||||
Get information about existing extensions.
|
|
||||||
"""
|
|
||||||
# Check that pg_extension exists:
|
# Check that pg_extension exists:
|
||||||
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
|
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
|
||||||
"information_schema.tables "
|
"information_schema.tables "
|
||||||
|
@ -666,9 +658,7 @@ class PgClusterInfo(object):
|
||||||
return ext_dict
|
return ext_dict
|
||||||
|
|
||||||
def get_role_info(self):
|
def get_role_info(self):
|
||||||
"""
|
"""Get information about roles (in PgSQL groups and users are roles)."""
|
||||||
Get information about roles (in PgSQL groups and users are roles).
|
|
||||||
"""
|
|
||||||
query = ("SELECT r.rolname, r.rolsuper, r.rolcanlogin, "
|
query = ("SELECT r.rolname, r.rolsuper, r.rolcanlogin, "
|
||||||
"r.rolvaliduntil, "
|
"r.rolvaliduntil, "
|
||||||
"ARRAY(SELECT b.rolname "
|
"ARRAY(SELECT b.rolname "
|
||||||
|
@ -691,9 +681,7 @@ class PgClusterInfo(object):
|
||||||
self.pg_info["roles"] = rol_dict
|
self.pg_info["roles"] = rol_dict
|
||||||
|
|
||||||
def get_rslot_info(self):
|
def get_rslot_info(self):
|
||||||
"""
|
"""Get information about replication slots if exist."""
|
||||||
Get information about replication slots if exist.
|
|
||||||
"""
|
|
||||||
# Check that pg_replication_slots exists:
|
# Check that pg_replication_slots exists:
|
||||||
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
|
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
|
||||||
"information_schema.tables "
|
"information_schema.tables "
|
||||||
|
@ -721,9 +709,7 @@ class PgClusterInfo(object):
|
||||||
self.pg_info["repl_slots"] = rslot_dict
|
self.pg_info["repl_slots"] = rslot_dict
|
||||||
|
|
||||||
def get_settings(self):
|
def get_settings(self):
|
||||||
"""
|
"""Get server settings."""
|
||||||
Get server settings.
|
|
||||||
"""
|
|
||||||
# Check pending restart column exists:
|
# Check pending restart column exists:
|
||||||
pend_rest_col_exists = self.__exec_sql("SELECT 1 FROM information_schema.columns "
|
pend_rest_col_exists = self.__exec_sql("SELECT 1 FROM information_schema.columns "
|
||||||
"WHERE table_name = 'pg_settings' "
|
"WHERE table_name = 'pg_settings' "
|
||||||
|
@ -789,9 +775,7 @@ class PgClusterInfo(object):
|
||||||
self.pg_info["settings"] = set_dict
|
self.pg_info["settings"] = set_dict
|
||||||
|
|
||||||
def get_repl_info(self):
|
def get_repl_info(self):
|
||||||
"""
|
"""Get information about replication if the server is a master."""
|
||||||
Get information about replication if the server is a master.
|
|
||||||
"""
|
|
||||||
# Check that pg_replication_slots exists:
|
# Check that pg_replication_slots exists:
|
||||||
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
|
res = self.__exec_sql("SELECT EXISTS (SELECT 1 FROM "
|
||||||
"information_schema.tables "
|
"information_schema.tables "
|
||||||
|
@ -823,9 +807,7 @@ class PgClusterInfo(object):
|
||||||
self.pg_info["replications"] = repl_dict
|
self.pg_info["replications"] = repl_dict
|
||||||
|
|
||||||
def get_lang_info(self):
|
def get_lang_info(self):
|
||||||
"""
|
"""Get information about current supported languages."""
|
||||||
Get information about current supported languages.
|
|
||||||
"""
|
|
||||||
query = ("SELECT l.lanname, a.rolname, l.lanacl "
|
query = ("SELECT l.lanname, a.rolname, l.lanacl "
|
||||||
"FROM pg_language AS l "
|
"FROM pg_language AS l "
|
||||||
"JOIN pg_authid AS a ON l.lanowner = a.oid")
|
"JOIN pg_authid AS a ON l.lanowner = a.oid")
|
||||||
|
@ -840,9 +822,7 @@ class PgClusterInfo(object):
|
||||||
return lang_dict
|
return lang_dict
|
||||||
|
|
||||||
def get_namespaces(self):
|
def get_namespaces(self):
|
||||||
"""
|
"""Get information about namespaces."""
|
||||||
Get information about namespaces.
|
|
||||||
"""
|
|
||||||
query = ("SELECT n.nspname, a.rolname, n.nspacl "
|
query = ("SELECT n.nspname, a.rolname, n.nspacl "
|
||||||
"FROM pg_catalog.pg_namespace AS n "
|
"FROM pg_catalog.pg_namespace AS n "
|
||||||
"JOIN pg_authid AS a ON a.oid = n.nspowner")
|
"JOIN pg_authid AS a ON a.oid = n.nspowner")
|
||||||
|
@ -858,9 +838,7 @@ class PgClusterInfo(object):
|
||||||
return nsp_dict
|
return nsp_dict
|
||||||
|
|
||||||
def get_pg_version(self):
|
def get_pg_version(self):
|
||||||
"""
|
"""Get major and minor PostgreSQL server version."""
|
||||||
Get major and minor PostgreSQL server version.
|
|
||||||
"""
|
|
||||||
query = "SELECT version()"
|
query = "SELECT version()"
|
||||||
raw = self.__exec_sql(query)[0][0]
|
raw = self.__exec_sql(query)[0][0]
|
||||||
raw = raw.split()[1].split('.')
|
raw = raw.split()[1].split('.')
|
||||||
|
@ -870,10 +848,7 @@ class PgClusterInfo(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_db_info(self):
|
def get_db_info(self):
|
||||||
"""
|
"""Get information about the current database."""
|
||||||
Get information about the current database.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Following query returns:
|
# Following query returns:
|
||||||
# Name, Owner, Encoding, Collate, Ctype, Access Priv, Size
|
# Name, Owner, Encoding, Collate, Ctype, Access Priv, Size
|
||||||
query = ("SELECT d.datname, "
|
query = ("SELECT d.datname, "
|
||||||
|
@ -912,15 +887,11 @@ class PgClusterInfo(object):
|
||||||
self.pg_info["databases"] = db_dict
|
self.pg_info["databases"] = db_dict
|
||||||
|
|
||||||
def __get_pretty_val(self, setting):
|
def __get_pretty_val(self, setting):
|
||||||
"""
|
"""Get setting's value represented by SHOW command."""
|
||||||
Get setting's value represented by SHOW command.
|
|
||||||
"""
|
|
||||||
return self.__exec_sql("SHOW %s" % setting)[0][0]
|
return self.__exec_sql("SHOW %s" % setting)[0][0]
|
||||||
|
|
||||||
def __exec_sql(self, query):
|
def __exec_sql(self, query):
|
||||||
"""
|
"""Execute SQL and return the result."""
|
||||||
Execute SQL and return the result.
|
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
self.cursor.execute(query)
|
self.cursor.execute(query)
|
||||||
res = self.cursor.fetchall()
|
res = self.cursor.fetchall()
|
||||||
|
|
|
@ -143,13 +143,12 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError, pg_quote_identifier
|
from ansible.module_utils.database import pg_quote_identifier
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
class PgMembership(object):
|
class PgMembership(object):
|
||||||
|
|
|
@ -157,13 +157,12 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError, pg_quote_identifier
|
from ansible.module_utils.database import pg_quote_identifier
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
class PgOwnership(object):
|
class PgOwnership(object):
|
||||||
|
@ -225,7 +224,6 @@ class PgOwnership(object):
|
||||||
fail_on_role (bool): If True, fail when a role from old_owners does not exist.
|
fail_on_role (bool): If True, fail when a role from old_owners does not exist.
|
||||||
Otherwise just warn and continue.
|
Otherwise just warn and continue.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
roles = []
|
roles = []
|
||||||
for r in old_owners:
|
for r in old_owners:
|
||||||
if self.check_role_exists(r, fail_on_role):
|
if self.check_role_exists(r, fail_on_role):
|
||||||
|
@ -251,7 +249,6 @@ class PgOwnership(object):
|
||||||
obj_type (str): Type of object (like database, table, view, etc.).
|
obj_type (str): Type of object (like database, table, view, etc.).
|
||||||
obj_name (str): Object name.
|
obj_name (str): Object name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.obj_name = obj_name
|
self.obj_name = obj_name
|
||||||
self.obj_type = obj_type
|
self.obj_type = obj_type
|
||||||
|
|
||||||
|
@ -286,7 +283,6 @@ class PgOwnership(object):
|
||||||
|
|
||||||
def __is_owner(self):
|
def __is_owner(self):
|
||||||
"""Return True if self.role is the current object owner."""
|
"""Return True if self.role is the current object owner."""
|
||||||
|
|
||||||
if self.obj_type == 'table':
|
if self.obj_type == 'table':
|
||||||
query = ("SELECT 1 FROM pg_tables WHERE tablename = '%s' "
|
query = ("SELECT 1 FROM pg_tables WHERE tablename = '%s' "
|
||||||
"AND tableowner = '%s'" % (self.obj_name, self.role))
|
"AND tableowner = '%s'" % (self.obj_name, self.role))
|
||||||
|
|
|
@ -78,15 +78,12 @@ except ImportError:
|
||||||
# from ansible.module_utils.postgres
|
# from ansible.module_utils.postgres
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError
|
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
|
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
|
@ -145,9 +145,7 @@ except ImportError:
|
||||||
# ansible.module_utils.postgres
|
# ansible.module_utils.postgres
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import ansible.module_utils.postgres as pgutils
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError
|
|
||||||
from ansible.module_utils.postgres import connect_to_db, postgres_common_argument_spec
|
from ansible.module_utils.postgres import connect_to_db, postgres_common_argument_spec
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,6 @@ from ansible.module_utils.postgres import (
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
class Sequence(object):
|
class Sequence(object):
|
||||||
|
|
|
@ -165,7 +165,6 @@ except Exception:
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError
|
|
||||||
from ansible.module_utils.postgres import connect_to_db, postgres_common_argument_spec
|
from ansible.module_utils.postgres import connect_to_db, postgres_common_argument_spec
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
|
@ -149,13 +149,11 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError
|
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
|
@ -236,13 +236,12 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError, pg_quote_identifier
|
from ansible.module_utils.database import pg_quote_identifier
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
|
@ -172,13 +172,12 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.database import SQLParseError, pg_quote_identifier
|
from ansible.module_utils.database import pg_quote_identifier
|
||||||
from ansible.module_utils.postgres import (
|
from ansible.module_utils.postgres import (
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
exec_sql,
|
exec_sql,
|
||||||
postgres_common_argument_spec,
|
postgres_common_argument_spec,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
class PgTablespace(object):
|
class PgTablespace(object):
|
||||||
|
@ -218,7 +217,6 @@ class PgTablespace(object):
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
"""Get tablespace information."""
|
"""Get tablespace information."""
|
||||||
|
|
||||||
# Check that spcoptions exists:
|
# Check that spcoptions exists:
|
||||||
opt = exec_sql(self, "SELECT 1 FROM information_schema.columns "
|
opt = exec_sql(self, "SELECT 1 FROM information_schema.columns "
|
||||||
"WHERE table_name = 'pg_tablespace' "
|
"WHERE table_name = 'pg_tablespace' "
|
||||||
|
@ -275,7 +273,6 @@ class PgTablespace(object):
|
||||||
args:
|
args:
|
||||||
location (str) -- tablespace directory path in the FS
|
location (str) -- tablespace directory path in the FS
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = ("CREATE TABLESPACE %s LOCATION '%s'" % (pg_quote_identifier(self.name, 'database'), location))
|
query = ("CREATE TABLESPACE %s LOCATION '%s'" % (pg_quote_identifier(self.name, 'database'), location))
|
||||||
return exec_sql(self, query, ddl=True)
|
return exec_sql(self, query, ddl=True)
|
||||||
|
|
||||||
|
@ -284,7 +281,6 @@ class PgTablespace(object):
|
||||||
|
|
||||||
Return True if success, otherwise, return False.
|
Return True if success, otherwise, return False.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return exec_sql(self, "DROP TABLESPACE %s" % pg_quote_identifier(self.name, 'database'), ddl=True)
|
return exec_sql(self, "DROP TABLESPACE %s" % pg_quote_identifier(self.name, 'database'), ddl=True)
|
||||||
|
|
||||||
def set_owner(self, new_owner):
|
def set_owner(self, new_owner):
|
||||||
|
@ -295,7 +291,6 @@ class PgTablespace(object):
|
||||||
args:
|
args:
|
||||||
new_owner (str) -- name of a new owner for the tablespace"
|
new_owner (str) -- name of a new owner for the tablespace"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if new_owner == self.owner:
|
if new_owner == self.owner:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -310,7 +305,6 @@ class PgTablespace(object):
|
||||||
args:
|
args:
|
||||||
newname (str) -- new name for the tablespace"
|
newname (str) -- new name for the tablespace"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = "ALTER TABLESPACE %s RENAME TO %s" % (pg_quote_identifier(self.name, 'database'), newname)
|
query = "ALTER TABLESPACE %s RENAME TO %s" % (pg_quote_identifier(self.name, 'database'), newname)
|
||||||
self.new_name = newname
|
self.new_name = newname
|
||||||
return exec_sql(self, query, ddl=True)
|
return exec_sql(self, query, ddl=True)
|
||||||
|
@ -324,7 +318,6 @@ class PgTablespace(object):
|
||||||
args:
|
args:
|
||||||
new_settings (list) -- list of new settings
|
new_settings (list) -- list of new settings
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# settings must be a dict {'key': 'value'}
|
# settings must be a dict {'key': 'value'}
|
||||||
if self.opt_not_supported:
|
if self.opt_not_supported:
|
||||||
return False
|
return False
|
||||||
|
@ -351,7 +344,6 @@ class PgTablespace(object):
|
||||||
args:
|
args:
|
||||||
setting (str) -- string in format "setting_name = 'setting_value'"
|
setting (str) -- string in format "setting_name = 'setting_value'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = "ALTER TABLESPACE %s RESET (%s)" % (pg_quote_identifier(self.name, 'database'), setting)
|
query = "ALTER TABLESPACE %s RESET (%s)" % (pg_quote_identifier(self.name, 'database'), setting)
|
||||||
return exec_sql(self, query, ddl=True)
|
return exec_sql(self, query, ddl=True)
|
||||||
|
|
||||||
|
@ -363,7 +355,6 @@ class PgTablespace(object):
|
||||||
args:
|
args:
|
||||||
setting (str) -- string in format "setting_name = 'setting_value'"
|
setting (str) -- string in format "setting_name = 'setting_value'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = "ALTER TABLESPACE %s SET (%s)" % (pg_quote_identifier(self.name, 'database'), setting)
|
query = "ALTER TABLESPACE %s SET (%s)" % (pg_quote_identifier(self.name, 'database'), setting)
|
||||||
return exec_sql(self, query, ddl=True)
|
return exec_sql(self, query, ddl=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue