INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Manages the configuration of the users on the device as specified in the state SLS file. Users not defined in that file will be remove whilst users not configured on the device will be added. | def managed(name, users=None, defaults=None):
'''
Manages the configuration of the users on the device, as specified in the state SLS file. Users not defined in that
file will be remove whilst users not configured on the device, will be added.
SLS Example:
.. code-block:: yaml
netusers_e... |
Checks if the client has sent a ready message. A ready message causes send () to be called on the parent end of the pipe. | def received_message(self, message):
'''
Checks if the client has sent a ready message.
A ready message causes ``send()`` to be called on the
``parent end`` of the pipe.
Clients need to ensure that the pipe assigned to ``self.pipe`` is
the ``parent end`` of a pipe.
... |
Prints an info on CLI with the title. Useful for infos general errors etc. | def cli_info(data, title='Info'):
'''
Prints an info on CLI with the title.
Useful for infos, general errors etc.
:param data:
:param title:
:return:
'''
wrapper = textwrap.TextWrapper()
wrapper.initial_indent = ' ' * 4
wrapper.subsequent_indent = wrapper.initial_indent
re... |
List users belonging to this account | def get_users(profile='pagerduty', subdomain=None, api_key=None):
'''
List users belonging to this account
CLI Example:
salt myminion pagerduty.get_users
'''
return _list_items(
'users',
'id',
profile=profile,
subdomain=subdomain,
api_key=api_key,
... |
List services belonging to this account | def get_services(profile='pagerduty', subdomain=None, api_key=None):
'''
List services belonging to this account
CLI Example:
salt myminion pagerduty.get_services
'''
return _list_items(
'services',
'id',
profile=profile,
subdomain=subdomain,
api_ke... |
List schedules belonging to this account | def get_schedules(profile='pagerduty', subdomain=None, api_key=None):
'''
List schedules belonging to this account
CLI Example:
salt myminion pagerduty.get_schedules
'''
return _list_items(
'schedules',
'id',
profile=profile,
subdomain=subdomain,
ap... |
List escalation_policies belonging to this account | def get_escalation_policies(profile='pagerduty', subdomain=None, api_key=None):
'''
List escalation_policies belonging to this account
CLI Example:
salt myminion pagerduty.get_escalation_policies
'''
return _list_items(
'escalation_policies',
'id',
profile=profile,... |
List items belonging to an API call. | def _list_items(action, key, profile=None, subdomain=None, api_key=None):
'''
List items belonging to an API call.
This method should be in utils.pagerduty.
'''
items = _query(
profile=profile,
subdomain=subdomain,
api_key=api_key,
action=action
)
ret = {}
... |
Query the PagerDuty API. | def _query(method='GET', profile=None, url=None, path='api/v1',
action=None, api_key=None, service=None, params=None,
data=None, subdomain=None, verify_ssl=True):
'''
Query the PagerDuty API.
This method should be in utils.pagerduty.
'''
if profile:
creds = __salt__[... |
Get any single pagerduty resource by key. | def get_resource(resource_name, key, identifier_fields, profile='pagerduty', subdomain=None, api_key=None):
'''
Get any single pagerduty resource by key.
We allow flexible lookup by any of a list of identifier_fields.
So, for example, you can look up users by email address or name by calling:
... |
create or update any pagerduty resource Helper method for present (). | def create_or_update_resource(resource_name, identifier_fields, data, diff=None, profile='pagerduty', subdomain=None, api_key=None):
'''
create or update any pagerduty resource
Helper method for present().
Determining if two resources are the same is different for different PD resource, so this method ... |
delete any pagerduty resource | def delete_resource(resource_name, key, identifier_fields, profile='pagerduty', subdomain=None, api_key=None):
'''
delete any pagerduty resource
Helper method for absent()
example:
delete_resource("users", key, ["id","name","email"]) # delete by id or name or email
'''
resource = ... |
Generic resource. present state method. Pagerduty state modules should be a thin wrapper over this method with a custom diff function. | def resource_present(resource, identifier_fields, diff=None, profile='pagerduty', subdomain=None, api_key=None, **kwargs):
'''
Generic resource.present state method. Pagerduty state modules should be a thin wrapper over this method,
with a custom diff function.
This method calls create_or_update_reso... |
Generic resource. absent state method. Pagerduty state modules should be a thin wrapper over this method with a custom diff function. | def resource_absent(resource, identifier_fields, profile='pagerduty', subdomain=None, api_key=None, **kwargs):
'''
Generic resource.absent state method. Pagerduty state modules should be a thin wrapper over this method,
with a custom diff function.
This method calls delete_resource() and formats the ... |
Ensures that the artifact from nexus exists at given location. If it doesn t exist then it will be downloaded. If it already exists then the checksum of existing file is checked against checksum in nexus. If it is different then the step will fail. | def downloaded(name, artifact, target_dir='/tmp', target_file=None):
'''
Ensures that the artifact from nexus exists at given location. If it doesn't exist, then
it will be downloaded. If it already exists then the checksum of existing file is checked
against checksum in nexus. If it is different then t... |
Return the currently configured jobs. | def _jobs():
'''
Return the currently configured jobs.
'''
response = salt.utils.http.query(
"{0}/scheduler/jobs".format(_base_url()),
decode_type='json',
decode=True,
)
jobs = {}
for job in response['dict']:
jobs[job.pop('name')] = job
return jobs |
Update the specified job with the given configuration. | def update_job(name, config):
'''
Update the specified job with the given configuration.
CLI Example:
.. code-block:: bash
salt chronos-minion-id chronos.update_job my-job '<config yaml>'
'''
if 'name' not in config:
config['name'] = name
data = salt.utils.json.dumps(confi... |
Remove the specified job from the server. | def rm_job(name):
'''
Remove the specified job from the server.
CLI Example:
.. code-block:: bash
salt chronos-minion-id chronos.rm_job my-job
'''
response = salt.utils.http.query(
"{0}/scheduler/job/{1}".format(_base_url(), name),
method='DELETE',
)
return Tru... |
Return iSCSI IQN | def iscsi_iqn():
'''
Return iSCSI IQN
'''
grains = {}
grains['iscsi_iqn'] = False
if salt.utils.platform.is_linux():
grains['iscsi_iqn'] = _linux_iqn()
elif salt.utils.platform.is_windows():
grains['iscsi_iqn'] = _windows_iqn()
elif salt.utils.platform.is_aix():
g... |
Return iSCSI IQN from a Linux host. | def _linux_iqn():
'''
Return iSCSI IQN from a Linux host.
'''
ret = []
initiator = '/etc/iscsi/initiatorname.iscsi'
try:
with salt.utils.files.fopen(initiator, 'r') as _iscsi:
for line in _iscsi:
line = line.strip()
if line.startswith('Initiat... |
Return iSCSI IQN from an AIX host. | def _aix_iqn():
'''
Return iSCSI IQN from an AIX host.
'''
ret = []
aix_cmd = 'lsattr -E -l iscsi0 | grep initiator_name'
aix_ret = salt.modules.cmdmod.run(aix_cmd)
if aix_ret[0].isalpha():
try:
ret.append(aix_ret.split()[1].rstrip())
except IndexError:
... |
Return iSCSI IQN from a Windows host. | def _windows_iqn():
'''
Return iSCSI IQN from a Windows host.
'''
ret = []
wmic = salt.utils.path.which('wmic')
if not wmic:
return ret
namespace = r'\\root\WMI'
path = 'MSiSCSIInitiator_MethodClass'
get = 'iSCSINodeName'
cmd_ret = salt.modules.cmdmod.run_all(
... |
Return the information for a specified job id | def get_jid(returner, jid):
'''
Return the information for a specified job id
CLI Example:
.. code-block:: bash
salt '*' ret.get_jid redis 20421104181954700505
'''
returners = salt.loader.returners(__opts__, __salt__)
return returners['{0}.get_jid'.format(returner)](jid) |
Return info about last time fun was called on each minion | def get_fun(returner, fun):
'''
Return info about last time fun was called on each minion
CLI Example:
.. code-block:: bash
salt '*' ret.get_fun mysql network.interfaces
'''
returners = salt.loader.returners(__opts__, __salt__)
return returners['{0}.get_fun'.format(returner)](fun) |
Return a list of all job ids | def get_jids(returner):
'''
Return a list of all job ids
CLI Example:
.. code-block:: bash
salt '*' ret.get_jids mysql
'''
returners = salt.loader.returners(__opts__, __salt__)
return returners['{0}.get_jids'.format(returner)]() |
Return a list of all minions | def get_minions(returner):
'''
Return a list of all minions
CLI Example:
.. code-block:: bash
salt '*' ret.get_minions mysql
'''
returners = salt.loader.returners(__opts__, __salt__)
return returners['{0}.get_minions'.format(returner)]() |
Enforces the TXT record maximum length of 255 characters. TXT record length includes key value and =. | def _enforce_txt_record_maxlen(key, value):
'''
Enforces the TXT record maximum length of 255 characters.
TXT record length includes key, value, and '='.
:param str key: Key of the TXT record
:param str value: Value of the TXT record
:rtype: str
:return: The value of the TXT record. It may... |
Broadcast values via zeroconf | def beacon(config):
'''
Broadcast values via zeroconf
If the announced values are static, it is advised to set run_once: True
(do not poll) on the beacon configuration.
The following are required configuration settings:
- ``servicetype`` - The service type to announce
- ``port`` - The por... |
Return the docstrings for all modules. Optionally specify a module or a function to narrow the selection. | def doc(*args):
'''
Return the docstrings for all modules. Optionally, specify a module or a
function to narrow the selection.
The strings are aggregated into a single document on the master for easy
reading.
Multiple modules/functions can be specified.
CLI Example:
.. code-block:: b... |
Return the docstrings for all states. Optionally specify a state or a function to narrow the selection. | def state_doc(*args):
'''
Return the docstrings for all states. Optionally, specify a state or a
function to narrow the selection.
The strings are aggregated into a single document on the master for easy
reading.
Multiple states/functions can be specified.
.. versionadded:: 2014.7.0
... |
Return the docstrings for all runners. Optionally specify a runner or a function to narrow the selection. | def runner_doc(*args):
'''
Return the docstrings for all runners. Optionally, specify a runner or a
function to narrow the selection.
The strings are aggregated into a single document on the master for easy
reading.
Multiple runners/functions can be specified.
.. versionadded:: 2014.7.0
... |
Return the docstrings for all returners. Optionally specify a returner or a function to narrow the selection. | def returner_doc(*args):
'''
Return the docstrings for all returners. Optionally, specify a returner or a
function to narrow the selection.
The strings are aggregated into a single document on the master for easy
reading.
Multiple returners/functions can be specified.
.. versionadded:: 20... |
Return the docstrings for all renderers. Optionally specify a renderer or a function to narrow the selection. | def renderer_doc(*args):
'''
Return the docstrings for all renderers. Optionally, specify a renderer or a
function to narrow the selection.
The strings are aggregated into a single document on the master for easy
reading.
Multiple renderers can be specified.
.. versionadded:: 2015.5.0
... |
.. versionadded:: Neon | def utils_doc(*args):
'''
.. versionadded:: Neon
Return the docstrings for all utils modules. Optionally, specify a module
or a function to narrow the selection.
The strings are aggregated into a single document on the master for easy
reading.
Multiple modules/functions can be specified.
... |
List the functions for all modules. Optionally specify a module or modules from which to list. | def list_functions(*args, **kwargs): # pylint: disable=unused-argument
'''
List the functions for all modules. Optionally, specify a module or modules
from which to list.
CLI Example:
.. code-block:: bash
salt '*' sys.list_functions
salt '*' sys.list_functions sys
salt '*... |
List the modules loaded on the minion | def list_modules(*args):
'''
List the modules loaded on the minion
.. versionadded:: 2015.5.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_modules
Module names can be specified as globs.
.. code-block:: bash
salt '*' sys.list_modules 's*'
'''
modules = ... |
Return the argument specification of functions in Salt state modules. | def state_argspec(module=''):
'''
Return the argument specification of functions in Salt state
modules.
.. versionadded:: 2015.5.0
CLI Example:
.. code-block:: bash
salt '*' sys.state_argspec pkg.installed
salt '*' sys.state_argspec file
salt '*' sys.state_argspec
... |
Return the argument specification of functions in Salt returner modules. | def returner_argspec(module=''):
'''
Return the argument specification of functions in Salt returner
modules.
.. versionadded:: 2015.5.0
CLI Example:
.. code-block:: bash
salt '*' sys.returner_argspec xmpp
salt '*' sys.returner_argspec xmpp smtp
salt '*' sys.returner_... |
Return the argument specification of functions in Salt runner modules. | def runner_argspec(module=''):
'''
Return the argument specification of functions in Salt runner
modules.
.. versionadded:: 2015.5.0
CLI Example:
.. code-block:: bash
salt '*' sys.runner_argspec state
salt '*' sys.runner_argspec http
salt '*' sys.runner_argspec
R... |
List the functions for all state modules. Optionally specify a state module or modules from which to list. | def list_state_functions(*args, **kwargs): # pylint: disable=unused-argument
'''
List the functions for all state modules. Optionally, specify a state
module or modules from which to list.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_state_functions... |
List the modules loaded on the minion | def list_state_modules(*args):
'''
List the modules loaded on the minion
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_state_modules
State module names can be specified as globs.
.. versionadded:: 2015.5.0
.. code-block:: bash
salt... |
List the runners loaded on the minion | def list_runners(*args):
'''
List the runners loaded on the minion
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_runners
Runner names can be specified as globs.
.. versionadded:: 2015.5.0
.. code-block:: bash
salt '*' sys.list_runn... |
List the functions for all runner modules. Optionally specify a runner module or modules from which to list. | def list_runner_functions(*args, **kwargs): # pylint: disable=unused-argument
'''
List the functions for all runner modules. Optionally, specify a runner
module or modules from which to list.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_runner_funct... |
List the returners loaded on the minion | def list_returners(*args):
'''
List the returners loaded on the minion
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_returners
Returner names can be specified as globs.
.. versionadded:: 2015.5.0
.. code-block:: bash
salt '*' sys.l... |
List the functions for all returner modules. Optionally specify a returner module or modules from which to list. | def list_returner_functions(*args, **kwargs): # pylint: disable=unused-argument
'''
List the functions for all returner modules. Optionally, specify a returner
module or modules from which to list.
.. versionadded:: 2014.7.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_return... |
List the renderers loaded on the minion | def list_renderers(*args):
'''
List the renderers loaded on the minion
.. versionadded:: 2015.5.0
CLI Example:
.. code-block:: bash
salt '*' sys.list_renderers
Render names can be specified as globs.
.. code-block:: bash
salt '*' sys.list_renderers 'yaml*'
'''
... |
Return a JSON Schema for the given state function ( s ) | def state_schema(module=''):
'''
Return a JSON Schema for the given state function(s)
.. versionadded:: 2016.3.0
CLI Example:
.. code-block:: bash
salt '*' sys.state_schema
salt '*' sys.state_schema pkg.installed
'''
specs = state_argspec(module)
schemas = []
for... |
... versionadded:: 2016. 3. 2 | def _find_pg_binary(util):
'''
... versionadded:: 2016.3.2
Helper function to locate various psql related binaries
'''
pg_bin_dir = __salt__['config.option']('postgres.bins_dir')
util_bin = salt.utils.path.which(util)
if not util_bin:
if pg_bin_dir:
return salt.utils.pa... |
Helper function to call psql because the password requirement makes this too much code to be repeated in each function below | def _run_psql(cmd, runas=None, password=None, host=None, port=None, user=None):
'''
Helper function to call psql, because the password requirement
makes this too much code to be repeated in each function below
'''
kwargs = {
'reset_system_locale': False,
'clean_env': True,
}
... |
Helper function to call initdb | def _run_initdb(name,
auth='password',
user=None,
password=None,
encoding='UTF8',
locale=None,
runas=None,
waldir=None,
checksums=False):
'''
Helper function to call initdb
'''
if runas is None:
if 'FreeBSD' in __grains__['os_family... |
Return the version of a Postgres server. | def version(user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Return the version of a Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.version
'''
query = 'SELECT setting FROM pg_catalog.pg_settings ' \
'W... |
Returns the server version properly parsed and int casted for internal use. | def _parsed_version(user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Returns the server version properly parsed and int casted for internal use.
If the Postgres server does not respond, None will be returned.
'''
psql_version = version(
... |
Returns a tuple of ( user host port db ) with config pillar or default values assigned to missing values. | def _connection_defaults(user=None, host=None, port=None, maintenance_db=None):
'''
Returns a tuple of (user, host, port, db) with config, pillar, or default
values assigned to missing values.
'''
if not user:
user = __salt__['config.option']('postgres.user')
if not host:
host = ... |
Return string with fully composed psql command. | def _psql_cmd(*args, **kwargs):
'''
Return string with fully composed psql command.
Accepts optional keyword arguments: user, host, port and maintenance_db,
as well as any number of positional arguments to be added to the end of
the command.
'''
(user, host, port, maintenance_db) = _connect... |
Run an SQL - Query and return the results as a list. This command only supports SELECT statements. This limitation can be worked around with a query like this: | def psql_query(query, user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None, write=False):
'''
Run an SQL-Query and return the results as a list. This command
only supports SELECT statements. This limitation can be worked around
with a query like this:
WITH... |
Return dictionary with information about databases of a Postgres server. | def db_list(user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Return dictionary with information about databases of a Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.db_list
'''
ret = {}
query = (
'SELE... |
Checks if a database exists on the Postgres server. | def db_exists(name, user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Checks if a database exists on the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.db_exists 'dbname'
'''
databases = db_list(user=user, host=h... |
Adds a databases to the Postgres server. | def db_create(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
tablespace=None,
encoding=None,
lc_collate=None,
lc_ctype=None,
owner=None,
t... |
Change tablespace or/ and owner of database. | def db_alter(name, user=None, host=None, port=None, maintenance_db=None,
password=None, tablespace=None, owner=None, owner_recurse=False,
runas=None):
'''
Change tablespace or/and owner of database.
CLI Example:
.. code-block:: bash
salt '*' postgres.db_alter dbname ... |
Return dictionary with information about tablespaces of a Postgres server. | def tablespace_list(user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Return dictionary with information about tablespaces of a Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.tablespace_list
.. versionadded:: 2... |
Checks if a tablespace exists on the Postgres server. | def tablespace_exists(name, user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Checks if a tablespace exists on the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.tablespace_exists 'dbname'
.. versionadded:: 2015.8.0
... |
Adds a tablespace to the Postgres server. | def tablespace_create(name, location, options=None, owner=None, user=None,
host=None, port=None, maintenance_db=None, password=None,
runas=None):
'''
Adds a tablespace to the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.table... |
Change tablespace name owner or options. | def tablespace_alter(name, user=None, host=None, port=None, maintenance_db=None,
password=None, new_name=None, new_owner=None,
set_option=None, reset_option=None, runas=None):
'''
Change tablespace name, owner, or options.
CLI Example:
.. code-block:: bash
... |
Removes a tablespace from the Postgres server. | def tablespace_remove(name, user=None, host=None, port=None,
maintenance_db=None, password=None, runas=None):
'''
Removes a tablespace from the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.tablespace_remove tsname
.. versionadded:: 2015.8.0
... |
Return a dict with information about users of a Postgres server. | def user_list(user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None, return_password=False):
'''
Return a dict with information about users of a Postgres server.
Set return_password to True to get password hash in the result.
CLI Example:
.. code-block:: ba... |
Return a dict with information about users of a Postgres server. | def role_get(name, user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None, return_password=False):
'''
Return a dict with information about users of a Postgres server.
Set return_password to True to get password hash in the result.
CLI Example:
.. code-block:... |
Checks if a user exists on the Postgres server. | def user_exists(name,
user=None, host=None, port=None, maintenance_db=None,
password=None,
runas=None):
'''
Checks if a user exists on the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.user_exists 'username'
'''
re... |
pgsql passwords are md5 hashes of the string: md5 { password } { rolename } | def _maybe_encrypt_password(role,
password,
encrypted=_DEFAULT_PASSWORDS_ENCRYPTION):
'''
pgsql passwords are md5 hashes of the string: 'md5{password}{rolename}'
'''
if password is not None:
password = six.text_type(password)
if encrypt... |
Creates a Postgres role. Users and Groups are both roles in postgres. However users can login groups cannot. | def _role_create(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
createdb=None,
createroles=None,
encrypted=None,
superuser=None,
... |
Creates a Postgres user. | def user_create(username,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
createdb=None,
createroles=None,
inherit=None,
login=None,
connli... |
Updates a postgres role. | def _role_update(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
createdb=None,
typ_='role',
createroles=None,
inherit=None,
... |
Removes a role from the Postgres Server | def _role_remove(name, user=None, host=None, port=None, maintenance_db=None,
password=None, runas=None):
'''
Removes a role from the Postgres Server
'''
# check if user exists
if not user_exists(name, user, host, port, maintenance_db,
password=password, runas... |
List installed postgresql extensions | def installed_extensions(user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
List installed postgresql extensions
CLI Example:
.. code-block:: ... |
Get info about an available postgresql extension | def get_available_extension(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Get info about an availa... |
Get info about an installed postgresql extension | def get_installed_extension(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Get info about an instal... |
Test if a specific extension is available | def is_available_extension(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Test if a specific extension is... |
Test if a specific extension is installed | def is_installed_extension(name,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Test if a specific extension is... |
Get lifecycle information about an extension | def create_metadata(name,
ext_version=None,
schema=None,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Get lifec... |
Drop an installed postgresql extension | def drop_extension(name,
if_exists=None,
restrict=None,
cascade=None,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None... |
Install a postgresql extension | def create_extension(name,
if_not_exists=None,
schema=None,
ext_version=None,
from_version=None,
user=None,
host=None,
port=None,
maintenance_db=None,
... |
Removes a user from the Postgres server. | def user_remove(username,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Removes a user from the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' p... |
Creates a Postgres group. A group is postgres is similar to a user but cannot login. | def group_create(groupname,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
createdb=None,
createroles=None,
encrypted=None,
login=None,
... |
Removes a group from the Postgres server. | def group_remove(groupname,
user=None,
host=None,
port=None,
maintenance_db=None,
password=None,
runas=None):
'''
Removes a group from the Postgres server.
CLI Example:
.. code-block:: bash
s... |
Set the owner of all schemas functions tables views and sequences to the given username. | def owner_to(dbname,
ownername,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
Set the owner of all schemas, functions, tables, views and sequences to
the given username.
CLI Example:
.. code-block:: ba... |
Creates a Postgres schema. | def schema_create(dbname, name, owner=None,
user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Creates a Postgres schema.
CLI Example:
.. code-block:: bash
salt '*' postgres.schema_create dbname name owner='owner' ... |
Removes a schema from the Postgres server. | def schema_remove(dbname, name,
user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Removes a schema from the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.schema_remove dbname schemaname
... |
Checks if a schema exists on the Postgres server. | def schema_exists(dbname, name, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Checks if a schema exists on the Postgres server.
CLI Example:
.. code-block:: bash
salt '*' postgres.schema_exists dbname schemaname
dbname
... |
Return a dict with information about schemas in a database. | def schema_get(dbname, name, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Return a dict with information about schemas in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.schema_get dbname name
dbname
Dat... |
Return a dict with information about schemas in a Postgres database. | def schema_list(dbname, user=None,
db_user=None, db_password=None,
db_host=None, db_port=None):
'''
Return a dict with information about schemas in a Postgres database.
CLI Example:
.. code-block:: bash
salt '*' postgres.schema_list dbname
dbname
D... |
.. versionadded:: 2016. 3. 0 | def language_list(
maintenance_db,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
.. versionadded:: 2016.3.0
Return a list of languages in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.language_list dbnam... |
.. versionadded:: 2016. 3. 0 | def language_exists(
name,
maintenance_db,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
.. versionadded:: 2016.3.0
Checks if language exists in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.lang... |
.. versionadded:: 2016. 3. 0 | def language_create(name,
maintenance_db,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
.. versionadded:: 2016.3.0
Installs a language into a database
CLI Example:... |
Generate the SQL required for specific object type | def _make_default_privileges_list_query(name, object_type, prepend):
'''
Generate the SQL required for specific object type
'''
if object_type == 'table':
query = (' '.join([
'SELECT defacl.defaclacl AS name',
'FROM pg_default_acl defacl',
'JOIN pg_authid aid'... |
Generate the SQL required for specific object type | def _make_privileges_list_query(name, object_type, prepend):
'''
Generate the SQL required for specific object type
'''
if object_type == 'table':
query = (' '.join([
'SELECT relacl AS name',
'FROM pg_catalog.pg_class c',
'JOIN pg_catalog.pg_namespace n',
... |
Return the owner of a postgres object | def _get_object_owner(name,
object_type,
prepend='public',
maintenance_db=None,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
Return the owner of a postgres object
'''
if object_type == 'table':
query = (' '.join(... |
Validate the supplied privileges | def _validate_default_privileges(object_type, defprivs, defprivileges):
'''
Validate the supplied privileges
'''
if object_type != 'group':
_defperms = [_DEFAULT_PRIVILEGES_MAP[defperm]
for defperm in _DEFAULT_PRIVILEGE_TYPE_MAP[object_type]]
_defperms.append('ALL')
... |
Format options | def _mod_defpriv_opts(object_type, defprivileges):
'''
Format options
'''
object_type = object_type.lower()
defprivileges = '' if defprivileges is None else defprivileges
_defprivs = re.split(r'\s?,\s?', defprivileges.upper())
return object_type, defprivileges, _defprivs |
Process part | def _process_defpriv_part(defperms):
'''
Process part
'''
_tmp = {}
previous = None
for defperm in defperms:
if previous is None:
_tmp[_DEFAULT_PRIVILEGES_MAP[defperm]] = False
previous = _DEFAULT_PRIVILEGES_MAP[defperm]
else:
if defperm == '*'... |
Validate the supplied privileges | def _validate_privileges(object_type, privs, privileges):
'''
Validate the supplied privileges
'''
if object_type != 'group':
_perms = [_PRIVILEGES_MAP[perm]
for perm in _PRIVILEGE_TYPE_MAP[object_type]]
_perms.append('ALL')
if object_type not in _PRIVILEGES_OBJE... |
Format options | def _mod_priv_opts(object_type, privileges):
'''
Format options
'''
object_type = object_type.lower()
privileges = '' if privileges is None else privileges
_privs = re.split(r'\s?,\s?', privileges.upper())
return object_type, privileges, _privs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.