INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Executes the passed command. Returns True if successful | def execute_return_success(cmd):
'''
Executes the passed command. Returns True if successful
:param str cmd: The command to run
:return: True if successful, otherwise False
:rtype: bool
:raises: Error if command fails or is not supported
'''
ret = _run_all(cmd)
if ret['retcode']... |
Executes the passed command. Returns the standard out if successful | def execute_return_result(cmd):
'''
Executes the passed command. Returns the standard out if successful
:param str cmd: The command to run
:return: The standard out of the command if successful, otherwise returns
an error
:rtype: str
:raises: Error if command fails or is not supported
... |
Helper function to validate the enabled parameter. Boolean values are converted to on and off. String values are checked to make sure they are either on or off/ yes or no. Integer 0 will return off. All other integers will return on | def validate_enabled(enabled):
'''
Helper function to validate the enabled parameter. Boolean values are
converted to "on" and "off". String values are checked to make sure they are
either "on" or "off"/"yes" or "no". Integer ``0`` will return "off". All
other integers will return "on"
:param e... |
Wait up to wait seconds for a system parameter to be changed before deciding it hasn t changed. | def confirm_updated(value, check_fun, normalize_ret=False, wait=5):
'''
Wait up to ``wait`` seconds for a system parameter to be changed before
deciding it hasn't changed.
:param str value: The value indicating a successful change
:param function check_fun: The function whose return is compared wi... |
Run a launchctl command and raise an error if it fails | def launchctl(sub_cmd, *args, **kwargs):
'''
Run a launchctl command and raise an error if it fails
Args: additional args are passed to launchctl
sub_cmd (str): Sub command supplied to launchctl
Kwargs: passed to ``cmd.run_all``
return_stdout (bool): A keyword argument. If true return ... |
This is a helper function for getting the available macOS services. | def _available_services(refresh=False):
'''
This is a helper function for getting the available macOS services.
The strategy is to look through the known system locations for
launchd plist files, parse them, and use their information for
populating the list of services. Services can run without a p... |
Gets the UID or Username of the current console user. | def console_user(username=False):
'''
Gets the UID or Username of the current console user.
:return: The uid or username of the console user.
:param bool username: Whether to return the username of the console
user instead of the UID. Defaults to False
:rtype: Interger of the UID, or a string... |
This state manages software package repositories. Currently: mod: yum <salt. modules. yumpkg >: mod: apt <salt. modules. aptpkg > and: mod: zypper <salt. modules. zypper > repositories are supported. | def managed(name, ppa=None, **kwargs):
'''
This state manages software package repositories. Currently, :mod:`yum
<salt.modules.yumpkg>`, :mod:`apt <salt.modules.aptpkg>`, and :mod:`zypper
<salt.modules.zypper>` repositories are supported.
**YUM/DNF/ZYPPER-BASED SYSTEMS**
.. note::
One... |
This function deletes the specified repo on the system if it exists. It is essentially a wrapper around pkg. del_repo. | def absent(name, **kwargs):
'''
This function deletes the specified repo on the system, if it exists. It
is essentially a wrapper around pkg.del_repo.
name
The name of the package repo, as it would be referred to when running
the regular package manager commands.
**UBUNTU-SPECIFIC ... |
Read pillar data from Foreman via its API. | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
key=None,
only=()):
'''
Read pillar data from Foreman via its API.
'''
url = __opts__['foreman.url']
user = __opts__['foreman.user']
password = __opts__['foreman.password']
api = __opts__[... |
Creates a DynamoDB table. | def create_table(table_name, region=None, key=None, keyid=None, profile=None,
read_capacity_units=None, write_capacity_units=None,
hash_key=None, hash_key_data_type=None, range_key=None,
range_key_data_type=None, local_indexes=None,
global_indexes=None... |
Check to see if a table exists. | def exists(table_name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a table exists.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.exists table_name region=us-east-1
'''
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=... |
Delete a DynamoDB table. | def delete(table_name, region=None, key=None, keyid=None, profile=None):
'''
Delete a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.delete table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table ... |
Update a DynamoDB table. | def update(table_name, throughput=None, global_indexes=None,
region=None, key=None, keyid=None, profile=None):
'''
Update a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.update table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, prof... |
Creates a single global secondary index on a DynamoDB table. | def create_global_secondary_index(table_name, global_index, region=None,
key=None, keyid=None, profile=None):
'''
Creates a single global secondary index on a DynamoDB table.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.create_global_secondary... |
Updates the throughput of the given global secondary indexes. | def update_global_secondary_index(table_name, global_indexes, region=None,
key=None, keyid=None, profile=None):
'''
Updates the throughput of the given global secondary indexes.
CLI Example:
.. code-block:: bash
salt myminion boto_dynamodb.update_global_second... |
Describe a DynamoDB table. | def describe(table_name, region=None, key=None, keyid=None, profile=None):
'''
Describe a DynamoDB table.
CLI example::
salt myminion boto_dynamodb.describe table_name region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
table = Table(table_name, ... |
Instantiates and returns an AllIndex object given a valid index configuration | def extract_index(index_data, global_index=False):
'''
Instantiates and returns an AllIndex object given a valid index
configuration
CLI Example:
salt myminion boto_dynamodb.extract_index index
'''
parsed_data = {}
keys = []
for key, value in six.iteritems(index_data):
... |
Install a Perl module from CPAN | def install(module):
'''
Install a Perl module from CPAN
CLI Example:
.. code-block:: bash
salt '*' cpan.install Template::Alloy
'''
ret = {
'old': None,
'new': None,
}
old_info = show(module)
cmd = 'cpan -i {0}'.format(module)
out = __salt__['cmd.run... |
Attempt to remove a Perl module that was installed from CPAN. Because the cpan command doesn t actually support uninstall - like functionality this function will attempt to do what it can with what it has from CPAN. | def remove(module, details=False):
'''
Attempt to remove a Perl module that was installed from CPAN. Because the
``cpan`` command doesn't actually support "uninstall"-like functionality,
this function will attempt to do what it can, with what it has from CPAN.
Until this function is declared stable... |
List installed Perl modules and the version installed | def list_():
'''
List installed Perl modules, and the version installed
CLI Example:
.. code-block:: bash
salt '*' cpan.list
'''
ret = {}
cmd = 'cpan -l'
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
comps = line.split()
ret[comps[0]] = comps... |
Show information about a specific Perl module | def show(module):
'''
Show information about a specific Perl module
CLI Example:
.. code-block:: bash
salt '*' cpan.show Template::Alloy
'''
ret = {}
ret['name'] = module
# This section parses out details from CPAN, if possible
cmd = 'cpan -D {0}'.format(module)
out =... |
Return a dict of CPAN configuration values | def show_config():
'''
Return a dict of CPAN configuration values
CLI Example:
.. code-block:: bash
salt '*' cpan.show_config
'''
ret = {}
cmd = 'cpan -J'
out = __salt__['cmd.run'](cmd).splitlines()
for line in out:
if '=>' not in line:
# TODO: Some opt... |
Get a cursor and run a query. Reconnect up to retries times if needed. Returns: cursor affected rows counter Raises: SaltCacheError AttributeError OperationalError | def run_query(conn, query, retries=3):
'''
Get a cursor and run a query. Reconnect up to `retries` times if
needed.
Returns: cursor, affected rows counter
Raises: SaltCacheError, AttributeError, OperationalError
'''
try:
cur = conn.cursor()
out = cur.execute(query)
re... |
Create table if needed | def _create_table():
'''
Create table if needed
'''
# Explicitely check if the table already exists as the library logs a
# warning on CREATE TABLE
query = """SELECT COUNT(TABLE_NAME) FROM information_schema.tables
WHERE table_schema = '{0}' AND table_name = '{1}'""".format(
... |
Initialize connection and create table if needed | def _init_client():
"""Initialize connection and create table if needed
"""
if client is not None:
return
global _mysql_kwargs, _table_name
_mysql_kwargs = {
'host': __opts__.get('mysql.host', '127.0.0.1'),
'user': __opts__.get('mysql.user', None),
'passwd': __opts__... |
Store a key value. | def store(bank, key, data):
'''
Store a key value.
'''
_init_client()
data = __context__['serial'].dumps(data)
query = b"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', " \
b"'{3}')".format(_table_name,
bank,
key,
... |
Fetch a key value. | def fetch(bank, key):
'''
Fetch a key value.
'''
_init_client()
query = "SELECT data FROM {0} WHERE bank='{1}' AND etcd_key='{2}'".format(
_table_name, bank, key)
cur, _ = run_query(client, query)
r = cur.fetchone()
cur.close()
if r is None:
return {}
return __con... |
Remove the key from the cache bank with all the key content. | def flush(bank, key=None):
'''
Remove the key from the cache bank with all the key content.
'''
_init_client()
query = "DELETE FROM {0} WHERE bank='{1}'".format(_table_name, bank)
if key is not None:
query += " AND etcd_key='{0}'".format(key)
cur, _ = run_query(client, query)
cu... |
Return an iterable object containing all entries stored in the specified bank. | def ls(bank):
'''
Return an iterable object containing all entries stored in the specified
bank.
'''
_init_client()
query = "SELECT etcd_key FROM {0} WHERE bank='{1}'".format(
_table_name, bank)
cur, _ = run_query(client, query)
out = [row[0] for row in cur.fetchall()]
cur.cl... |
Checks if the specified bank contains the specified key. | def contains(bank, key):
'''
Checks if the specified bank contains the specified key.
'''
_init_client()
query = "SELECT COUNT(data) FROM {0} WHERE bank='{1}' " \
"AND etcd_key='{2}'".format(_table_name, bank, key)
cur, _ = run_query(client, query)
r = cur.fetchone()
cur.close()
... |
Create a new database and opens it. | def new(self):
'''
Create a new database and opens it.
:return:
'''
dbname = self._label()
self.db_path = os.path.join(self.path, dbname)
if not os.path.exists(self.db_path):
os.makedirs(self.db_path)
self._opened = True
self.list_tabl... |
Purge the database. | def purge(self, dbid):
'''
Purge the database.
:param dbid:
:return:
'''
db_path = os.path.join(self.path, dbid)
if os.path.exists(db_path):
shutil.rmtree(db_path, ignore_errors=True)
return True
return False |
Flush table. | def flush(self, table):
'''
Flush table.
:param table:
:return:
'''
table_path = os.path.join(self.db_path, table)
if os.path.exists(table_path):
os.unlink(table_path) |
List all the databases on the given path. | def list(self):
'''
List all the databases on the given path.
:return:
'''
databases = []
for dbname in os.listdir(self.path):
databases.append(dbname)
return list(reversed(sorted(databases))) |
Load existing tables and their descriptions. | def list_tables(self):
'''
Load existing tables and their descriptions.
:return:
'''
if not self._tables:
for table_name in os.listdir(self.db_path):
self._tables[table_name] = self._load_table(table_name)
return self._tables.keys() |
Open database from the path with the name or latest. If there are no yet databases create a new implicitly. | def open(self, dbname=None):
'''
Open database from the path with the name or latest.
If there are no yet databases, create a new implicitly.
:return:
'''
databases = self.list()
if self.is_closed():
self.db_path = os.path.join(self.path, dbname or (d... |
Create a table from the object. NOTE: This method doesn t stores anything. | def create_table_from_object(self, obj):
'''
Create a table from the object.
NOTE: This method doesn't stores anything.
:param obj:
:return:
'''
get_type = lambda item: str(type(item)).split("'")[1]
if not os.path.exists(os.path.join(self.db_path, obj._TA... |
Store an object in the table. | def store(self, obj, distinct=False):
'''
Store an object in the table.
:param obj: An object to store
:param distinct: Store object only if there is none identical of such.
If at least one field is different, store it.
:return:
'''
if d... |
Update object ( s ) in the database. | def update(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Update object(s) in the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return:
'''
updated = False
objects = list()
for _obj in se... |
Delete object from the database. | def delete(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Delete object from the database.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return:
'''
deleted = False
objects = list()
for _obj in sel... |
Returns True if object is aligned to the criteria. | def __criteria(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Returns True if object is aligned to the criteria.
:param obj:
:param matches:
:param mt:
:param lt:
:param eq:
:return: Boolean
'''
# Fail matcher if "less than"
... |
Get objects from the table. | def get(self, obj, matches=None, mt=None, lt=None, eq=None):
'''
Get objects from the table.
:param table_name:
:param matches: Regexp.
:param mt: More than.
:param lt: Less than.
:param eq: Equals.
:return:
'''
objects = []
with g... |
Send an event with the given tag and data. | def send(tag, data=None):
'''
Send an event with the given tag and data.
This is useful for sending events directly to the master from the shell
with salt-run. It is also quite useful for sending events in orchestration
states where the ``fire_event`` requisite isn't sufficient because it does
... |
.. versionchanged:: 2017. 7. 0 The expr_form argument has been renamed to tgt_type earlier releases must use expr_form. | def grains(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached grains of the targeted minions.
tgt
Target to match minion ids.
.. vers... |
.. versionchanged:: 2017. 7. 0 The expr_form argument has been renamed to tgt_type earlier releases must use expr_form. | def pillar(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached pillars of the targeted minions
CLI Example:
.. code-block:: bash
salt-run... |
.. versionchanged:: 2017. 7. 0 The expr_form argument has been renamed to tgt_type earlier releases must use expr_form. | def mine(tgt=None, tgt_type='glob', **kwargs):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Return cached mine data of the targeted minions
CLI Example:
.. code-block:: bash
salt-run... |
Clear the cached data/ files for the targeted minions. | def _clear_cache(tgt=None,
tgt_type='glob',
clear_pillar_flag=False,
clear_grains_flag=False,
clear_mine_flag=False,
clear_mine_func_flag=None):
'''
Clear the cached data/files for the targeted minions.
'''
if tgt is No... |
.. versionchanged:: 2017. 7. 0 The expr_form argument has been renamed to tgt_type earlier releases must use expr_form. | def clear_all(tgt=None, tgt_type='glob'):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Clear the cached pillar, grains, and mine data of the targeted minions
CLI Example:
.. code-block:: bash... |
.. versionadded:: 2015. 8. 2 | def clear_git_lock(role, remote=None, **kwargs):
'''
.. versionadded:: 2015.8.2
Remove the update locks for Salt components (gitfs, git_pillar, winrepo)
which use gitfs backend code from salt.utils.gitfs.
.. note::
Running :py:func:`cache.clear_all <salt.runners.cache.clear_all>` will
... |
Return cloud cache data for target. | def cloud(tgt, provider=None):
'''
Return cloud cache data for target.
.. note:: Only works with glob matching
tgt
Glob Target to match minion ids
provider
Cloud Provider
CLI Example:
.. code-block:: bash
salt-run cache.cloud 'salt*'
salt-run cache.cloud gla... |
Lists entries stored in the specified bank. | def store(bank, key, data, cachedir=None):
'''
Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.store mycache mykey 'The time has come the walrus said'
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache ... |
Lists entries stored in the specified bank. | def list_(bank, cachedir=None):
'''
Lists entries stored in the specified bank.
CLI Example:
.. code-block:: bash
salt-run cache.list cloud/active/ec2/myec2 cachedir=/var/cache/salt/
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache = salt.cache.... |
Fetch data from a salt. cache bank. | def fetch(bank, key, cachedir=None):
'''
Fetch data from a salt.cache bank.
CLI Example:
.. code-block:: bash
salt-run cache.fetch cloud/active/ec2/myec2 myminion cachedir=/var/cache/salt/
'''
if cachedir is None:
cachedir = __opts__['cachedir']
try:
cache = salt.... |
Return an postgres cursor | def _conn(commit=False):
'''
Return an postgres cursor
'''
defaults = {'host': 'localhost',
'user': 'salt',
'password': 'salt',
'dbname': 'salt',
'port': 5432}
conn_kwargs = {}
for key, value in defaults.items():
conn_kwarg... |
Add an item or items to a queue | def insert(queue, items):
'''
Add an item or items to a queue
'''
handle_queue_creation(queue)
with _conn(commit=True) as cur:
if isinstance(items, dict):
items = salt.utils.json.dumps(items)
cmd = str('''INSERT INTO {0}(data) VALUES('{1}')''').format(queue, items) ... |
Delete an item or items from a queue | def delete(queue, items):
'''
Delete an item or items from a queue
'''
with _conn(commit=True) as cur:
if isinstance(items, dict):
cmd = str("""DELETE FROM {0} WHERE data = '{1}'""").format( # future lint: disable=blacklisted-function
queue,
salt.util... |
Pop one or more or all items from the queue return them. | def pop(queue, quantity=1, is_runner=False):
'''
Pop one or more or all items from the queue return them.
'''
cmd = 'SELECT id, data FROM {0}'.format(queue)
if quantity != 'all':
try:
quantity = int(quantity)
except ValueError as exc:
error_txt = ('Quantity mu... |
Daemonize a process | def daemonize(redirect_out=True):
'''
Daemonize a process
'''
# Avoid circular import
import salt.utils.crypt
try:
pid = os.fork()
if pid > 0:
# exit first parent
salt.utils.crypt.reinit_crypto()
os._exit(salt.defaults.exitcodes.EX_OK)
exce... |
Daemonize a module function process if multiprocessing is True and the process is not being called by salt - call | def daemonize_if(opts):
'''
Daemonize a module function process if multiprocessing is True and the
process is not being called by salt-call
'''
if 'salt-call' in sys.argv[0]:
return
if not opts.get('multiprocessing', True):
return
if sys.platform.startswith('win'):
re... |
Notify systemd that this process has started | def notify_systemd():
'''
Notify systemd that this process has started
'''
try:
import systemd.daemon
except ImportError:
if salt.utils.path.which('systemd-notify') \
and systemd_notify_call('--booted'):
# Notify systemd synchronously
notify_so... |
Save the pidfile | def set_pidfile(pidfile, user):
'''
Save the pidfile
'''
pdir = os.path.dirname(pidfile)
if not os.path.isdir(pdir) and pdir:
os.makedirs(pdir)
try:
with salt.utils.files.fopen(pidfile, 'w+') as ofile:
ofile.write(str(os.getpid())) # future lint: disable=blacklisted-... |
Return the pid from a pidfile as an integer | def get_pidfile(pidfile):
'''
Return the pid from a pidfile as an integer
'''
try:
with salt.utils.files.fopen(pidfile) as pdf:
pid = pdf.read().strip()
return int(pid)
except (OSError, IOError, TypeError, ValueError):
return -1 |
Generic method for cleaning up multiprocessing procs | def clean_proc(proc, wait_for_kill=10):
'''
Generic method for cleaning up multiprocessing procs
'''
# NoneType and other fun stuff need not apply
if not proc:
return
try:
waited = 0
while proc.is_alive():
proc.terminate()
waited += 1
t... |
Use OS facilities to determine if a process is running | def os_is_running(pid):
'''
Use OS facilities to determine if a process is running
'''
if isinstance(pid, six.string_types):
pid = int(pid)
if HAS_PSUTIL:
return psutil.pid_exists(pid)
else:
try:
os.kill(pid, 0) # SIG 0 is the "are you alive?" signal
... |
Create a processes and args + kwargs This will deterimine if it is a Process class otherwise it assumes it is a function | def add_process(self, tgt, args=None, kwargs=None, name=None):
'''
Create a processes and args + kwargs
This will deterimine if it is a Process class, otherwise it assumes
it is a function
'''
if args is None:
args = []
if kwargs is None:
... |
Create new process ( assuming this one is dead ) then remove the old one | def restart_process(self, pid):
'''
Create new process (assuming this one is dead), then remove the old one
'''
if self._restart_processes is False:
return
log.info(
'Process %s (%s) died with exit status %s, restarting...',
self._process_map[p... |
Load and start all available api modules | def run(self, asynchronous=False):
'''
Load and start all available api modules
'''
log.debug('Process Manager starting!')
appendproctitle(self.name)
# make sure to kill the subprocesses if the parent is killed
if signal.getsignal(signal.SIGTERM) is signal.SIG_DF... |
Check the children once | def check_children(self):
'''
Check the children once
'''
if self._restart_processes is True:
for pid, mapping in six.iteritems(self._process_map):
if not mapping['Process'].is_alive():
log.trace('Process restart of %s', pid)
... |
Kill all of the children | def kill_children(self, *args, **kwargs):
'''
Kill all of the children
'''
# first lets reset signal handlers to default one to prevent running this twice
signal.signal(signal.SIGTERM, signal.SIG_IGN)
signal.signal(signal.SIGINT, signal.SIG_IGN)
# check that this... |
Make a web call to VictorOps | def _query(action=None,
routing_key=None,
args=None,
method='GET',
header_dict=None,
data=None):
'''
Make a web call to VictorOps
'''
api_key = __salt__['config.get']('victorops.api_key') or \
__salt__['config.get']('victorops:api_key')
... |
Create an event in VictorOps. Designed for use in states. | def create_event(message_type=None, routing_key='everybody', **kwargs):
'''
Create an event in VictorOps. Designed for use in states.
The following parameters are required:
:param message_type: One of the following values: INFO, WARNING, ACKNOWLEDGEMENT, CRITICAL, RECOVERY.
The followi... |
Ensure the telemetry alert exists. | def present(name, deployment_id, metric_name, alert_config, api_key=None, profile='telemetry'):
'''
Ensure the telemetry alert exists.
name
An optional description of the alarm (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
... |
Ensure the telemetry alert config is deleted | def absent(name, deployment_id, metric_name, api_key=None, profile="telemetry"):
'''
Ensure the telemetry alert config is deleted
name
An optional description of the alarms (not currently supported by telemetry API)
deployment_id
Specifies the ID of the root deployment resource
... |
List the installed packages. | def list_():
'''
List the installed packages.
:return: A list of installed packages
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' pkgutil.list
'''
cmd = 'pkgutil --pkgs'
ret = salt.utils.mac_utils.execute_return_result(cmd)
return ret.splitlines() |
Internal function to install a package from the given path | def _install_from_path(path):
'''
Internal function to install a package from the given path
'''
if not os.path.exists(path):
msg = 'File not found: {0}'.format(path)
raise SaltInvocationError(msg)
cmd = 'installer -pkg "{0}" -target /'.format(path)
return salt.utils.mac_utils.e... |
Install a. pkg from an URI or an absolute path. | def install(source, package_id):
'''
Install a .pkg from an URI or an absolute path.
:param str source: The path to a package.
:param str package_id: The package ID
:return: True if successful, otherwise False
:rtype: bool
CLI Example:
.. code-block:: bash
salt '*' pkgutil.... |
.. versionadded:: 2016. 3. 0 | def forget(package_id):
'''
.. versionadded:: 2016.3.0
Remove the receipt data about the specified package. Does not remove files.
.. warning::
DO NOT use this command to fix broken package design
:param str package_id: The name of the package to forget
:return: True if successful, o... |
Return a list of the currently installed app ids. | def apps():
'''
Return a list of the currently installed app ids.
CLI Example:
.. code-block:: bash
salt marathon-minion-id marathon.apps
'''
response = salt.utils.http.query(
"{0}/v2/apps".format(_base_url()),
decode_type='json',
decode=True,
)
return ... |
Update the specified app with the given configuration. | def update_app(id, config):
'''
Update the specified app with the given configuration.
CLI Example:
.. code-block:: bash
salt marathon-minion-id marathon.update_app my-app '<config yaml>'
'''
if 'id' not in config:
config['id'] = id
config.pop('version', None)
# mirror... |
Remove the specified app from the server. | def rm_app(id):
'''
Remove the specified app from the server.
CLI Example:
.. code-block:: bash
salt marathon-minion-id marathon.rm_app my-app
'''
response = salt.utils.http.query(
"{0}/v2/apps/{1}".format(_base_url(), id),
method='DELETE',
decode_type='json',
... |
Return configuration and status information about the marathon instance. | def info():
'''
Return configuration and status information about the marathon instance.
CLI Example:
.. code-block:: bash
salt marathon-minion-id marathon.info
'''
response = salt.utils.http.query(
"{0}/v2/info".format(_base_url()),
decode_type='json',
decode=... |
Restart the current server configuration for the specified app. | def restart_app(id, restart=False, force=True):
'''
Restart the current server configuration for the specified app.
:param restart: Restart the app
:param force: Override the current deployment
CLI Example:
.. code-block:: bash
salt marathon-minion-id marathon.restart_app my-app
... |
Return a list of the configured DNS servers of the specified interface | def get_dns_servers(interface='Local Area Connection'):
'''
Return a list of the configured DNS servers of the specified interface
CLI Example:
.. code-block:: bash
salt '*' win_dns_client.get_dns_servers 'Local Area Connection'
'''
# remove any escape characters
interface = inter... |
Remove the DNS server from the network interface | def rm_dns(ip, interface='Local Area Connection'):
'''
Remove the DNS server from the network interface
CLI Example:
.. code-block:: bash
salt '*' win_dns_client.rm_dns <ip> <interface>
'''
cmd = ['netsh', 'interface', 'ip', 'delete', 'dns', interface, ip, 'validate=no']
return __... |
Add the DNS server to the network interface ( index starts from 1 ) | def add_dns(ip, interface='Local Area Connection', index=1):
'''
Add the DNS server to the network interface
(index starts from 1)
Note: if the interface DNS is configured by DHCP, all the DNS servers will
be removed from the interface and the requested DNS will be the only one
CLI Example:
... |
Get the type of DNS configuration ( dhcp/ static ) | def get_dns_config(interface='Local Area Connection'):
'''
Get the type of DNS configuration (dhcp / static)
CLI Example:
.. code-block:: bash
salt '*' win_dns_client.get_dns_config 'Local Area Connection'
'''
# remove any escape characters
interface = interface.split('\\')
in... |
Verify that the given package is installed and is at the correct version ( if specified ). | def installed(name,
dir,
pkgs=None,
user=None,
env=None):
'''
Verify that the given package is installed and is at the correct version
(if specified).
.. code-block:: yaml
underscore:
bower.installed:
- dir: /path/to... |
Bootstraps a frontend distribution. | def bootstrap(name, user=None):
'''
Bootstraps a frontend distribution.
Will execute 'bower install' on the specified directory.
user
The user to run Bower with
'''
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
if __opts__['test']:
ret['result'] = Non... |
.. versionadded:: 2017. 7. 0 | def pruned(name, user=None, env=None):
'''
.. versionadded:: 2017.7.0
Cleans up local bower_components directory.
Will execute 'bower prune' on the specified directory (param: name)
user
The user to run Bower with
'''
ret = {'name': name, 'result': None, 'comment': '', 'changes':... |
Ensure that the named export is present with the given options | def present(name,
clients=None,
hosts=None,
options=None,
exports='/etc/exports'):
'''
Ensure that the named export is present with the given options
name
The export path to configure
clients
A list of hosts and the options applied to the... |
Ensure that the named path is not exported | def absent(name, exports='/etc/exports'):
'''
Ensure that the named path is not exported
name
The export path to remove
'''
path = name
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
old = __salt__['nfs3.list_exports'](exports)
... |
Slack object method function to construct and execute on the API URL. | def query(function,
api_key=None,
args=None,
method='GET',
header_dict=None,
data=None,
opts=None):
'''
Slack object method function to construct and execute on the API URL.
:param api_key: The Slack api key.
:param function: The Slack ... |
Validate the beacon configuration | def validate(config):
'''
Validate the beacon configuration
'''
# Configuration for pkg beacon should be a list
if not isinstance(config, list):
return False, ('Configuration for pkg beacon must be a list.')
# Configuration for pkg beacon should contain pkgs
pkgs_found = False
p... |
Check if installed packages are the latest versions and fire an event for those that have upgrades. | def beacon(config):
'''
Check if installed packages are the latest versions
and fire an event for those that have upgrades.
.. code-block:: yaml
beacons:
pkg:
- pkgs:
- zsh
- apache2
- refresh: True
'''
ret = []
_re... |
Set a new value for a specific configuration line. | def set_(name, key, value, setting=None, conf_file=_DEFAULT_CONF):
'''
Set a new value for a specific configuration line.
:param str key: The command or block to configure.
:param str value: The command value or command of the block specified by the key parameter.
:param str setting: The command va... |
Unlock a FS file/ dir based lock | def _unlock_cache(w_lock):
'''
Unlock a FS file/dir based lock
'''
if not os.path.exists(w_lock):
return
try:
if os.path.isdir(w_lock):
os.rmdir(w_lock)
elif os.path.isfile(w_lock):
os.unlink(w_lock)
except (OSError, IOError) as exc:
log.tr... |
If the write lock is there check to see if the file is actually being written. If there is no change in the file size after a short sleep remove the lock and move forward. | def wait_lock(lk_fn, dest, wait_timeout=0):
'''
If the write lock is there, check to see if the file is actually being
written. If there is no change in the file size after a short sleep,
remove the lock and move forward.
'''
if not os.path.exists(lk_fn):
return False
if not os.path.... |
Checks the cache file to see if there is a new enough file list cache and returns the match ( if found along with booleans used by the fileserver backend to determine if the cache needs to be refreshed/ written ). | def check_file_list_cache(opts, form, list_cache, w_lock):
'''
Checks the cache file to see if there is a new enough file list cache, and
returns the match (if found, along with booleans used by the fileserver
backend to determine if the cache needs to be refreshed/written).
'''
refresh_cache = ... |
Checks the cache file to see if there is a new enough file list cache and returns the match ( if found along with booleans used by the fileserver backend to determine if the cache needs to be refreshed/ written ). | def write_file_list_cache(opts, data, list_cache, w_lock):
'''
Checks the cache file to see if there is a new enough file list cache, and
returns the match (if found, along with booleans used by the fileserver
backend to determine if the cache needs to be refreshed/written).
'''
serial = salt.pa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.