repository_name
stringclasses
316 values
func_path_in_repository
stringlengths
6
223
func_name
stringlengths
1
134
language
stringclasses
1 value
func_code_string
stringlengths
57
65.5k
func_documentation_string
stringlengths
1
46.3k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
called_functions
listlengths
1
156
enclosing_scope
stringlengths
2
1.48M
saltstack/salt
salt/states/azurearm_network.py
security_rule_absent
python
def security_rule_absent(name, security_group, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a security rule does not exist in the network security group. :param name: Name of the security rule. :param security_group: The network security group conta...
.. versionadded:: 2019.2.0 Ensure a security rule does not exist in the network security group. :param name: Name of the security rule. :param security_group: The network security group containing the security rule. :param resource_group: The resource group assigned to the ne...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1055-L1119
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
load_balancer_present
python
def load_balancer_present(name, resource_group, sku=None, frontend_ip_configurations=None, backend_address_pools=None, load_balancing_rules=None, probes=None, inbound_nat_rules=None, inbound_nat_pools=None, outbound_nat_rules=None, tags=None, connection_auth=None, **k...
.. versionadded:: 2019.2.0 Ensure a load balancer exists. :param name: Name of the load balancer. :param resource_group: The resource group assigned to the load balancer. :param sku: The load balancer SKU, which can be 'Basic' or 'Standard'. :param tags: A dictio...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1122-L1478
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
load_balancer_absent
python
def load_balancer_absent(name, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a load balancer does not exist in the resource group. :param name: Name of the load balancer. :param resource_group: The resource group assigned to the load balancer. :...
.. versionadded:: 2019.2.0 Ensure a load balancer does not exist in the resource group. :param name: Name of the load balancer. :param resource_group: The resource group assigned to the load balancer. :param connection_auth: A dict with subscription and authentication paramet...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1481-L1541
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
public_ip_address_present
python
def public_ip_address_present(name, resource_group, tags=None, sku=None, public_ip_allocation_method=None, public_ip_address_version=None, dns_settings=None, idle_timeout_in_minutes=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 ...
.. versionadded:: 2019.2.0 Ensure a public IP address exists. :param name: Name of the public IP address. :param resource_group: The resource group assigned to the public IP address. :param dns_settings: An optional dictionary representing a valid PublicIPAddressDnsSettings o...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1544-L1727
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
public_ip_address_absent
python
def public_ip_address_absent(name, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a public IP address does not exist in the resource group. :param name: Name of the public IP address. :param resource_group: The resource group assigned to the public IP...
.. versionadded:: 2019.2.0 Ensure a public IP address does not exist in the resource group. :param name: Name of the public IP address. :param resource_group: The resource group assigned to the public IP address. :param connection_auth: A dict with subscription and authentica...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1730-L1790
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
network_interface_present
python
def network_interface_present(name, ip_configurations, subnet, virtual_network, resource_group, tags=None, virtual_machine=None, network_security_group=None, dns_settings=None, mac_address=None, primary=None, enable_accelerated_networking=None, enable_ip_forwa...
.. versionadded:: 2019.2.0 Ensure a network interface exists. :param name: Name of the network interface. :param ip_configurations: A list of dictionaries representing valid NetworkInterfaceIPConfiguration objects. The 'name' key is required at minimum. At least one IP Configurati...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L1793-L2047
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
network_interface_absent
python
def network_interface_absent(name, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a network interface does not exist in the resource group. :param name: Name of the network interface. :param resource_group: The resource group assigned to the network i...
.. versionadded:: 2019.2.0 Ensure a network interface does not exist in the resource group. :param name: Name of the network interface. :param resource_group: The resource group assigned to the network interface. :param connection_auth: A dict with subscription and authentica...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L2050-L2110
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
route_table_present
python
def route_table_present(name, resource_group, tags=None, routes=None, disable_bgp_route_propagation=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure a route table exists. :param name: Name of the route table. :param resource_group: ...
.. versionadded:: 2019.2.0 Ensure a route table exists. :param name: Name of the route table. :param resource_group: The resource group assigned to the route table. :param routes: An optional list of dictionaries representing valid Route objects contained within a route table...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L2113-L2251
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
route_table_absent
python
def route_table_absent(name, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a route table does not exist in the resource group. :param name: Name of the route table. :param resource_group: The resource group assigned to the route table. :param co...
.. versionadded:: 2019.2.0 Ensure a route table does not exist in the resource group. :param name: Name of the route table. :param resource_group: The resource group assigned to the route table. :param connection_auth: A dict with subscription and authentication parameters to...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L2254-L2314
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
route_present
python
def route_present(name, address_prefix, next_hop_type, route_table, resource_group, next_hop_ip_address=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure a route exists within a route table. :param name: Name of the route. :param address_prefix...
.. versionadded:: 2019.2.0 Ensure a route exists within a route table. :param name: Name of the route. :param address_prefix: The destination CIDR to which the route applies. :param next_hop_type: The type of Azure hop the packet should be sent to. Possible values are: 'Virtu...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L2317-L2447
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/states/azurearm_network.py
route_absent
python
def route_absent(name, route_table, resource_group, connection_auth=None): ''' .. versionadded:: 2019.2.0 Ensure a route table does not exist in the resource group. :param name: Name of the route table. :param route_table: The name of the existing route table containing the route....
.. versionadded:: 2019.2.0 Ensure a route table does not exist in the resource group. :param name: Name of the route table. :param route_table: The name of the existing route table containing the route. :param resource_group: The resource group assigned to the route table. ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/azurearm_network.py#L2450-L2514
null
# -*- coding: utf-8 -*- ''' Azure (ARM) Network State Module .. versionadded:: 2019.2.0 :maintainer: <devops@decisionlab.io> :maturity: new :depends: * `azure <https://pypi.python.org/pypi/azure>`_ >= 2.0.0 * `azure-common <https://pypi.python.org/pypi/azure-common>`_ >= 1.1.8 * `azure-mgmt <https://pypi....
saltstack/salt
salt/utils/jid.py
gen_jid
python
def gen_jid(opts=None): ''' Generate a jid ''' if opts is None: salt.utils.versions.warn_until( 'Sodium', 'The `opts` argument was not passed into salt.utils.jid.gen_jid(). ' 'This will be required starting in {version}.' ) opts = {} global...
Generate a jid
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L17-L39
[ "def warn_until(version,\n message,\n category=DeprecationWarning,\n stacklevel=None,\n _version_info_=None,\n _dont_call_warnings=False):\n '''\n Helper function to raise a warning, by default, a ``DeprecationWarning``,\n until the prov...
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/utils/jid.py
is_jid
python
def is_jid(jid): ''' Returns True if the passed in value is a job id ''' if not isinstance(jid, six.string_types): return False if len(jid) != 20 and (len(jid) <= 21 or jid[20] != '_'): return False try: int(jid[:20]) return True except ValueError: ret...
Returns True if the passed in value is a job id
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L42-L54
null
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/utils/jid.py
jid_to_time
python
def jid_to_time(jid): ''' Convert a salt job id into the time when the job was invoked ''' jid = six.text_type(jid) if len(jid) != 20 and (len(jid) <= 21 or jid[20] != '_'): return '' year = jid[:4] month = jid[4:6] day = jid[6:8] hour = jid[8:10] minute = jid[10:12] ...
Convert a salt job id into the time when the job was invoked
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L57-L79
null
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/utils/jid.py
format_job_instance
python
def format_job_instance(job): ''' Format the job instance correctly ''' ret = {'Function': job.get('fun', 'unknown-function'), 'Arguments': list(job.get('arg', [])), # unlikely but safeguard from invalid returns 'Target': job.get('tgt', 'unknown-target'), 'Tar...
Format the job instance correctly
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L82-L99
null
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/utils/jid.py
format_jid_instance
python
def format_jid_instance(jid, job): ''' Format the jid correctly ''' ret = format_job_instance(job) ret.update({'StartTime': jid_to_time(jid)}) return ret
Format the jid correctly
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L102-L108
[ "def jid_to_time(jid):\n '''\n Convert a salt job id into the time when the job was invoked\n '''\n jid = six.text_type(jid)\n if len(jid) != 20 and (len(jid) <= 21 or jid[20] != '_'):\n return ''\n year = jid[:4]\n month = jid[4:6]\n day = jid[6:8]\n hour = jid[8:10]\n minute =...
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/utils/jid.py
format_jid_instance_ext
python
def format_jid_instance_ext(jid, job): ''' Format the jid correctly with jid included ''' ret = format_job_instance(job) ret.update({ 'JID': jid, 'StartTime': jid_to_time(jid)}) return ret
Format the jid correctly with jid included
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L111-L119
[ "def jid_to_time(jid):\n '''\n Convert a salt job id into the time when the job was invoked\n '''\n jid = six.text_type(jid)\n if len(jid) != 20 and (len(jid) <= 21 or jid[20] != '_'):\n return ''\n year = jid[:4]\n month = jid[4:6]\n day = jid[6:8]\n hour = jid[8:10]\n minute =...
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/utils/jid.py
jid_dir
python
def jid_dir(jid, job_dir=None, hash_type='sha256'): ''' Return the jid_dir for the given job id ''' if not isinstance(jid, six.string_types): jid = six.text_type(jid) jhash = getattr(hashlib, hash_type)( salt.utils.stringutils.to_bytes(jid)).hexdigest() parts = [] if job_dir...
Return the jid_dir for the given job id
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jid.py#L122-L135
null
# -*- coding: utf-8 -*- ''' Functions for creating and working with job IDs ''' from __future__ import absolute_import, print_function, unicode_literals from calendar import month_abbr as months import datetime import hashlib import os import salt.utils.stringutils from salt.ext import six LAST_JID_DATETIME = None ...
saltstack/salt
salt/modules/system.py
init
python
def init(runlevel): ''' Change the system runlevel on sysV compatible systems CLI Example: .. code-block:: bash salt '*' system.init 3 ''' cmd = ['init', '{0}'.format(runlevel)] ret = __salt__['cmd.run'](cmd, python_shell=False) return ret
Change the system runlevel on sysV compatible systems CLI Example: .. code-block:: bash salt '*' system.init 3
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L64-L76
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
reboot
python
def reboot(at_time=None): ''' Reboot the system at_time The wait time in minutes before the system will be rebooted. CLI Example: .. code-block:: bash salt '*' system.reboot ''' cmd = ['shutdown', '-r', ('{0}'.format(at_time) if at_time else 'now')] ret = __salt__['cm...
Reboot the system at_time The wait time in minutes before the system will be rebooted. CLI Example: .. code-block:: bash salt '*' system.reboot
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L94-L109
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
shutdown
python
def shutdown(at_time=None): ''' Shutdown a running system at_time The wait time in minutes before the system will be shutdown. CLI Example: .. code-block:: bash salt '*' system.shutdown 5 ''' cmd = ['shutdown', '-h', ('{0}'.format(at_time) if at_time else 'now')] ret ...
Shutdown a running system at_time The wait time in minutes before the system will be shutdown. CLI Example: .. code-block:: bash salt '*' system.shutdown 5
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L112-L127
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
_date_bin_set_datetime
python
def _date_bin_set_datetime(new_date): ''' set the system date/time using the date command Note using a strictly posix-compliant date binary we can only set the date up to the minute. ''' cmd = ['date'] # if there is a timezone in the datetime object use that offset # This will modify t...
set the system date/time using the date command Note using a strictly posix-compliant date binary we can only set the date up to the minute.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L130-L169
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
has_settable_hwclock
python
def has_settable_hwclock(): ''' Returns True if the system has a hardware clock capable of being set from software. CLI Example: salt '*' system.has_settable_hwclock ''' if salt.utils.path.which_bin(['hwclock']) is not None: res = __salt__['cmd.run_all']( ['hwclock', '-...
Returns True if the system has a hardware clock capable of being set from software. CLI Example: salt '*' system.has_settable_hwclock
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L172-L187
[ "def which_bin(exes):\n '''\n Scan over some possible executables and return the first one that is found\n '''\n if not isinstance(exes, Iterable):\n return None\n for exe in exes:\n path = which(exe)\n if not path:\n continue\n return path\n return None\n" ]
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
_swclock_to_hwclock
python
def _swclock_to_hwclock(): ''' Set hardware clock to value of software clock. ''' res = __salt__['cmd.run_all'](['hwclock', '--systohc'], python_shell=False) if res['retcode'] != 0: msg = 'hwclock failed to set hardware clock from software clock: {0}'.format(res['stderr']) raise Comm...
Set hardware clock to value of software clock.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L190-L198
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
_offset_to_min
python
def _offset_to_min(utc_offset): ''' Helper function that converts the utc offset string into number of minutes offset. Input is in form "[+-]?HHMM". Example valid inputs are "+0500" "-0300" and "0800". These would return -300, 180, 480 respectively. ''' match = re.match(r"^([+-])?(\d\d)(\d\d)$",...
Helper function that converts the utc offset string into number of minutes offset. Input is in form "[+-]?HHMM". Example valid inputs are "+0500" "-0300" and "0800". These would return -300, 180, 480 respectively.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L221-L235
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
_get_offset_time
python
def _get_offset_time(utc_offset): ''' Will return the current time adjusted using the input timezone offset. :rtype datetime: ''' if utc_offset is not None: minutes = _offset_to_min(utc_offset) offset = timedelta(minutes=minutes) offset_time = datetime.utcnow() + offset ...
Will return the current time adjusted using the input timezone offset. :rtype datetime:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L238-L251
[ "def _offset_to_min(utc_offset):\n '''\n Helper function that converts the utc offset string into number of minutes\n offset. Input is in form \"[+-]?HHMM\". Example valid inputs are \"+0500\"\n \"-0300\" and \"0800\". These would return -300, 180, 480 respectively.\n '''\n match = re.match(r\"^([...
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
set_system_time
python
def set_system_time(newtime, utc_offset=None): ''' Set the system time. :param str newtime: The time to set. Can be any of the following formats. - HH:MM:SS AM/PM - HH:MM AM/PM - HH:MM:SS (24 hour) - HH:MM (24 hour) Note that the salt command line parser par...
Set the system time. :param str newtime: The time to set. Can be any of the following formats. - HH:MM:SS AM/PM - HH:MM AM/PM - HH:MM:SS (24 hour) - HH:MM (24 hour) Note that the salt command line parser parses the date/time before we obtain the argument (pr...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L276-L312
[ "def _try_parse_datetime(time_str, fmts):\n '''\n Attempts to parse the input time_str as a date.\n\n :param str time_str: A string representing the time\n :param list fmts: A list of date format strings.\n\n :return: Returns a datetime object if parsed properly. Otherwise None\n :rtype datetime:\...
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
set_system_date_time
python
def set_system_date_time(years=None, months=None, days=None, hours=None, minutes=None, seconds=None, utc_offset=None): ''' Set the system date and time. Each argu...
Set the system date and time. Each argument is an element of the date, but not required. If an element is not passed, the current system value for that element will be used. For example, if you don't pass the year, the current system year will be used. (Used by set_system_date and set_system_time) ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L337-L405
[ "def _date_bin_set_datetime(new_date):\n '''\n set the system date/time using the date command\n\n Note using a strictly posix-compliant date binary we can only set the date\n up to the minute.\n '''\n cmd = ['date']\n\n # if there is a timezone in the datetime object use that offset\n # Thi...
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
get_computer_desc
python
def get_computer_desc(): ''' Get PRETTY_HOSTNAME value stored in /etc/machine-info If this file doesn't exist or the variable doesn't exist return False. :return: Value of PRETTY_HOSTNAME if this does not exist False. :rtype: str CLI Example: .. code-block:: bash salt '*' sys...
Get PRETTY_HOSTNAME value stored in /etc/machine-info If this file doesn't exist or the variable doesn't exist return False. :return: Value of PRETTY_HOSTNAME if this does not exist False. :rtype: str CLI Example: .. code-block:: bash salt '*' system.get_computer_desc
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L496-L535
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
set_computer_desc
python
def set_computer_desc(desc): ''' Set PRETTY_HOSTNAME value stored in /etc/machine-info This will create the file if it does not exist. If it is unable to create or modify this file returns False. :param str desc: The computer description :return: False on failure. True if successful. CLI E...
Set PRETTY_HOSTNAME value stored in /etc/machine-info This will create the file if it does not exist. If it is unable to create or modify this file returns False. :param str desc: The computer description :return: False on failure. True if successful. CLI Example: .. code-block:: bash ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L538-L586
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/modules/system.py
set_reboot_required_witnessed
python
def set_reboot_required_witnessed(): ''' This function is used to remember that an event indicating that a reboot is required was witnessed. This function writes to a temporary filesystem so the event gets cleared upon reboot. Returns: bool: ``True`` if successful, otherwise ``False`` ...
This function is used to remember that an event indicating that a reboot is required was witnessed. This function writes to a temporary filesystem so the event gets cleared upon reboot. Returns: bool: ``True`` if successful, otherwise ``False`` .. code-block:: bash salt '*' system.set...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/system.py#L626-L651
null
# -*- coding: utf-8 -*- ''' Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` w...
saltstack/salt
salt/transport/ipc.py
IPCServer.handle_stream
python
def handle_stream(self, stream): ''' Override this to handle the streams as they arrive :param IOStream stream: An IOStream for processing See https://tornado.readthedocs.io/en/latest/iostream.html#tornado.iostream.IOStream for additional details. ''' @tornado.g...
Override this to handle the streams as they arrive :param IOStream stream: An IOStream for processing See https://tornado.readthedocs.io/en/latest/iostream.html#tornado.iostream.IOStream for additional details.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L150-L202
[ "def write_callback(stream, header):\n if header.get('mid'):\n @tornado.gen.coroutine\n def return_message(msg):\n pack = salt.transport.frame.frame_msg_ipc(\n msg,\n header={'mid': header['mid']},\n raw_body=True,\n )\n ...
class IPCServer(object): ''' A Tornado IPC server very similar to Tornado's TCPServer class but using either UNIX domain sockets or TCP sockets ''' def __init__(self, opts, socket_path, io_loop=None, payload_handler=None): ''' Create a new Tornado IPC server :param dict opts...
saltstack/salt
salt/transport/ipc.py
IPCServer.close
python
def close(self): ''' Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks. ''' if self._closing: return self._closing = True if hasattr(self.sock, 'close'): ...
Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L216-L226
null
class IPCServer(object): ''' A Tornado IPC server very similar to Tornado's TCPServer class but using either UNIX domain sockets or TCP sockets ''' def __init__(self, opts, socket_path, io_loop=None, payload_handler=None): ''' Create a new Tornado IPC server :param dict opts...
saltstack/salt
salt/transport/ipc.py
IPCClient.connect
python
def connect(self, callback=None, timeout=None): ''' Connect to the IPC socket ''' if hasattr(self, '_connecting_future') and not self._connecting_future.done(): # pylint: disable=E0203 future = self._connecting_future # pylint: disable=E0203 else: if has...
Connect to the IPC socket
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L308-L328
null
class IPCClient(object): ''' A Tornado IPC client very similar to Tornado's TCPClient class but using either UNIX domain sockets or TCP sockets This was written because Tornado does not have its own IPC server/client implementation. :param IOLoop io_loop: A Tornado ioloop to handle scheduling ...
saltstack/salt
salt/transport/ipc.py
IPCClient._connect
python
def _connect(self, timeout=None): ''' Connect to a running IPCServer ''' if isinstance(self.socket_path, int): sock_type = socket.AF_INET sock_addr = ('127.0.0.1', self.socket_path) else: sock_type = socket.AF_UNIX sock_addr = self....
Connect to a running IPCServer
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L331-L372
null
class IPCClient(object): ''' A Tornado IPC client very similar to Tornado's TCPClient class but using either UNIX domain sockets or TCP sockets This was written because Tornado does not have its own IPC server/client implementation. :param IOLoop io_loop: A Tornado ioloop to handle scheduling ...
saltstack/salt
salt/transport/ipc.py
IPCClient.close
python
def close(self): ''' Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks. ''' if self._closing: return if self._refcount > 1: # Decrease refcount ...
Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L391-L426
null
class IPCClient(object): ''' A Tornado IPC client very similar to Tornado's TCPClient class but using either UNIX domain sockets or TCP sockets This was written because Tornado does not have its own IPC server/client implementation. :param IOLoop io_loop: A Tornado ioloop to handle scheduling ...
saltstack/salt
salt/transport/ipc.py
IPCMessageClient.send
python
def send(self, msg, timeout=None, tries=None): ''' Send a message to an IPC socket If the socket is not currently connected, a connection will be established. :param dict msg: The message to be sent :param int timeout: Timeout when sending message (Currently unimplemented) ...
Send a message to an IPC socket If the socket is not currently connected, a connection will be established. :param dict msg: The message to be sent :param int timeout: Timeout when sending message (Currently unimplemented)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L462-L474
[ "def frame_msg_ipc(body, header=None, raw_body=False): # pylint: disable=unused-argument\n '''\n Frame the given message with our wire protocol for IPC\n\n For IPC, we don't need to be backwards compatible, so\n use the more efficient \"use_bin_type=True\" on Python 3.\n '''\n framed_msg = {}\n ...
class IPCMessageClient(IPCClient): ''' Salt IPC message client Create an IPC client to send messages to an IPC server An example of a very simple IPCMessageClient connecting to an IPCServer. This example assumes an already running IPCMessage server. IMPORTANT: The below example also assumes a...
saltstack/salt
salt/transport/ipc.py
IPCMessagePublisher.start
python
def start(self): ''' Perform the work necessary to start up a Tornado IPC server Blocks until socket is established ''' # Start up the ioloop log.trace('IPCMessagePublisher: binding to socket: %s', self.socket_path) if isinstance(self.socket_path, int): ...
Perform the work necessary to start up a Tornado IPC server Blocks until socket is established
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L540-L568
null
class IPCMessagePublisher(object): ''' A Tornado IPC Publisher similar to Tornado's TCPServer class but using either UNIX domain sockets or TCP sockets ''' def __init__(self, opts, socket_path, io_loop=None): ''' Create a new Tornado IPC server :param dict opts: Salt options ...
saltstack/salt
salt/transport/ipc.py
IPCMessagePublisher.publish
python
def publish(self, msg): ''' Send message to all connected sockets ''' if not self.streams: return pack = salt.transport.frame.frame_msg_ipc(msg, raw_body=True) for stream in self.streams: self.io_loop.spawn_callback(self._write, stream, pack)
Send message to all connected sockets
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L583-L593
[ "def frame_msg_ipc(body, header=None, raw_body=False): # pylint: disable=unused-argument\n '''\n Frame the given message with our wire protocol for IPC\n\n For IPC, we don't need to be backwards compatible, so\n use the more efficient \"use_bin_type=True\" on Python 3.\n '''\n framed_msg = {}\n ...
class IPCMessagePublisher(object): ''' A Tornado IPC Publisher similar to Tornado's TCPServer class but using either UNIX domain sockets or TCP sockets ''' def __init__(self, opts, socket_path, io_loop=None): ''' Create a new Tornado IPC server :param dict opts: Salt options ...
saltstack/salt
salt/transport/ipc.py
IPCMessagePublisher.close
python
def close(self): ''' Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks. ''' if self._closing: return self._closing = True for stream in self.streams: ...
Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L616-L629
null
class IPCMessagePublisher(object): ''' A Tornado IPC Publisher similar to Tornado's TCPServer class but using either UNIX domain sockets or TCP sockets ''' def __init__(self, opts, socket_path, io_loop=None): ''' Create a new Tornado IPC server :param dict opts: Salt options ...
saltstack/salt
salt/transport/ipc.py
IPCMessageSubscriber.read_sync
python
def read_sync(self, timeout=None): ''' Read a message from an IPC socket The socket must already be connected. The associated IO Loop must NOT be running. :param int timeout: Timeout when receiving message :return: message data if successful. None if timed out. Will rais...
Read a message from an IPC socket The socket must already be connected. The associated IO Loop must NOT be running. :param int timeout: Timeout when receiving message :return: message data if successful. None if timed out. Will raise an exception for all other error con...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L743-L763
null
class IPCMessageSubscriber(IPCClient): ''' Salt IPC message subscriber Create an IPC client to receive messages from IPC publisher An example of a very simple IPCMessageSubscriber connecting to an IPCMessagePublisher. This example assumes an already running IPCMessagePublisher. IMPORTANT: The...
saltstack/salt
salt/transport/ipc.py
IPCMessageSubscriber.read_async
python
def read_async(self): ''' Asynchronously read messages and invoke a callback when they are ready. :param callback: A callback with the received data ''' while not self.connected(): try: yield self.connect(timeout=5) except tornado.iostream...
Asynchronously read messages and invoke a callback when they are ready. :param callback: A callback with the received data
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L788-L803
[ "def connected(self):\n return self.stream is not None and not self.stream.closed()\n" ]
class IPCMessageSubscriber(IPCClient): ''' Salt IPC message subscriber Create an IPC client to receive messages from IPC publisher An example of a very simple IPCMessageSubscriber connecting to an IPCMessagePublisher. This example assumes an already running IPCMessagePublisher. IMPORTANT: The...
saltstack/salt
salt/transport/ipc.py
IPCMessageSubscriber.close
python
def close(self): ''' Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks. ''' if not self._closing: IPCClient.close(self) if self._closing: # This will...
Routines to handle any cleanup before the instance shuts down. Sockets and filehandles should be closed explicitly, to prevent leaks.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/ipc.py#L805-L820
[ "def close(self):\n '''\n Routines to handle any cleanup before the instance shuts down.\n Sockets and filehandles should be closed explicitly, to prevent\n leaks.\n '''\n if self._closing:\n return\n\n if self._refcount > 1:\n # Decrease refcount\n with self._refcount_lock...
class IPCMessageSubscriber(IPCClient): ''' Salt IPC message subscriber Create an IPC client to receive messages from IPC publisher An example of a very simple IPCMessageSubscriber connecting to an IPCMessagePublisher. This example assumes an already running IPCMessagePublisher. IMPORTANT: The...
saltstack/salt
salt/modules/schedule.py
list_
python
def list_(show_all=False, show_disabled=True, where=None, return_yaml=True): ''' List the jobs currently scheduled on the minion CLI Example: .. code-block:: bash salt '*' schedule.list # Show all jobs including hidden internal jobs salt '*' sche...
List the jobs currently scheduled on the minion CLI Example: .. code-block:: bash salt '*' schedule.list # Show all jobs including hidden internal jobs salt '*' schedule.list show_all=True # Hide disabled jobs from list of jobs salt '*' schedule.list show_disabled=Fa...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L75-L159
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
is_enabled
python
def is_enabled(name): ''' List a Job only if its enabled .. versionadded:: 2015.5.3 CLI Example: .. code-block:: bash salt '*' schedule.is_enabled name=job_name ''' current_schedule = __salt__['schedule.list'](show_all=False, return_yaml=False) if name in current_schedule: ...
List a Job only if its enabled .. versionadded:: 2015.5.3 CLI Example: .. code-block:: bash salt '*' schedule.is_enabled name=job_name
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L162-L179
null
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
purge
python
def purge(**kwargs): ''' Purge all the jobs currently scheduled on the minion CLI Example: .. code-block:: bash salt '*' schedule.purge ''' ret = {'comment': [], 'result': True} for name in list_(show_all=True, return_yaml=False): if name == 'enabled': ...
Purge all the jobs currently scheduled on the minion CLI Example: .. code-block:: bash salt '*' schedule.purge
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L182-L231
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
build_schedule_item
python
def build_schedule_item(name, **kwargs): ''' Build a schedule job CLI Example: .. code-block:: bash salt '*' schedule.build_schedule_item job1 function='test.ping' seconds=3600 ''' ret = {'comment': [], 'result': True} if not name: ret['comment'] = 'Job name i...
Build a schedule job CLI Example: .. code-block:: bash salt '*' schedule.build_schedule_item job1 function='test.ping' seconds=3600
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L286-L393
null
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
add
python
def add(name, **kwargs): ''' Add a job to the schedule CLI Example: .. code-block:: bash salt '*' schedule.add job1 function='test.ping' seconds=3600 # If function have some arguments, use job_args salt '*' schedule.add job2 function='cmd.run' job_args="['date >> /tmp/date.log...
Add a job to the schedule CLI Example: .. code-block:: bash salt '*' schedule.add job1 function='test.ping' seconds=3600 # If function have some arguments, use job_args salt '*' schedule.add job2 function='cmd.run' job_args="['date >> /tmp/date.log']" seconds=60
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L396-L468
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
modify
python
def modify(name, **kwargs): ''' Modify an existing job in the schedule CLI Example: .. code-block:: bash salt '*' schedule.modify job1 function='test.ping' seconds=3600 ''' ret = {'comment': '', 'changes': {}, 'result': True} time_conflict = False for i...
Modify an existing job in the schedule CLI Example: .. code-block:: bash salt '*' schedule.modify job1 function='test.ping' seconds=3600
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L471-L556
[ "def list_(show_all=False,\n show_disabled=True,\n where=None,\n return_yaml=True):\n '''\n List the jobs currently scheduled on the minion\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' schedule.list\n\n # Show all jobs including hidden internal jobs\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
run_job
python
def run_job(name, force=False): ''' Run a scheduled job on the minion immediately CLI Example: .. code-block:: bash salt '*' schedule.run_job job1 salt '*' schedule.run_job job1 force=True Force the job to run even if it is disabled. ''' ret = {'comment': [], ...
Run a scheduled job on the minion immediately CLI Example: .. code-block:: bash salt '*' schedule.run_job job1 salt '*' schedule.run_job job1 force=True Force the job to run even if it is disabled.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L559-L595
[ "def list_(show_all=False,\n show_disabled=True,\n where=None,\n return_yaml=True):\n '''\n List the jobs currently scheduled on the minion\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' schedule.list\n\n # Show all jobs including hidden internal jobs\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
enable_job
python
def enable_job(name, **kwargs): ''' Enable a job in the minion's schedule CLI Example: .. code-block:: bash salt '*' schedule.enable_job job1 ''' ret = {'comment': [], 'result': True} if not name: ret['comment'] = 'Job name is required.' ret['result'] ...
Enable a job in the minion's schedule CLI Example: .. code-block:: bash salt '*' schedule.enable_job job1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L598-L650
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
save
python
def save(**kwargs): ''' Save all scheduled jobs on the minion CLI Example: .. code-block:: bash salt '*' schedule.save ''' ret = {'comment': [], 'result': True} if 'test' in kwargs and kwargs['test']: ret['comment'] = 'Schedule would be saved.' else: ...
Save all scheduled jobs on the minion CLI Example: .. code-block:: bash salt '*' schedule.save
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L708-L739
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
reload_
python
def reload_(): ''' Reload saved scheduled jobs on the minion CLI Example: .. code-block:: bash salt '*' schedule.reload ''' ret = {'comment': [], 'result': True} # If there a schedule defined in pillar, refresh it. if 'schedule' in __pillar__: out = __salt...
Reload saved scheduled jobs on the minion CLI Example: .. code-block:: bash salt '*' schedule.reload
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L816-L862
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
move
python
def move(name, target, **kwargs): ''' Move scheduled job to another minion or minions. CLI Example: .. code-block:: bash salt '*' schedule.move jobname target ''' ret = {'comment': [], 'result': True} if not name: ret['comment'] = 'Job name is required.' ...
Move scheduled job to another minion or minions. CLI Example: .. code-block:: bash salt '*' schedule.move jobname target
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L865-L928
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def delete(name, **kwargs):\n '''\n Delete a job from the minion's schedule\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' schedule.delete job1\n '''\n\n ret = {'comment': 'Failed to delete job {0} from schedule.'.format(...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/modules/schedule.py
postpone_job
python
def postpone_job(name, current_time, new_time, **kwargs): ''' Postpone a job in the minion's schedule Current time and new time should be in date string format, default value is %Y-%m-%dT%H:%M:%S. .. versionadded:: 2018.3.0 CLI Example: ...
Postpone a job in the minion's schedule Current time and new time should be in date string format, default value is %Y-%m-%dT%H:%M:%S. .. versionadded:: 2018.3.0 CLI Example: .. code-block:: bash salt '*' schedule.postpone_job job current_time new_time salt '*' schedule.postpon...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/schedule.py#L994-L1096
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for managing the Salt schedule on a minion .. versionadded:: 2014.7.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import copy as pycopy import datetime import difflib import logging import os try: import dateutil.parser as ...
saltstack/salt
salt/utils/platform.py
is_proxy
python
def is_proxy(): ''' Return True if this minion is a proxy minion. Leverages the fact that is_linux() and is_windows both return False for proxies. TODO: Need to extend this for proxies that might run on other Unices ''' import __main__ as main # This is a hack. If a proxy minion is ...
Return True if this minion is a proxy minion. Leverages the fact that is_linux() and is_windows both return False for proxies. TODO: Need to extend this for proxies that might run on other Unices
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/platform.py#L24-L47
null
# -*- coding: utf-8 -*- ''' Functions for identifying which platform a machine is ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os import subprocess import sys # Import Salt libs from salt.utils.decorators import memoize as real_memoize @real_memoize def is_...
saltstack/salt
salt/utils/platform.py
is_smartos_globalzone
python
def is_smartos_globalzone(): ''' Function to return if host is SmartOS (Illumos) global zone or not ''' if not is_smartos(): return False else: cmd = ['zonename'] try: zonename = subprocess.Popen( cmd, shell=False, stdout=subprocess...
Function to return if host is SmartOS (Illumos) global zone or not
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/platform.py#L87-L106
null
# -*- coding: utf-8 -*- ''' Functions for identifying which platform a machine is ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals import os import subprocess import sys # Import Salt libs from salt.utils.decorators import memoize as real_memoize @real_memoize def is_...
saltstack/salt
salt/modules/genesis.py
bootstrap
python
def bootstrap( platform, root, img_format='dir', fs_format='ext2', fs_opts=None, arch=None, flavor=None, repo_url=None, static_qemu=None, img_size=None, mount_dir=None, pkg_cache=None, pkgs=None, exclude_pkgs...
Create an image for a specific platform. Please note that this function *MUST* be run as root, as images that are created make files belonging to root. platform Which platform to use to create the image. Currently supported platforms are rpm, deb and pacman. root Local path to...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L51-L224
[ "def to_unicode(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str or unicode, return unicode (str for python 3)\n '''\n def _normalize(s):\n return unicodedata.normalize('NFC', s) if normalize else s\n\n if encoding is None:\n # Try utf-8 first, and fall back to det...
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_mkpart
python
def _mkpart(root, fs_format, fs_opts, mount_dir): ''' Make a partition, and make it bootable .. versionadded:: Beryllium ''' __salt__['partition.mklabel'](root, 'msdos') loop1 = __salt__['cmd.run']('losetup -f') log.debug('First loop device is %s', loop1) __salt__['cmd.run']('losetup {0...
Make a partition, and make it bootable .. versionadded:: Beryllium
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L227-L261
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_mkfs
python
def _mkfs(root, fs_format, fs_opts=None): ''' Make a filesystem using the appropriate module .. versionadded:: Beryllium ''' if fs_opts is None: fs_opts = {} if fs_format in ('ext2', 'ext3', 'ext4'): __salt__['extfs.mkfs'](root, fs_format, **fs_opts) elif fs_format in ('btr...
Make a filesystem using the appropriate module .. versionadded:: Beryllium
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L264-L278
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_populate_cache
python
def _populate_cache(platform, pkg_cache, mount_dir): ''' If a ``pkg_cache`` directory is specified, then use it to populate the disk image. ''' if not pkg_cache: return if not os.path.isdir(pkg_cache): return if platform == 'pacman': cache_dir = '{0}/var/cache/pacman...
If a ``pkg_cache`` directory is specified, then use it to populate the disk image.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L281-L295
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_bootstrap_yum
python
def _bootstrap_yum( root, pkg_confs='/etc/yum*', pkgs=None, exclude_pkgs=None, epel_url=EPEL_URL, ): ''' Bootstrap an image using the yum tools root The root of the image to install to. Will be created as a directory if it does not exist. (e.x.: /...
Bootstrap an image using the yum tools root The root of the image to install to. Will be created as a directory if it does not exist. (e.x.: /root/arch) pkg_confs The location of the conf files to copy into the image, to point yum to the right repos and configuration. pkgs...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L298-L361
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_bootstrap_deb
python
def _bootstrap_deb( root, arch, flavor, repo_url=None, static_qemu=None, pkgs=None, exclude_pkgs=None, ): ''' Bootstrap an image using the Debian tools root The root of the image to install to. Will be created as a directory if it ...
Bootstrap an image using the Debian tools root The root of the image to install to. Will be created as a directory if it does not exist. (e.x.: /root/wheezy) arch Architecture of the target image. (e.x.: amd64) flavor Flavor of Debian to install. (e.x.: wheezy) repo_u...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L364-L460
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_bootstrap_pacman
python
def _bootstrap_pacman( root, pkg_confs='/etc/pacman*', img_format='dir', pkgs=None, exclude_pkgs=None, ): ''' Bootstrap an image using the pacman tools root The root of the image to install to. Will be created as a directory if it does not exist. ...
Bootstrap an image using the pacman tools root The root of the image to install to. Will be created as a directory if it does not exist. (e.x.: /root/arch) pkg_confs The location of the conf files to copy into the image, to point pacman to the right repos and configuration. ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L463-L531
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_make_nodes
python
def _make_nodes(root): ''' Make the minimum number of nodes inside of /dev/. Based on: https://wiki.archlinux.org/index.php/Linux_Containers ''' dirs = ( ('{0}/etc'.format(root), 'root', 'root', '755'), ('{0}/dev'.format(root), 'root', 'root', '755'), ('{0}/proc'.format(root...
Make the minimum number of nodes inside of /dev/. Based on: https://wiki.archlinux.org/index.php/Linux_Containers
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L534-L565
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
avail_platforms
python
def avail_platforms(): ''' Return which platforms are available CLI Example: .. code-block:: bash salt myminion genesis.avail_platforms ''' ret = {} for platform in CMD_MAP: ret[platform] = True for cmd in CMD_MAP[platform]: if not salt.utils.path.which...
Return which platforms are available CLI Example: .. code-block:: bash salt myminion genesis.avail_platforms
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L568-L584
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
pack
python
def pack(name, root, path=None, pack_format='tar', compress='bzip2'): ''' Pack up a directory structure, into a specific format CLI Examples: .. code-block:: bash salt myminion genesis.pack centos /root/centos salt myminion genesis.pack centos /root/centos pack_format='tar' ''' ...
Pack up a directory structure, into a specific format CLI Examples: .. code-block:: bash salt myminion genesis.pack centos /root/centos salt myminion genesis.pack centos /root/centos pack_format='tar'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L587-L599
[ "def _tar(name, root, path=None, compress='bzip2'):\n '''\n Pack up image in a tar format\n '''\n if path is None:\n path = os.path.join(salt.syspaths.BASE_FILE_ROOTS_DIR, 'img')\n if not __salt__['file.directory_exists'](path):\n try:\n __salt__['file.mkdir'](path)\n ...
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
unpack
python
def unpack(name, dest=None, path=None, pack_format='tar', compress='bz2'): ''' Unpack an image into a directory structure CLI Example: .. code-block:: bash salt myminion genesis.unpack centos /root/centos ''' if pack_format == 'tar': _untar(name, dest, path, compress)
Unpack an image into a directory structure CLI Example: .. code-block:: bash salt myminion genesis.unpack centos /root/centos
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L602-L613
[ "def _untar(name, dest=None, path=None, compress='bz2'):\n '''\n Unpack a tarball to be used as a container\n '''\n if path is None:\n path = os.path.join(salt.syspaths.BASE_FILE_ROOTS_DIR, 'img')\n\n if not dest:\n dest = path\n\n if not __salt__['file.directory_exists'](dest):\n ...
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_tar
python
def _tar(name, root, path=None, compress='bzip2'): ''' Pack up image in a tar format ''' if path is None: path = os.path.join(salt.syspaths.BASE_FILE_ROOTS_DIR, 'img') if not __salt__['file.directory_exists'](path): try: __salt__['file.mkdir'](path) except Excepti...
Pack up image in a tar format
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L616-L636
[ "def to_unicode(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str or unicode, return unicode (str for python 3)\n '''\n def _normalize(s):\n return unicodedata.normalize('NFC', s) if normalize else s\n\n if encoding is None:\n # Try utf-8 first, and fall back to det...
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
_compress
python
def _compress(compress): ''' Resolve compression flags ''' if compress in ('bz2', 'bzip2', 'j'): compression = 'j' ext = 'bz2' elif compress in ('gz', 'gzip', 'z'): compression = 'z' ext = 'gz' elif compress in ('xz', 'a', 'J'): compression = 'J' e...
Resolve compression flags
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L665-L679
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
ldd_deps
python
def ldd_deps(filename, ret=None): ''' Recurse through a set of dependencies reported by ``ldd``, to find associated dependencies. Please note that this does not necessarily resolve all (non-package) dependencies for a file; but it does help. CLI Example: salt myminion genesis.ldd_deps...
Recurse through a set of dependencies reported by ``ldd``, to find associated dependencies. Please note that this does not necessarily resolve all (non-package) dependencies for a file; but it does help. CLI Example: salt myminion genesis.ldd_deps bash salt myminion genesis.ldd_deps /...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L682-L724
null
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/genesis.py
mksls
python
def mksls(fmt, src, dst=None): ''' Convert an installation file/script to an SLS file. Currently supports ``kickstart``, ``preseed``, and ``autoyast``. CLI Examples: salt <minion> genesis.mksls kickstart /path/to/kickstart.cfg salt <minion> genesis.mksls kickstart /path/to/kickstart.cf...
Convert an installation file/script to an SLS file. Currently supports ``kickstart``, ``preseed``, and ``autoyast``. CLI Examples: salt <minion> genesis.mksls kickstart /path/to/kickstart.cfg salt <minion> genesis.mksls kickstart /path/to/kickstart.cfg /path/to/dest.sls .. versionadded:: ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/genesis.py#L727-L744
[ "def mksls(src, dst=None):\n '''\n Convert a preseed file to an SLS file\n '''\n ps_opts = {}\n with salt.utils.files.fopen(src, 'r') as fh_:\n for line in fh_:\n line = salt.utils.stringutils.to_unicode(line)\n if line.startswith('#'):\n continue\n ...
# -*- coding: utf-8 -*- ''' Module for managing container and VM images .. versionadded:: 2014.7.0 ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import uuid import pprint import logging try: from shlex import quote as _cmd_quote # pylint: disable=E061...
saltstack/salt
salt/modules/win_psget.py
_pshell
python
def _pshell(cmd, cwd=None, json_depth=2): ''' Execute the desired powershell command and ensure that it returns data in json format and load that into python ''' if 'convertto-json' not in cmd.lower(): cmd = '{0} | ConvertTo-Json -Depth {1}'.format(cmd, json_depth) log.debug('DSC: %s', c...
Execute the desired powershell command and ensure that it returns data in json format and load that into python
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L53-L75
[ "def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
avail_modules
python
def avail_modules(desc=False): ''' List available modules in registered Powershell module repositories. :param desc: If ``True``, the verbose description will be returned. :type desc: ``bool`` CLI Example: .. code-block:: bash salt 'win01' psget.avail_modules salt 'win01' ps...
List available modules in registered Powershell module repositories. :param desc: If ``True``, the verbose description will be returned. :type desc: ``bool`` CLI Example: .. code-block:: bash salt 'win01' psget.avail_modules salt 'win01' psget.avail_modules desc=True
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L94-L118
[ "def _pshell(cmd, cwd=None, json_depth=2):\n '''\n Execute the desired powershell command and ensure that it returns data\n in json format and load that into python\n '''\n if 'convertto-json' not in cmd.lower():\n cmd = '{0} | ConvertTo-Json -Depth {1}'.format(cmd, json_depth)\n log.debug(...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
list_modules
python
def list_modules(desc=False): ''' List currently installed PSGet Modules on the system. :param desc: If ``True``, the verbose description will be returned. :type desc: ``bool`` CLI Example: .. code-block:: bash salt 'win01' psget.list_modules salt 'win01' psget.list_modules ...
List currently installed PSGet Modules on the system. :param desc: If ``True``, the verbose description will be returned. :type desc: ``bool`` CLI Example: .. code-block:: bash salt 'win01' psget.list_modules salt 'win01' psget.list_modules desc=True
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L121-L154
[ "def _pshell(cmd, cwd=None, json_depth=2):\n '''\n Execute the desired powershell command and ensure that it returns data\n in json format and load that into python\n '''\n if 'convertto-json' not in cmd.lower():\n cmd = '{0} | ConvertTo-Json -Depth {1}'.format(cmd, json_depth)\n log.debug(...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
install
python
def install(name, minimum_version=None, required_version=None, scope=None, repository=None): ''' Install a Powershell module from powershell gallery on the system. :param name: Name of a Powershell module :type name: ``str`` :param minimum_version: The maximum version to install, e.g....
Install a Powershell module from powershell gallery on the system. :param name: Name of a Powershell module :type name: ``str`` :param minimum_version: The maximum version to install, e.g. 1.23.2 :type minimum_version: ``str`` :param required_version: Install a specific version :type requi...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L157-L199
[ "def list_modules(desc=False):\n '''\n List currently installed PSGet Modules on the system.\n\n :param desc: If ``True``, the verbose description will be returned.\n :type desc: ``bool``\n\n CLI Example:\n\n .. code-block:: bash\n\n salt 'win01' psget.list_modules\n salt 'win01' ps...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
update
python
def update(name, maximum_version=None, required_version=None): ''' Update a PowerShell module to a specific version, or the newest :param name: Name of a Powershell module :type name: ``str`` :param maximum_version: The maximum version to install, e.g. 1.23.2 :type maximum_version: ``str`` ...
Update a PowerShell module to a specific version, or the newest :param name: Name of a Powershell module :type name: ``str`` :param maximum_version: The maximum version to install, e.g. 1.23.2 :type maximum_version: ``str`` :param required_version: Install a specific version :type required...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L202-L234
[ "def list_modules(desc=False):\n '''\n List currently installed PSGet Modules on the system.\n\n :param desc: If ``True``, the verbose description will be returned.\n :type desc: ``bool``\n\n CLI Example:\n\n .. code-block:: bash\n\n salt 'win01' psget.list_modules\n salt 'win01' ps...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
remove
python
def remove(name): ''' Remove a Powershell DSC module from the system. :param name: Name of a Powershell DSC module :type name: ``str`` CLI Example: .. code-block:: bash salt 'win01' psget.remove PowerPlan ''' # Putting quotes around the parameter protects against command i...
Remove a Powershell DSC module from the system. :param name: Name of a Powershell DSC module :type name: ``str`` CLI Example: .. code-block:: bash salt 'win01' psget.remove PowerPlan
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L237-L253
[ "def list_modules(desc=False):\n '''\n List currently installed PSGet Modules on the system.\n\n :param desc: If ``True``, the verbose description will be returned.\n :type desc: ``bool``\n\n CLI Example:\n\n .. code-block:: bash\n\n salt 'win01' psget.list_modules\n salt 'win01' ps...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
register_repository
python
def register_repository(name, location, installation_policy=None): ''' Register a PSGet repository on the local machine :param name: The name for the repository :type name: ``str`` :param location: The URI for the repository :type location: ``str`` :param installation_policy: The instal...
Register a PSGet repository on the local machine :param name: The name for the repository :type name: ``str`` :param location: The URI for the repository :type location: ``str`` :param installation_policy: The installation policy for packages, e.g. Trusted, Untrusted :type installa...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L256-L288
[ "def list_modules(desc=False):\n '''\n List currently installed PSGet Modules on the system.\n\n :param desc: If ``True``, the verbose description will be returned.\n :type desc: ``bool``\n\n CLI Example:\n\n .. code-block:: bash\n\n salt 'win01' psget.list_modules\n salt 'win01' ps...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/modules/win_psget.py
get_repository
python
def get_repository(name): ''' Get the details of a local PSGet repository :param name: Name of the repository :type name: ``str`` CLI Example: .. code-block:: bash salt 'win01' psget.get_repository MyRepo ''' # Putting quotes around the parameter protects against command i...
Get the details of a local PSGet repository :param name: Name of the repository :type name: ``str`` CLI Example: .. code-block:: bash salt 'win01' psget.get_repository MyRepo
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_psget.py#L291-L307
[ "def list_modules(desc=False):\n '''\n List currently installed PSGet Modules on the system.\n\n :param desc: If ``True``, the verbose description will be returned.\n :type desc: ``bool``\n\n CLI Example:\n\n .. code-block:: bash\n\n salt 'win01' psget.list_modules\n salt 'win01' ps...
# -*- coding: utf-8 -*- ''' Module for managing PowerShell through PowerShellGet (PSGet) :depends: - PowerShell 5.0 - PSGet Support for PowerShell ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import copy import logging # Import Salt libs import salt.utils...
saltstack/salt
salt/states/lxc.py
present
python
def present(name, running=None, clone_from=None, snapshot=False, profile=None, network_profile=None, template=None, options=None, image=None, config=None, fstype=None, size=None, ...
.. versionchanged:: 2015.8.0 The :mod:`lxc.created <salt.states.lxc.created>` state has been renamed to ``lxc.present``, and the :mod:`lxc.cloned <salt.states.lxc.cloned>` state has been merged into this state. Create the named container if it does not exist name The name of t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxc.py#L15-L330
null
# -*- coding: utf-8 -*- ''' Manage Linux Containers ======================= ''' from __future__ import absolute_import, print_function, unicode_literals __docformat__ = 'restructuredtext en' # Import salt libs from salt.exceptions import CommandExecutionError, SaltInvocationError # Container existence/non-existence...
saltstack/salt
salt/states/lxc.py
absent
python
def absent(name, stop=False, path=None): ''' Ensure a container is not present, destroying it if present name Name of the container to destroy stop stop before destroying default: false .. versionadded:: 2015.5.2 path path to the container parent d...
Ensure a container is not present, destroying it if present name Name of the container to destroy stop stop before destroying default: false .. versionadded:: 2015.5.2 path path to the container parent default: /var/lib/lxc (system default) .. ver...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxc.py#L333-L379
null
# -*- coding: utf-8 -*- ''' Manage Linux Containers ======================= ''' from __future__ import absolute_import, print_function, unicode_literals __docformat__ = 'restructuredtext en' # Import salt libs from salt.exceptions import CommandExecutionError, SaltInvocationError # Container existence/non-existence...
saltstack/salt
salt/states/lxc.py
running
python
def running(name, restart=False, path=None): ''' .. versionchanged:: 2015.5.0 The :mod:`lxc.started <salt.states.lxc.started>` state has been renamed to ``lxc.running`` Ensure that a container is running .. note:: This state does not enforce the existence of the named containe...
.. versionchanged:: 2015.5.0 The :mod:`lxc.started <salt.states.lxc.started>` state has been renamed to ``lxc.running`` Ensure that a container is running .. note:: This state does not enforce the existence of the named container, it just starts the container if it is not runn...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxc.py#L383-L480
null
# -*- coding: utf-8 -*- ''' Manage Linux Containers ======================= ''' from __future__ import absolute_import, print_function, unicode_literals __docformat__ = 'restructuredtext en' # Import salt libs from salt.exceptions import CommandExecutionError, SaltInvocationError # Container existence/non-existence...
saltstack/salt
salt/states/lxc.py
stopped
python
def stopped(name, kill=False, path=None): ''' Ensure that a container is stopped .. note:: This state does not enforce the existence of the named container, it just stops the container if it running or frozen. To ensure that the named container exists, use :mod:`lxc.present ...
Ensure that a container is stopped .. note:: This state does not enforce the existence of the named container, it just stops the container if it running or frozen. To ensure that the named container exists, use :mod:`lxc.present <salt.states.lxc.present>`, or use the :mod:`lxc.abse...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxc.py#L570-L646
null
# -*- coding: utf-8 -*- ''' Manage Linux Containers ======================= ''' from __future__ import absolute_import, print_function, unicode_literals __docformat__ = 'restructuredtext en' # Import salt libs from salt.exceptions import CommandExecutionError, SaltInvocationError # Container existence/non-existence...
saltstack/salt
salt/states/lxc.py
edited_conf
python
def edited_conf(name, lxc_conf=None, lxc_conf_unset=None): ''' .. warning:: This state is unsuitable for setting parameters that appear more than once in an LXC config file, or parameters which must appear in a certain order (such as when configuring more than one network interf...
.. warning:: This state is unsuitable for setting parameters that appear more than once in an LXC config file, or parameters which must appear in a certain order (such as when configuring more than one network interface). `Issue #35523`_ was opened to track the addition of a su...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lxc.py#L676-L725
null
# -*- coding: utf-8 -*- ''' Manage Linux Containers ======================= ''' from __future__ import absolute_import, print_function, unicode_literals __docformat__ = 'restructuredtext en' # Import salt libs from salt.exceptions import CommandExecutionError, SaltInvocationError # Container existence/non-existence...
saltstack/salt
salt/runners/thin.py
generate
python
def generate(extra_mods='', overwrite=False, so_mods='', python2_bin='python2', python3_bin='python3', absonly=True, compress='gzip'): ''' Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma...
Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma delimited string. Permits forcing an overwrite of the output file as well. CLI Example: .. code-block:: bash salt-run thin.generate salt-run...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/thin.py#L17-L45
[ "def gen_thin(cachedir, extra_mods='', overwrite=False, so_mods='',\n python2_bin='python2', python3_bin='python3', absonly=True,\n compress='gzip', extended_cfg=None):\n '''\n Generate the salt-thin tarball and print the location of the tarball\n Optional additional mods to include...
# -*- coding: utf-8 -*- ''' The thin runner is used to manage the salt thin systems. Salt Thin is a transport-less version of Salt that can be used to run routines in a standalone way. This runner has tools which generate the standalone salt system for easy consumption. ''' # Import python libs from __future__ import...
saltstack/salt
salt/runners/thin.py
generate_min
python
def generate_min(extra_mods='', overwrite=False, so_mods='', python2_bin='python2', python3_bin='python3'): ''' Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma delimited string. Permits forcing ...
Generate the salt-thin tarball and print the location of the tarball Optional additional mods to include (e.g. mako) can be supplied as a comma delimited string. Permits forcing an overwrite of the output file as well. CLI Example: .. code-block:: bash salt-run thin.generate_min
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/thin.py#L48-L70
[ "def gen_min(cachedir, extra_mods='', overwrite=False, so_mods='',\n python2_bin='python2', python3_bin='python3'):\n '''\n Generate the salt-min tarball and print the location of the tarball\n Optional additional mods to include (e.g. mako) can be supplied as a comma\n delimited string. Per...
# -*- coding: utf-8 -*- ''' The thin runner is used to manage the salt thin systems. Salt Thin is a transport-less version of Salt that can be used to run routines in a standalone way. This runner has tools which generate the standalone salt system for easy consumption. ''' # Import python libs from __future__ import...
saltstack/salt
salt/auth/rest.py
auth
python
def auth(username, password): ''' REST authentication ''' url = rest_auth_setup() data = {'username': username, 'password': password} # Post to the API endpoint. If 200 is returned then the result will be the ACLs # for this user result = salt.utils.http.query(url, method='POST', data...
REST authentication
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/auth/rest.py#L50-L70
[ "def rest_auth_setup():\n\n if '^url' in __opts__['external_auth']['rest']:\n return __opts__['external_auth']['rest']['^url']\n else:\n return False\n" ]
# -*- coding: utf-8 -*- ''' Provide authentication using a REST call REST auth can be defined like any other eauth module: .. code-block:: yaml external_auth: rest: ^url: https://url/for/rest/call fred: - .* - '@runner' If there are entries underneath the ^url entry the...
saltstack/salt
salt/states/github.py
present
python
def present(name, profile="github", **kwargs): ''' Ensure a user is present .. code-block:: yaml ensure user test is present in github: github.present: - name: 'gitexample' The following parameters are required: name This is the github handle of the us...
Ensure a user is present .. code-block:: yaml ensure user test is present in github: github.present: - name: 'gitexample' The following parameters are required: name This is the github handle of the user in the organization
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/github.py#L40-L93
null
# -*- coding: utf-8 -*- ''' Github User State Module .. versionadded:: 2016.3.0. This state is used to ensure presence of users in the Organization. .. code-block:: yaml ensure user test is present in github: github.present: - name: 'Example TestUser1' - email: example@domain.com...
saltstack/salt
salt/states/github.py
absent
python
def absent(name, profile="github", **kwargs): ''' Ensure a github user is absent .. code-block:: yaml ensure user test is absent in github: github.absent: - name: 'Example TestUser1' - email: example@domain.com - username: 'gitexample' ...
Ensure a github user is absent .. code-block:: yaml ensure user test is absent in github: github.absent: - name: 'Example TestUser1' - email: example@domain.com - username: 'gitexample' The following parameters are required: name ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/github.py#L96-L151
null
# -*- coding: utf-8 -*- ''' Github User State Module .. versionadded:: 2016.3.0. This state is used to ensure presence of users in the Organization. .. code-block:: yaml ensure user test is present in github: github.present: - name: 'Example TestUser1' - email: example@domain.com...
saltstack/salt
salt/states/github.py
team_present
python
def team_present( name, description=None, repo_names=None, privacy='secret', permission='pull', members=None, enforce_mfa=False, no_mfa_grace_seconds=0, profile="github", **kwargs): ''' Ensure a team is present name Thi...
Ensure a team is present name This is the name of the team in the organization. description The description of the team. repo_names The names of repositories to add the team to. privacy The level of privacy for the team, can be 'secret' or 'closed'. Defaults t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/github.py#L154-L413
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _member_violates_mfa(member, member_info, mfa_deadline, members_without_mfa):\n if member_info.get('mfa_exempt', False):\n return False\n enforce_mfa_from = datetime.datetime.strptime(\n member_info.get('enforce_mfa_from', '1970/0...
# -*- coding: utf-8 -*- ''' Github User State Module .. versionadded:: 2016.3.0. This state is used to ensure presence of users in the Organization. .. code-block:: yaml ensure user test is present in github: github.present: - name: 'Example TestUser1' - email: example@domain.com...
saltstack/salt
salt/states/github.py
team_absent
python
def team_absent(name, profile="github", **kwargs): ''' Ensure a team is absent. Example: .. code-block:: yaml ensure team test is present in github: github.team_absent: - name: 'test' The following parameters are required: name This is the name o...
Ensure a team is absent. Example: .. code-block:: yaml ensure team test is present in github: github.team_absent: - name: 'test' The following parameters are required: name This is the name of the team in the organization. .. versionadded:: 2016.11....
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/github.py#L424-L473
null
# -*- coding: utf-8 -*- ''' Github User State Module .. versionadded:: 2016.3.0. This state is used to ensure presence of users in the Organization. .. code-block:: yaml ensure user test is present in github: github.present: - name: 'Example TestUser1' - email: example@domain.com...
saltstack/salt
salt/states/github.py
repo_present
python
def repo_present( name, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, auto_init=False, gitignore_template=None, license_template=None, teams=None, profile="github", ...
Ensure a repository is present name This is the name of the repository. description The description of the repository. homepage The URL with more information about the repository. private The visiblity of the repository. Note that private repositories require ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/github.py#L476-L728
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Github User State Module .. versionadded:: 2016.3.0. This state is used to ensure presence of users in the Organization. .. code-block:: yaml ensure user test is present in github: github.present: - name: 'Example TestUser1' - email: example@domain.com...
saltstack/salt
salt/roster/dir.py
targets
python
def targets(tgt, tgt_type='glob', **kwargs): ''' Return the targets from the directory of flat yaml files, checks opts for location. ''' roster_dir = __opts__.get('roster_dir', '/etc/salt/roster.d') # Match the targets before rendering to avoid opening files unnecessarily. raw = dict.fromkey...
Return the targets from the directory of flat yaml files, checks opts for location.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/roster/dir.py#L63-L79
null
# -*- coding: utf-8 -*- ''' Create a salt roster out of a flat directory of files. Each filename in the directory is a minion id. The contents of each file is rendered using the salt renderer system. Consider the following configuration for example: config/master: ... roster: dir roster_dir: config/rost...
saltstack/salt
salt/roster/dir.py
_render
python
def _render(roster_file, **kwargs): renderers = salt.loader.render(__opts__, {}) domain = __opts__.get('roster_domain', '') try: result = salt.template.compile_template(roster_file, renderers, __opts__['r...
Render the roster file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/roster/dir.py#L82-L100
[ "def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n input_data='',\n **kwargs):\n '''\n Ta...
# -*- coding: utf-8 -*- ''' Create a salt roster out of a flat directory of files. Each filename in the directory is a minion id. The contents of each file is rendered using the salt renderer system. Consider the following configuration for example: config/master: ... roster: dir roster_dir: config/rost...
saltstack/salt
salt/modules/disk.py
_parse_numbers
python
def _parse_numbers(text): ''' Convert a string to a number, allowing for a K|M|G|T postfix, 32.8K. Returns a decimal number if the string is a real number, or the string unchanged otherwise. ''' if text.isdigit(): return decimal.Decimal(text) try: postPrefixes = {'K': '10E3'...
Convert a string to a number, allowing for a K|M|G|T postfix, 32.8K. Returns a decimal number if the string is a real number, or the string unchanged otherwise.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/disk.py#L45-L63
null
# -*- coding: utf-8 -*- ''' Module for managing disks and blockdevices ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import logging import os import subprocess import re import collections import decimal # Import 3rd-party libs from salt.ext import six from salt.ext...
saltstack/salt
salt/modules/disk.py
_clean_flags
python
def _clean_flags(args, caller): ''' Sanitize flags passed into df ''' flags = '' if args is None: return flags allowed = ('a', 'B', 'h', 'H', 'i', 'k', 'l', 'P', 't', 'T', 'x', 'v') for flag in args: if flag in allowed: flags += flag else: rais...
Sanitize flags passed into df
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/disk.py#L66-L81
null
# -*- coding: utf-8 -*- ''' Module for managing disks and blockdevices ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import logging import os import subprocess import re import collections import decimal # Import 3rd-party libs from salt.ext import six from salt.ext...
saltstack/salt
salt/modules/disk.py
usage
python
def usage(args=None): ''' Return usage information for volumes mounted on this minion .. versionchanged:: 2019.2.0 Default for SunOS changed to 1 kilobyte blocks CLI Example: .. code-block:: bash salt '*' disk.usage ''' flags = _clean_flags(args, 'disk.usage') if not...
Return usage information for volumes mounted on this minion .. versionchanged:: 2019.2.0 Default for SunOS changed to 1 kilobyte blocks CLI Example: .. code-block:: bash salt '*' disk.usage
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/disk.py#L84-L160
[ "def _clean_flags(args, caller):\n '''\n Sanitize flags passed into df\n '''\n flags = ''\n if args is None:\n return flags\n allowed = ('a', 'B', 'h', 'H', 'i', 'k', 'l', 'P', 't', 'T', 'x', 'v')\n for flag in args:\n if flag in allowed:\n flags += flag\n else:\...
# -*- coding: utf-8 -*- ''' Module for managing disks and blockdevices ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import logging import os import subprocess import re import collections import decimal # Import 3rd-party libs from salt.ext import six from salt.ext...
saltstack/salt
salt/modules/disk.py
inodeusage
python
def inodeusage(args=None): ''' Return inode usage information for volumes mounted on this minion CLI Example: .. code-block:: bash salt '*' disk.inodeusage ''' flags = _clean_flags(args, 'disk.inodeusage') if __grains__['kernel'] == 'AIX': cmd = 'df -i' else: c...
Return inode usage information for volumes mounted on this minion CLI Example: .. code-block:: bash salt '*' disk.inodeusage
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/disk.py#L163-L218
[ "def _clean_flags(args, caller):\n '''\n Sanitize flags passed into df\n '''\n flags = ''\n if args is None:\n return flags\n allowed = ('a', 'B', 'h', 'H', 'i', 'k', 'l', 'P', 't', 'T', 'x', 'v')\n for flag in args:\n if flag in allowed:\n flags += flag\n else:\...
# -*- coding: utf-8 -*- ''' Module for managing disks and blockdevices ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import logging import os import subprocess import re import collections import decimal # Import 3rd-party libs from salt.ext import six from salt.ext...
saltstack/salt
salt/modules/disk.py
percent
python
def percent(args=None): ''' Return partition information for volumes mounted on this minion CLI Example: .. code-block:: bash salt '*' disk.percent /var ''' if __grains__['kernel'] == 'Linux': cmd = 'df -P' elif __grains__['kernel'] == 'OpenBSD' or __grains__['kernel'] == ...
Return partition information for volumes mounted on this minion CLI Example: .. code-block:: bash salt '*' disk.percent /var
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/disk.py#L221-L267
null
# -*- coding: utf-8 -*- ''' Module for managing disks and blockdevices ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import logging import os import subprocess import re import collections import decimal # Import 3rd-party libs from salt.ext import six from salt.ext...