mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2015.8' into '2016.3'
Conflicts: - salt/modules/postgres.py
This commit is contained in:
commit
5bd4d6430b
3 changed files with 49 additions and 24 deletions
|
@ -657,7 +657,7 @@ def tablespace_create(name, location, options=None, owner=None, user=None,
|
|||
owner_query = 'OWNER "{0}"'.format(owner)
|
||||
# should come out looking like: 'OWNER postgres'
|
||||
if options:
|
||||
optionstext = ['{0} = {1}'.format(k, v) for k, v in options.items()]
|
||||
optionstext = ['{0} = {1}'.format(k, v) for k, v in six.iteritems(options)]
|
||||
options_query = 'WITH ( {0} )'.format(', '.join(optionstext))
|
||||
# should come out looking like: 'WITH ( opt1 = 1.0, opt2 = 4.0 )'
|
||||
query = 'CREATE TABLESPACE "{0}" {1} LOCATION \'{2}\' {3}'.format(name,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Management of PostgreSQL extensions (e.g.: postgis)
|
||||
===================================================
|
||||
Management of PostgreSQL extensions
|
||||
===================================
|
||||
|
||||
The postgres_extensions module is used to create and manage Postgres extensions.
|
||||
A module used to install and manage PostgreSQL extensions.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
|
@ -44,14 +44,20 @@ def present(name,
|
|||
db_port=None):
|
||||
'''
|
||||
Ensure that the named extension is present.
|
||||
For more information about all of these options see `CREATE EXTENSION` SQL
|
||||
|
||||
.. note::
|
||||
|
||||
Before you can use the state to load an extension into a database, the
|
||||
extension's supporting files must be already installed.
|
||||
|
||||
For more information about all of these options see ``CREATE EXTENSION`` SQL
|
||||
command reference in the PostgreSQL documentation.
|
||||
|
||||
name
|
||||
The name of the extension to manage
|
||||
The name of the extension to be installed
|
||||
|
||||
if_not_exists
|
||||
Add an `IF NOT EXISTS` parameter to the DDL statement
|
||||
Add an ``IF NOT EXISTS`` parameter to the DDL statement
|
||||
|
||||
schema
|
||||
Schema to install the extension into
|
||||
|
@ -174,10 +180,10 @@ def absent(name,
|
|||
Database to act on
|
||||
|
||||
db_user
|
||||
database username if different from config or default
|
||||
Database username if different from config or default
|
||||
|
||||
db_password
|
||||
user password if any password for a specified user
|
||||
User password if any password for a specified user
|
||||
|
||||
db_host
|
||||
Database host if different from config or default
|
||||
|
|
|
@ -15,8 +15,16 @@ A module used to create and manage PostgreSQL tablespaces.
|
|||
.. versionadded:: 2015.8.0
|
||||
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import salt libs
|
||||
from salt.utils import dictupdate
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext.six import iteritems
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -37,7 +45,8 @@ def present(name,
|
|||
db_user=None):
|
||||
'''
|
||||
Ensure that the named tablespace is present with the specified properties.
|
||||
For more information about all of these options see man `create_tablespace`(7).
|
||||
For more information about all of these options see man
|
||||
``create_tablespace``(7).
|
||||
|
||||
name
|
||||
The name of the tablespace to create/manage.
|
||||
|
@ -46,13 +55,21 @@ def present(name,
|
|||
The directory where the tablespace will be located, must already exist
|
||||
|
||||
options
|
||||
A dictionary of options to specify for the table.
|
||||
Currently, the only tablespace options supported are
|
||||
seq_page_cost - float; default=1.0
|
||||
random_page_cost - float; default=4.0
|
||||
A dictionary of options to specify for the tablespace.
|
||||
Currently, the only tablespace options supported are ``seq_page_cost``
|
||||
and ``random_page_cost``. Default values are shown in the example below:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
my_space:
|
||||
postgres_tablespace.present:
|
||||
- directory: /srv/my_tablespace
|
||||
- options:
|
||||
seq_page_cost: 1.0
|
||||
random_page_cost: 4.0
|
||||
|
||||
owner
|
||||
The database user that will be the owner of the tablespace
|
||||
The database user that will be the owner of the tablespace.
|
||||
Defaults to the user executing the command (i.e. the `user` option)
|
||||
|
||||
user
|
||||
|
@ -62,10 +79,10 @@ def present(name,
|
|||
Database to act on
|
||||
|
||||
db_user
|
||||
database username if different from config or default
|
||||
Database username if different from config or default
|
||||
|
||||
db_password
|
||||
user password if any password for a specified user
|
||||
User password if any password for a specified user
|
||||
|
||||
db_host
|
||||
Database host if different from config or default
|
||||
|
@ -113,6 +130,7 @@ def present(name,
|
|||
if (__salt__['postgres.tablespace_alter'](name, new_owner=owner)
|
||||
and not __opts__['test']):
|
||||
ret['comment'] = 'Tablespace {0} owner changed'.format(name)
|
||||
ret['changes'][name] = {'owner': owner}
|
||||
ret['result'] = True
|
||||
|
||||
if options:
|
||||
|
@ -121,17 +139,18 @@ def present(name,
|
|||
# that we should be able to string check:
|
||||
# {seq_page_cost=1.1,random_page_cost=3.9}
|
||||
# TODO remove options that exist if possible
|
||||
for k, v in options:
|
||||
for k, v in iteritems(options):
|
||||
# if 'seq_page_cost=1.1' not in '{seq_page_cost=1.1,...}'
|
||||
if '{0}={1}'.format(k, v) not in tblspaces[name]['Opts']:
|
||||
# if 'seq_page_cost=1.1' not in '{seq_page_cost=1.1,...}'
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = """Tablespace {0} options to be
|
||||
altered""".format(name)
|
||||
break # we know it's going to be altered, no reason to cont
|
||||
if __salt__['postgres.tablespace_alter'](name,
|
||||
set_options={k: v}):
|
||||
set_option={k: v}):
|
||||
ret['comment'] = 'Tablespace {0} opts changed'.format(name)
|
||||
dictupdate.update(ret['changes'], {name: {'options': {k: v}}})
|
||||
ret['result'] = True
|
||||
|
||||
return ret
|
||||
|
@ -145,10 +164,10 @@ def absent(name,
|
|||
db_host=None,
|
||||
db_port=None):
|
||||
'''
|
||||
Ensure that the named database is absent.
|
||||
Ensure that the named tablespace is absent.
|
||||
|
||||
name
|
||||
The name of the database to remove
|
||||
The name of the tablespace to remove
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
@ -157,10 +176,10 @@ def absent(name,
|
|||
Database to act on
|
||||
|
||||
db_user
|
||||
database username if different from config or defaul
|
||||
Database username if different from config or defaul
|
||||
|
||||
db_password
|
||||
user password if any password for a specified user
|
||||
User password if any password for a specified user
|
||||
|
||||
db_host
|
||||
Database host if different from config or default
|
||||
|
|
Loading…
Add table
Reference in a new issue