partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
__apf_cmd
Return the apf location
salt/modules/apf.py
def __apf_cmd(cmd): ''' Return the apf location ''' apf_cmd = '{0} {1}'.format(salt.utils.path.which('apf'), cmd) out = __salt__['cmd.run_all'](apf_cmd) if out['retcode'] != 0: if not out['stderr']: msg = out['stdout'] else: msg = out['stderr'] ra...
def __apf_cmd(cmd): ''' Return the apf location ''' apf_cmd = '{0} {1}'.format(salt.utils.path.which('apf'), cmd) out = __salt__['cmd.run_all'](apf_cmd) if out['retcode'] != 0: if not out['stderr']: msg = out['stdout'] else: msg = out['stderr'] ra...
[ "Return", "the", "apf", "location" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apf.py#L39-L54
[ "def", "__apf_cmd", "(", "cmd", ")", ":", "apf_cmd", "=", "'{0} {1}'", ".", "format", "(", "salt", ".", "utils", ".", "path", ".", "which", "(", "'apf'", ")", ",", "cmd", ")", "out", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "apf_cmd", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_status_apf
Return True if apf is running otherwise return False
salt/modules/apf.py
def _status_apf(): ''' Return True if apf is running otherwise return False ''' status = 0 table = iptc.Table(iptc.Table.FILTER) for chain in table.chains: if 'sanity' in chain.name.lower(): status = 1 return True if status else False
def _status_apf(): ''' Return True if apf is running otherwise return False ''' status = 0 table = iptc.Table(iptc.Table.FILTER) for chain in table.chains: if 'sanity' in chain.name.lower(): status = 1 return True if status else False
[ "Return", "True", "if", "apf", "is", "running", "otherwise", "return", "False" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/apf.py#L57-L66
[ "def", "_status_apf", "(", ")", ":", "status", "=", "0", "table", "=", "iptc", ".", "Table", "(", "iptc", ".", "Table", ".", "FILTER", ")", "for", "chain", "in", "table", ".", "chains", ":", "if", "'sanity'", "in", "chain", ".", "name", ".", "lower...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
did_composer_install
Test to see if the vendor directory exists in this directory dir Directory location of the composer.json file CLI Example: .. code-block:: bash salt '*' composer.did_composer_install /var/www/application
salt/modules/composer.py
def did_composer_install(dir): ''' Test to see if the vendor directory exists in this directory dir Directory location of the composer.json file CLI Example: .. code-block:: bash salt '*' composer.did_composer_install /var/www/application ''' lockFile = "{0}/vendor".forma...
def did_composer_install(dir): ''' Test to see if the vendor directory exists in this directory dir Directory location of the composer.json file CLI Example: .. code-block:: bash salt '*' composer.did_composer_install /var/www/application ''' lockFile = "{0}/vendor".forma...
[ "Test", "to", "see", "if", "the", "vendor", "directory", "exists", "in", "this", "directory" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/composer.py#L44-L60
[ "def", "did_composer_install", "(", "dir", ")", ":", "lockFile", "=", "\"{0}/vendor\"", ".", "format", "(", "dir", ")", "if", "os", ".", "path", ".", "exists", "(", "lockFile", ")", ":", "return", "True", "return", "False" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_run_composer
Run PHP's composer with a specific action. If composer has not been installed globally making it available in the system PATH & making it executable, the ``composer`` and ``php`` parameters will need to be set to the location of the executables. action The action to pass to composer ('install'...
salt/modules/composer.py
def _run_composer(action, directory=None, composer=None, php=None, runas=None, prefer_source=None, prefer_dist=None, no_scripts=None, no_plugins=None, optimiz...
def _run_composer(action, directory=None, composer=None, php=None, runas=None, prefer_source=None, prefer_dist=None, no_scripts=None, no_plugins=None, optimiz...
[ "Run", "PHP", "s", "composer", "with", "a", "specific", "action", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/composer.py#L63-L209
[ "def", "_run_composer", "(", "action", ",", "directory", "=", "None", ",", "composer", "=", "None", ",", "php", "=", "None", ",", "runas", "=", "None", ",", "prefer_source", "=", "None", ",", "prefer_dist", "=", "None", ",", "no_scripts", "=", "None", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
install
Install composer dependencies for a directory. If composer has not been installed globally making it available in the system PATH & making it executable, the ``composer`` and ``php`` parameters will need to be set to the location of the executables. directory Directory location of the composer...
salt/modules/composer.py
def install(directory, composer=None, php=None, runas=None, prefer_source=None, prefer_dist=None, no_scripts=None, no_plugins=None, optimize=None, no_dev=None, quiet=False, composer_home='...
def install(directory, composer=None, php=None, runas=None, prefer_source=None, prefer_dist=None, no_scripts=None, no_plugins=None, optimize=None, no_dev=None, quiet=False, composer_home='...
[ "Install", "composer", "dependencies", "for", "a", "directory", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/composer.py#L212-L297
[ "def", "install", "(", "directory", ",", "composer", "=", "None", ",", "php", "=", "None", ",", "runas", "=", "None", ",", "prefer_source", "=", "None", ",", "prefer_dist", "=", "None", ",", "no_scripts", "=", "None", ",", "no_plugins", "=", "None", ",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
selfupdate
Update composer itself. If composer has not been installed globally making it available in the system PATH & making it executable, the ``composer`` and ``php`` parameters will need to be set to the location of the executables. composer Location of the composer.phar file. If not set composer wi...
salt/modules/composer.py
def selfupdate(composer=None, php=None, runas=None, quiet=False, composer_home='/root'): ''' Update composer itself. If composer has not been installed globally making it available in the system PATH & making it executable, the ``composer`` and ``php`` pa...
def selfupdate(composer=None, php=None, runas=None, quiet=False, composer_home='/root'): ''' Update composer itself. If composer has not been installed globally making it available in the system PATH & making it executable, the ``composer`` and ``php`` pa...
[ "Update", "composer", "itself", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/composer.py#L392-L435
[ "def", "selfupdate", "(", "composer", "=", "None", ",", "php", "=", "None", ",", "runas", "=", "None", ",", "quiet", "=", "False", ",", "composer_home", "=", "'/root'", ")", ":", "result", "=", "_run_composer", "(", "'selfupdate'", ",", "extra_flags", "=...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
sync_all
Sync all custom types saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelist : None dictionary of modules to sync based on type extmod_blacklist : None dictionary of modules to bla...
salt/runners/saltutil.py
def sync_all(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' Sync all custom types saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelist : None dictionary of modules...
def sync_all(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' Sync all custom types saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelist : None dictionary of modules...
[ "Sync", "all", "custom", "types" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/saltutil.py#L20-L68
[ "def", "sync_all", "(", "saltenv", "=", "'base'", ",", "extmod_whitelist", "=", "None", ",", "extmod_blacklist", "=", "None", ")", ":", "log", ".", "debug", "(", "'Syncing all'", ")", "ret", "=", "{", "}", "ret", "[", "'clouds'", "]", "=", "sync_clouds",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
sync_auth
Sync execution modules from ``salt://_auth`` to the master saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelist : None comma-separated list of modules to sync extmod_blacklist : None ...
salt/runners/saltutil.py
def sync_auth(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' Sync execution modules from ``salt://_auth`` to the master saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelis...
def sync_auth(saltenv='base', extmod_whitelist=None, extmod_blacklist=None): ''' Sync execution modules from ``salt://_auth`` to the master saltenv : base The fileserver environment from which to sync. To sync from more than one environment, pass a comma-separated list. extmod_whitelis...
[ "Sync", "execution", "modules", "from", "salt", ":", "//", "_auth", "to", "the", "master" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/saltutil.py#L71-L92
[ "def", "sync_auth", "(", "saltenv", "=", "'base'", ",", "extmod_whitelist", "=", "None", ",", "extmod_blacklist", "=", "None", ")", ":", "return", "salt", ".", "utils", ".", "extmods", ".", "sync", "(", "__opts__", ",", "'auth'", ",", "saltenv", "=", "sa...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
avail_images
Return available Packet os images. CLI Example: .. code-block:: bash salt-cloud --list-images packet-provider salt-cloud -f avail_images packet-provider
salt/cloud/clouds/packet.py
def avail_images(call=None): ''' Return available Packet os images. CLI Example: .. code-block:: bash salt-cloud --list-images packet-provider salt-cloud -f avail_images packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_images fu...
def avail_images(call=None): ''' Return available Packet os images. CLI Example: .. code-block:: bash salt-cloud --list-images packet-provider salt-cloud -f avail_images packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_images fu...
[ "Return", "available", "Packet", "os", "images", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L117-L143
[ "def", "avail_images", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudException", "(", "'The avail_images function must be called with -f or --function.'", ")", "ret", "=", "{", "}", "vm_", "=", "get_configured_provider", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
avail_locations
Return available Packet datacenter locations. CLI Example: .. code-block:: bash salt-cloud --list-locations packet-provider salt-cloud -f avail_locations packet-provider
salt/cloud/clouds/packet.py
def avail_locations(call=None): ''' Return available Packet datacenter locations. CLI Example: .. code-block:: bash salt-cloud --list-locations packet-provider salt-cloud -f avail_locations packet-provider ''' if call == 'action': raise SaltCloudException( ...
def avail_locations(call=None): ''' Return available Packet datacenter locations. CLI Example: .. code-block:: bash salt-cloud --list-locations packet-provider salt-cloud -f avail_locations packet-provider ''' if call == 'action': raise SaltCloudException( ...
[ "Return", "available", "Packet", "datacenter", "locations", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L146-L170
[ "def", "avail_locations", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudException", "(", "'The avail_locations function must be called with -f or --function.'", ")", "vm_", "=", "get_configured_provider", "(", ")", "manager"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
avail_sizes
Return available Packet sizes. CLI Example: .. code-block:: bash salt-cloud --list-sizes packet-provider salt-cloud -f avail_sizes packet-provider
salt/cloud/clouds/packet.py
def avail_sizes(call=None): ''' Return available Packet sizes. CLI Example: .. code-block:: bash salt-cloud --list-sizes packet-provider salt-cloud -f avail_sizes packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_locations functi...
def avail_sizes(call=None): ''' Return available Packet sizes. CLI Example: .. code-block:: bash salt-cloud --list-sizes packet-provider salt-cloud -f avail_sizes packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_locations functi...
[ "Return", "available", "Packet", "sizes", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L173-L198
[ "def", "avail_sizes", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudException", "(", "'The avail_locations function must be called with -f or --function.'", ")", "vm_", "=", "get_configured_provider", "(", ")", "manager", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
avail_projects
Return available Packet projects. CLI Example: .. code-block:: bash salt-cloud -f avail_projects packet-provider
salt/cloud/clouds/packet.py
def avail_projects(call=None): ''' Return available Packet projects. CLI Example: .. code-block:: bash salt-cloud -f avail_projects packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_projects function must be called with -f or --function....
def avail_projects(call=None): ''' Return available Packet projects. CLI Example: .. code-block:: bash salt-cloud -f avail_projects packet-provider ''' if call == 'action': raise SaltCloudException( 'The avail_projects function must be called with -f or --function....
[ "Return", "available", "Packet", "projects", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L201-L224
[ "def", "avail_projects", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudException", "(", "'The avail_projects function must be called with -f or --function.'", ")", "vm_", "=", "get_configured_provider", "(", ")", "manager", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_wait_for_status
Wait for a certain status from Packet. status_type device or volume object_id The ID of the Packet device or volume to wait on. Required. status The status to wait for. timeout The amount of time to wait for a status to update. quiet Log status updates to debu...
salt/cloud/clouds/packet.py
def _wait_for_status(status_type, object_id, status=None, timeout=500, quiet=True): ''' Wait for a certain status from Packet. status_type device or volume object_id The ID of the Packet device or volume to wait on. Required. status The status to wait for. timeout ...
def _wait_for_status(status_type, object_id, status=None, timeout=500, quiet=True): ''' Wait for a certain status from Packet. status_type device or volume object_id The ID of the Packet device or volume to wait on. Required. status The status to wait for. timeout ...
[ "Wait", "for", "a", "certain", "status", "from", "Packet", ".", "status_type", "device", "or", "volume", "object_id", "The", "ID", "of", "the", "Packet", "device", "or", "volume", "to", "wait", "on", ".", "Required", ".", "status", "The", "status", "to", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L227-L264
[ "def", "_wait_for_status", "(", "status_type", ",", "object_id", ",", "status", "=", "None", ",", "timeout", "=", "500", ",", "quiet", "=", "True", ")", ":", "if", "status", "is", "None", ":", "status", "=", "\"ok\"", "interval", "=", "5", "iterations", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create
Create a single Packet VM.
salt/cloud/clouds/packet.py
def create(vm_): ''' Create a single Packet VM. ''' name = vm_['name'] if not is_profile_configured(vm_): return False __utils__['cloud.fire_event']( 'event', 'starting create', 'salt/cloud/{0}/creating'.format(name), args=__utils__['cloud.filter_event']...
def create(vm_): ''' Create a single Packet VM. ''' name = vm_['name'] if not is_profile_configured(vm_): return False __utils__['cloud.fire_event']( 'event', 'starting create', 'salt/cloud/{0}/creating'.format(name), args=__utils__['cloud.filter_event']...
[ "Create", "a", "single", "Packet", "VM", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L324-L434
[ "def", "create", "(", "vm_", ")", ":", "name", "=", "vm_", "[", "'name'", "]", "if", "not", "is_profile_configured", "(", "vm_", ")", ":", "return", "False", "__utils__", "[", "'cloud.fire_event'", "]", "(", "'event'", ",", "'starting create'", ",", "'salt...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_nodes_full
List devices, with all available information. CLI Example: .. code-block:: bash salt-cloud -F salt-cloud --full-query salt-cloud -f list_nodes_full packet-provider ..
salt/cloud/clouds/packet.py
def list_nodes_full(call=None): ''' List devices, with all available information. CLI Example: .. code-block:: bash salt-cloud -F salt-cloud --full-query salt-cloud -f list_nodes_full packet-provider .. ''' if call == 'action': raise SaltCloudException( ...
def list_nodes_full(call=None): ''' List devices, with all available information. CLI Example: .. code-block:: bash salt-cloud -F salt-cloud --full-query salt-cloud -f list_nodes_full packet-provider .. ''' if call == 'action': raise SaltCloudException( ...
[ "List", "devices", "with", "all", "available", "information", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L437-L461
[ "def", "list_nodes_full", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudException", "(", "'The list_nodes_full function must be called with -f or --function.'", ")", "ret", "=", "{", "}", "for", "device", "in", "get_devi...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_nodes_min
Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f list_nodes_min packet-provider ...
salt/cloud/clouds/packet.py
def list_nodes_min(call=None): ''' Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt...
def list_nodes_min(call=None): ''' Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt...
[ "Return", "a", "list", "of", "the", "VMs", "that", "are", "on", "the", "provider", ".", "Only", "a", "list", "of", "VM", "names", "and", "their", "state", "is", "returned", ".", "This", "is", "the", "minimum", "amount", "of", "information", "needed", "...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L464-L489
[ "def", "list_nodes_min", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The list_nodes_min function must be called with -f or --function.'", ")", "ret", "=", "{", "}", "for", "device", "in", "get_devic...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_nodes
Returns a list of devices, keeping only a brief listing. CLI Example: .. code-block:: bash salt-cloud -Q salt-cloud --query salt-cloud -f list_nodes packet-provider ..
salt/cloud/clouds/packet.py
def list_nodes(call=None): ''' Returns a list of devices, keeping only a brief listing. CLI Example: .. code-block:: bash salt-cloud -Q salt-cloud --query salt-cloud -f list_nodes packet-provider .. ''' if call == 'action': raise SaltCloudException( ...
def list_nodes(call=None): ''' Returns a list of devices, keeping only a brief listing. CLI Example: .. code-block:: bash salt-cloud -Q salt-cloud --query salt-cloud -f list_nodes packet-provider .. ''' if call == 'action': raise SaltCloudException( ...
[ "Returns", "a", "list", "of", "devices", "keeping", "only", "a", "brief", "listing", ".", "CLI", "Example", ":", "..", "code", "-", "block", "::", "bash", "salt", "-", "cloud", "-", "Q", "salt", "-", "cloud", "--", "query", "salt", "-", "cloud", "-",...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L515-L536
[ "def", "list_nodes", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudException", "(", "'The list_nodes function must be called with -f or --function.'", ")", "ret", "=", "{", "}", "for", "device", "in", "get_devices_by_tok...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
destroy
Destroys a Packet device by name. name The hostname of VM to be be destroyed. CLI Example: .. code-block:: bash salt-cloud -d name
salt/cloud/clouds/packet.py
def destroy(name, call=None): ''' Destroys a Packet device by name. name The hostname of VM to be be destroyed. CLI Example: .. code-block:: bash salt-cloud -d name ''' if call == 'function': raise SaltCloudException( 'The destroy action must be called...
def destroy(name, call=None): ''' Destroys a Packet device by name. name The hostname of VM to be be destroyed. CLI Example: .. code-block:: bash salt-cloud -d name ''' if call == 'function': raise SaltCloudException( 'The destroy action must be called...
[ "Destroys", "a", "Packet", "device", "by", "name", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L539-L593
[ "def", "destroy", "(", "name", ",", "call", "=", "None", ")", ":", "if", "call", "==", "'function'", ":", "raise", "SaltCloudException", "(", "'The destroy action must be called with -d, --destroy, '", "'-a or --action.'", ")", "__utils__", "[", "'cloud.fire_event'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
beacon
Poll imgadm and compare available images
salt/beacons/smartos_imgadm.py
def beacon(config): ''' Poll imgadm and compare available images ''' ret = [] # NOTE: lookup current images current_images = __salt__['imgadm.list'](verbose=True) # NOTE: apply configuration if IMGADM_STATE['first_run']: log.info('Applying configuration for imgadm beacon') ...
def beacon(config): ''' Poll imgadm and compare available images ''' ret = [] # NOTE: lookup current images current_images = __salt__['imgadm.list'](verbose=True) # NOTE: apply configuration if IMGADM_STATE['first_run']: log.info('Applying configuration for imgadm beacon') ...
[ "Poll", "imgadm", "and", "compare", "available", "images" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/smartos_imgadm.py#L69-L117
[ "def", "beacon", "(", "config", ")", ":", "ret", "=", "[", "]", "# NOTE: lookup current images", "current_images", "=", "__salt__", "[", "'imgadm.list'", "]", "(", "verbose", "=", "True", ")", "# NOTE: apply configuration", "if", "IMGADM_STATE", "[", "'first_run'"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
mock_decorator_with_params
Optionally mock a decorator that takes parameters E.g.: @blah(stuff=True) def things(): pass
doc/conf.py
def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument ''' Optionally mock a decorator that takes parameters E.g.: @blah(stuff=True) def things(): pass ''' def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument if hasattr(fn, '__...
def mock_decorator_with_params(*oargs, **okwargs): # pylint: disable=unused-argument ''' Optionally mock a decorator that takes parameters E.g.: @blah(stuff=True) def things(): pass ''' def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument if hasattr(fn, '__...
[ "Optionally", "mock", "a", "decorator", "that", "takes", "parameters" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/doc/conf.py#L63-L77
[ "def", "mock_decorator_with_params", "(", "*", "oargs", ",", "*", "*", "okwargs", ")", ":", "# pylint: disable=unused-argument", "def", "inner", "(", "fn", ",", "*", "iargs", ",", "*", "*", "ikwargs", ")", ":", "# pylint: disable=unused-argument", "if", "hasattr...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
absent
Ensures that the named command is not running. name The pattern to match. user The user to which the process belongs signal Signal to send to the process(es).
salt/states/process.py
def absent(name, user=None, signal=None): ''' Ensures that the named command is not running. name The pattern to match. user The user to which the process belongs signal Signal to send to the process(es). ''' ret = {'name': name, 'changes': {}, ...
def absent(name, user=None, signal=None): ''' Ensures that the named command is not running. name The pattern to match. user The user to which the process belongs signal Signal to send to the process(es). ''' ret = {'name': name, 'changes': {}, ...
[ "Ensures", "that", "the", "named", "command", "is", "not", "running", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/process.py#L21-L61
[ "def", "absent", "(", "name", ",", "user", "=", "None", ",", "signal", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", "}", "if", "__opts_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ext_pillar
Query NetBox API for minion data
salt/pillar/netbox.py
def ext_pillar(minion_id, pillar, *args, **kwargs): ''' Query NetBox API for minion data ''' if minion_id == '*': log.info('There\'s no data to collect from NetBox for the Master') return {} # Pull settings from kwargs api_url = kwargs['api_url'].rstrip('/') api_token = kwarg...
def ext_pillar(minion_id, pillar, *args, **kwargs): ''' Query NetBox API for minion data ''' if minion_id == '*': log.info('There\'s no data to collect from NetBox for the Master') return {} # Pull settings from kwargs api_url = kwargs['api_url'].rstrip('/') api_token = kwarg...
[ "Query", "NetBox", "API", "for", "minion", "data" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/netbox.py#L61-L172
[ "def", "ext_pillar", "(", "minion_id", ",", "pillar", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "minion_id", "==", "'*'", ":", "log", ".", "info", "(", "'There\\'s no data to collect from NetBox for the Master'", ")", "return", "{", "}", "# ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
top
Run the command configured
salt/tops/ext_nodes.py
def top(**kwargs): ''' Run the command configured ''' if 'id' not in kwargs['opts']: return {} cmd = '{0} {1}'.format( __opts__['master_tops']['ext_nodes'], kwargs['opts']['id'] ) ndata = salt.utils.yaml.safe_load( subprocess.Popen( ...
def top(**kwargs): ''' Run the command configured ''' if 'id' not in kwargs['opts']: return {} cmd = '{0} {1}'.format( __opts__['master_tops']['ext_nodes'], kwargs['opts']['id'] ) ndata = salt.utils.yaml.safe_load( subprocess.Popen( ...
[ "Run", "the", "command", "configured" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/tops/ext_nodes.py#L69-L103
[ "def", "top", "(", "*", "*", "kwargs", ")", ":", "if", "'id'", "not", "in", "kwargs", "[", "'opts'", "]", ":", "return", "{", "}", "cmd", "=", "'{0} {1}'", ".", "format", "(", "__opts__", "[", "'master_tops'", "]", "[", "'ext_nodes'", "]", ",", "kw...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_check_current_value
Check the current value with the passed value
salt/states/gnomedesktop.py
def _check_current_value(gnome_kwargs, value): ''' Check the current value with the passed value ''' current_value = __salt__['gnome.get'](**gnome_kwargs) return six.text_type(current_value) == six.text_type(value)
def _check_current_value(gnome_kwargs, value): ''' Check the current value with the passed value ''' current_value = __salt__['gnome.get'](**gnome_kwargs) return six.text_type(current_value) == six.text_type(value)
[ "Check", "the", "current", "value", "with", "the", "passed", "value" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L38-L43
[ "def", "_check_current_value", "(", "gnome_kwargs", ",", "value", ")", ":", "current_value", "=", "__salt__", "[", "'gnome.get'", "]", "(", "*", "*", "gnome_kwargs", ")", "return", "six", ".", "text_type", "(", "current_value", ")", "==", "six", ".", "text_t...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_do
worker function for the others to use this handles all the gsetting magic
salt/states/gnomedesktop.py
def _do(name, gnome_kwargs, preferences): ''' worker function for the others to use this handles all the gsetting magic ''' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} messages = [] for pref in preferences: key = pref ...
def _do(name, gnome_kwargs, preferences): ''' worker function for the others to use this handles all the gsetting magic ''' ret = {'name': name, 'result': True, 'changes': {}, 'comment': ''} messages = [] for pref in preferences: key = pref ...
[ "worker", "function", "for", "the", "others", "to", "use", "this", "handles", "all", "the", "gsetting", "magic" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L46-L92
[ "def", "_do", "(", "name", ",", "gnome_kwargs", ",", "preferences", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "''", "}", "messages", "=", "[", "]", "for",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
wm_preferences
wm_preferences: sets values in the org.gnome.desktop.wm.preferences schema
salt/states/gnomedesktop.py
def wm_preferences(name, user=None, action_double_click_titlebar=None, action_middle_click_titlebar=None, action_right_click_titlebar=None, application_based=None, audible_bell=None, auto...
def wm_preferences(name, user=None, action_double_click_titlebar=None, action_middle_click_titlebar=None, action_right_click_titlebar=None, application_based=None, audible_bell=None, auto...
[ "wm_preferences", ":", "sets", "values", "in", "the", "org", ".", "gnome", ".", "desktop", ".", "wm", ".", "preferences", "schema" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L95-L142
[ "def", "wm_preferences", "(", "name", ",", "user", "=", "None", ",", "action_double_click_titlebar", "=", "None", ",", "action_middle_click_titlebar", "=", "None", ",", "action_right_click_titlebar", "=", "None", ",", "application_based", "=", "None", ",", "audible_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
desktop_lockdown
desktop_lockdown: sets values in the org.gnome.desktop.lockdown schema
salt/states/gnomedesktop.py
def desktop_lockdown(name, user=None, disable_application_handlers=None, disable_command_line=None, disable_lock_screen=None, disable_log_out=None, disable_print_setup=None, ...
def desktop_lockdown(name, user=None, disable_application_handlers=None, disable_command_line=None, disable_lock_screen=None, disable_log_out=None, disable_print_setup=None, ...
[ "desktop_lockdown", ":", "sets", "values", "in", "the", "org", ".", "gnome", ".", "desktop", ".", "lockdown", "schema" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L145-L176
[ "def", "desktop_lockdown", "(", "name", ",", "user", "=", "None", ",", "disable_application_handlers", "=", "None", ",", "disable_command_line", "=", "None", ",", "disable_lock_screen", "=", "None", ",", "disable_log_out", "=", "None", ",", "disable_print_setup", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
desktop_interface
desktop_interface: sets values in the org.gnome.desktop.interface schema
salt/states/gnomedesktop.py
def desktop_interface(name, user=None, automatic_mnemonics=None, buttons_have_icons=None, can_change_accels=None, clock_format=None, clock_show_date=None, clock_show_...
def desktop_interface(name, user=None, automatic_mnemonics=None, buttons_have_icons=None, can_change_accels=None, clock_format=None, clock_show_date=None, clock_show_...
[ "desktop_interface", ":", "sets", "values", "in", "the", "org", ".", "gnome", ".", "desktop", ".", "interface", "schema" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/gnomedesktop.py#L179-L246
[ "def", "desktop_interface", "(", "name", ",", "user", "=", "None", ",", "automatic_mnemonics", "=", "None", ",", "buttons_have_icons", "=", "None", ",", "can_change_accels", "=", "None", ",", "clock_format", "=", "None", ",", "clock_show_date", "=", "None", ",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
deserialize
Deserialize from TOML into Python data structure. :param stream_or_string: toml stream or string to deserialize. :param options: options given to lower pytoml module.
salt/serializers/toml.py
def deserialize(stream_or_string, **options): ''' Deserialize from TOML into Python data structure. :param stream_or_string: toml stream or string to deserialize. :param options: options given to lower pytoml module. ''' try: if not isinstance(stream_or_string, (bytes, six.string_types...
def deserialize(stream_or_string, **options): ''' Deserialize from TOML into Python data structure. :param stream_or_string: toml stream or string to deserialize. :param options: options given to lower pytoml module. ''' try: if not isinstance(stream_or_string, (bytes, six.string_types...
[ "Deserialize", "from", "TOML", "into", "Python", "data", "structure", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/toml.py#L29-L46
[ "def", "deserialize", "(", "stream_or_string", ",", "*", "*", "options", ")", ":", "try", ":", "if", "not", "isinstance", "(", "stream_or_string", ",", "(", "bytes", ",", "six", ".", "string_types", ")", ")", ":", "return", "toml", ".", "load", "(", "s...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
serialize
Serialize Python data to TOML. :param obj: the data structure to serialize. :param options: options given to lower pytoml module.
salt/serializers/toml.py
def serialize(obj, **options): ''' Serialize Python data to TOML. :param obj: the data structure to serialize. :param options: options given to lower pytoml module. ''' try: if 'file_out' in options: return toml.dump(obj, options['file_out'], **options) else: ...
def serialize(obj, **options): ''' Serialize Python data to TOML. :param obj: the data structure to serialize. :param options: options given to lower pytoml module. ''' try: if 'file_out' in options: return toml.dump(obj, options['file_out'], **options) else: ...
[ "Serialize", "Python", "data", "to", "TOML", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/serializers/toml.py#L49-L63
[ "def", "serialize", "(", "obj", ",", "*", "*", "options", ")", ":", "try", ":", "if", "'file_out'", "in", "options", ":", "return", "toml", ".", "dump", "(", "obj", ",", "options", "[", "'file_out'", "]", ",", "*", "*", "options", ")", "else", ":",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
render
Render the template_file, passing the functions and grains into the Mako rendering system. :rtype: string
salt/renderers/mako.py
def render(template_file, saltenv='base', sls='', context=None, tmplpath=None, **kws): ''' Render the template_file, passing the functions and grains into the Mako rendering system. :rtype: string ''' tmp_data = salt.utils.templates.MAKO(template_file, to_str=True, salt=__sa...
def render(template_file, saltenv='base', sls='', context=None, tmplpath=None, **kws): ''' Render the template_file, passing the functions and grains into the Mako rendering system. :rtype: string ''' tmp_data = salt.utils.templates.MAKO(template_file, to_str=True, salt=__sa...
[ "Render", "the", "template_file", "passing", "the", "functions", "and", "grains", "into", "the", "Mako", "rendering", "system", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/mako.py#L15-L35
[ "def", "render", "(", "template_file", ",", "saltenv", "=", "'base'", ",", "sls", "=", "''", ",", "context", "=", "None", ",", "tmplpath", "=", "None", ",", "*", "*", "kws", ")", ":", "tmp_data", "=", "salt", ".", "utils", ".", "templates", ".", "M...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
init
This function gets called when the proxy starts up. We check opts to see if a fallback user and password are supplied. If they are present, and the primary credentials don't work, then we try the backup before failing. Whichever set of credentials works is placed in the persistent DETAILS dictionar...
salt/proxy/fx2.py
def init(opts): ''' This function gets called when the proxy starts up. We check opts to see if a fallback user and password are supplied. If they are present, and the primary credentials don't work, then we try the backup before failing. Whichever set of credentials works is placed in the pers...
def init(opts): ''' This function gets called when the proxy starts up. We check opts to see if a fallback user and password are supplied. If they are present, and the primary credentials don't work, then we try the backup before failing. Whichever set of credentials works is placed in the pers...
[ "This", "function", "gets", "called", "when", "the", "proxy", "starts", "up", ".", "We", "check", "opts", "to", "see", "if", "a", "fallback", "user", "and", "password", "are", "supplied", ".", "If", "they", "are", "present", "and", "the", "primary", "cre...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L203-L220
[ "def", "init", "(", "opts", ")", ":", "if", "'host'", "not", "in", "opts", "[", "'proxy'", "]", ":", "log", ".", "critical", "(", "'No \"host\" key found in pillar for this proxy'", ")", "return", "False", "DETAILS", "[", "'host'", "]", "=", "opts", "[", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_grains
Get the grains from the proxied device
salt/proxy/fx2.py
def _grains(host, user, password): ''' Get the grains from the proxied device ''' r = __salt__['dracr.system_info'](host=host, admin_username=user, admin_password=password) if r.get('retcode', 0) == 0: GRAINS_CACHE =...
def _grains(host, user, password): ''' Get the grains from the proxied device ''' r = __salt__['dracr.system_info'](host=host, admin_username=user, admin_password=password) if r.get('retcode', 0) == 0: GRAINS_CACHE =...
[ "Get", "the", "grains", "from", "the", "proxied", "device" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L247-L258
[ "def", "_grains", "(", "host", ",", "user", ",", "password", ")", ":", "r", "=", "__salt__", "[", "'dracr.system_info'", "]", "(", "host", "=", "host", ",", "admin_username", "=", "user", ",", "admin_password", "=", "password", ")", "if", "r", ".", "ge...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
find_credentials
Cycle through all the possible credentials and return the first one that works
salt/proxy/fx2.py
def find_credentials(): ''' Cycle through all the possible credentials and return the first one that works ''' usernames = [__pillar__['proxy'].get('admin_username', 'root')] if 'fallback_admin_username' in __pillar__.get('proxy'): usernames.append(__pillar__['proxy'].get('fallback_admin...
def find_credentials(): ''' Cycle through all the possible credentials and return the first one that works ''' usernames = [__pillar__['proxy'].get('admin_username', 'root')] if 'fallback_admin_username' in __pillar__.get('proxy'): usernames.append(__pillar__['proxy'].get('fallback_admin...
[ "Cycle", "through", "all", "the", "possible", "credentials", "and", "return", "the", "first", "one", "that", "works" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L281-L313
[ "def", "find_credentials", "(", ")", ":", "usernames", "=", "[", "__pillar__", "[", "'proxy'", "]", ".", "get", "(", "'admin_username'", ",", "'root'", ")", "]", "if", "'fallback_admin_username'", "in", "__pillar__", ".", "get", "(", "'proxy'", ")", ":", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
chconfig
This function is called by the :mod:`salt.modules.chassis.cmd <salt.modules.chassis.cmd>` shim. It then calls whatever is passed in ``cmd`` inside the :mod:`salt.modules.dracr <salt.modules.dracr>` module. :param cmd: The command to call inside salt.modules.dracr :param args: Arguments that need t...
salt/proxy/fx2.py
def chconfig(cmd, *args, **kwargs): ''' This function is called by the :mod:`salt.modules.chassis.cmd <salt.modules.chassis.cmd>` shim. It then calls whatever is passed in ``cmd`` inside the :mod:`salt.modules.dracr <salt.modules.dracr>` module. :param cmd: The command to call inside salt.modu...
def chconfig(cmd, *args, **kwargs): ''' This function is called by the :mod:`salt.modules.chassis.cmd <salt.modules.chassis.cmd>` shim. It then calls whatever is passed in ``cmd`` inside the :mod:`salt.modules.dracr <salt.modules.dracr>` module. :param cmd: The command to call inside salt.modu...
[ "This", "function", "is", "called", "by", "the", ":", "mod", ":", "salt", ".", "modules", ".", "chassis", ".", "cmd", "<salt", ".", "modules", ".", "chassis", ".", "cmd", ">", "shim", ".", "It", "then", "calls", "whatever", "is", "passed", "in", "cmd...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L316-L348
[ "def", "chconfig", "(", "cmd", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Strip the __pub_ keys...is there a better way to do this?", "for", "k", "in", "list", "(", "kwargs", ")", ":", "if", "k", ".", "startswith", "(", "'__pub_'", ")", ":", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ping
Is the chassis responding? :return: Returns False if the chassis didn't respond, True otherwise.
salt/proxy/fx2.py
def ping(): ''' Is the chassis responding? :return: Returns False if the chassis didn't respond, True otherwise. ''' r = __salt__['dracr.system_info'](host=DETAILS['host'], admin_username=DETAILS['admin_username'], admin_p...
def ping(): ''' Is the chassis responding? :return: Returns False if the chassis didn't respond, True otherwise. ''' r = __salt__['dracr.system_info'](host=DETAILS['host'], admin_username=DETAILS['admin_username'], admin_p...
[ "Is", "the", "chassis", "responding?" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/fx2.py#L351-L368
[ "def", "ping", "(", ")", ":", "r", "=", "__salt__", "[", "'dracr.system_info'", "]", "(", "host", "=", "DETAILS", "[", "'host'", "]", ",", "admin_username", "=", "DETAILS", "[", "'admin_username'", "]", ",", "admin_password", "=", "DETAILS", "[", "'admin_p...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
store
Store a key value.
salt/cache/consul.py
def store(bank, key, data): ''' Store a key value. ''' c_key = '{0}/{1}'.format(bank, key) try: c_data = __context__['serial'].dumps(data) api.kv.put(c_key, c_data) except Exception as exc: raise SaltCacheError( 'There was an error writing the key, {0}: {1}'.f...
def store(bank, key, data): ''' Store a key value. ''' c_key = '{0}/{1}'.format(bank, key) try: c_data = __context__['serial'].dumps(data) api.kv.put(c_key, c_data) except Exception as exc: raise SaltCacheError( 'There was an error writing the key, {0}: {1}'.f...
[ "Store", "a", "key", "value", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/consul.py#L95-L108
[ "def", "store", "(", "bank", ",", "key", ",", "data", ")", ":", "c_key", "=", "'{0}/{1}'", ".", "format", "(", "bank", ",", "key", ")", "try", ":", "c_data", "=", "__context__", "[", "'serial'", "]", ".", "dumps", "(", "data", ")", "api", ".", "k...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
fetch
Fetch a key value.
salt/cache/consul.py
def fetch(bank, key): ''' Fetch a key value. ''' c_key = '{0}/{1}'.format(bank, key) try: _, value = api.kv.get(c_key) if value is None: return {} return __context__['serial'].loads(value['Value']) except Exception as exc: raise SaltCacheError( ...
def fetch(bank, key): ''' Fetch a key value. ''' c_key = '{0}/{1}'.format(bank, key) try: _, value = api.kv.get(c_key) if value is None: return {} return __context__['serial'].loads(value['Value']) except Exception as exc: raise SaltCacheError( ...
[ "Fetch", "a", "key", "value", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/consul.py#L111-L126
[ "def", "fetch", "(", "bank", ",", "key", ")", ":", "c_key", "=", "'{0}/{1}'", ".", "format", "(", "bank", ",", "key", ")", "try", ":", "_", ",", "value", "=", "api", ".", "kv", ".", "get", "(", "c_key", ")", "if", "value", "is", "None", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
flush
Remove the key from the cache bank with all the key content.
salt/cache/consul.py
def flush(bank, key=None): ''' Remove the key from the cache bank with all the key content. ''' if key is None: c_key = bank else: c_key = '{0}/{1}'.format(bank, key) try: return api.kv.delete(c_key, recurse=key is None) except Exception as exc: raise SaltCach...
def flush(bank, key=None): ''' Remove the key from the cache bank with all the key content. ''' if key is None: c_key = bank else: c_key = '{0}/{1}'.format(bank, key) try: return api.kv.delete(c_key, recurse=key is None) except Exception as exc: raise SaltCach...
[ "Remove", "the", "key", "from", "the", "cache", "bank", "with", "all", "the", "key", "content", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/consul.py#L129-L144
[ "def", "flush", "(", "bank", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "c_key", "=", "bank", "else", ":", "c_key", "=", "'{0}/{1}'", ".", "format", "(", "bank", ",", "key", ")", "try", ":", "return", "api", ".", "kv", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_
Return an iterable object containing all entries stored in the specified bank.
salt/cache/consul.py
def list_(bank): ''' Return an iterable object containing all entries stored in the specified bank. ''' try: _, keys = api.kv.get(bank + '/', keys=True, separator='/') except Exception as exc: raise SaltCacheError( 'There was an error getting the key "{0}": {1}'.format( ...
def list_(bank): ''' Return an iterable object containing all entries stored in the specified bank. ''' try: _, keys = api.kv.get(bank + '/', keys=True, separator='/') except Exception as exc: raise SaltCacheError( 'There was an error getting the key "{0}": {1}'.format( ...
[ "Return", "an", "iterable", "object", "containing", "all", "entries", "stored", "in", "the", "specified", "bank", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/consul.py#L147-L168
[ "def", "list_", "(", "bank", ")", ":", "try", ":", "_", ",", "keys", "=", "api", ".", "kv", ".", "get", "(", "bank", "+", "'/'", ",", "keys", "=", "True", ",", "separator", "=", "'/'", ")", "except", "Exception", "as", "exc", ":", "raise", "Sal...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
contains
Checks if the specified bank contains the specified key.
salt/cache/consul.py
def contains(bank, key): ''' Checks if the specified bank contains the specified key. ''' if key is None: return True # any key could be a branch and a leaf at the same time in Consul else: try: c_key = '{0}/{1}'.format(bank, key) _, value = api.kv.get(c_key)...
def contains(bank, key): ''' Checks if the specified bank contains the specified key. ''' if key is None: return True # any key could be a branch and a leaf at the same time in Consul else: try: c_key = '{0}/{1}'.format(bank, key) _, value = api.kv.get(c_key)...
[ "Checks", "if", "the", "specified", "bank", "contains", "the", "specified", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/consul.py#L171-L187
[ "def", "contains", "(", "bank", ",", "key", ")", ":", "if", "key", "is", "None", ":", "return", "True", "# any key could be a branch and a leaf at the same time in Consul", "else", ":", "try", ":", "c_key", "=", "'{0}/{1}'", ".", "format", "(", "bank", ",", "k...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set_pixel
Sets a single pixel on the LED matrix to a specified color. x The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right. y The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom. color The new color of the pixel as a list of ``[R, G, B]`` values....
salt/modules/sensehat.py
def set_pixel(x, y, color): ''' Sets a single pixel on the LED matrix to a specified color. x The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right. y The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom. color The new color of the ...
def set_pixel(x, y, color): ''' Sets a single pixel on the LED matrix to a specified color. x The x coordinate of the pixel. Ranges from 0 on the left to 7 on the right. y The y coordinate of the pixel. Ranges from 0 at the top to 7 at the bottom. color The new color of the ...
[ "Sets", "a", "single", "pixel", "on", "the", "LED", "matrix", "to", "a", "specified", "color", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L89-L107
[ "def", "set_pixel", "(", "x", ",", "y", ",", "color", ")", ":", "_sensehat", ".", "set_pixel", "(", "x", ",", "y", ",", "color", ")", "return", "{", "'color'", ":", "color", "}" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
show_message
Displays a message on the LED matrix. message The message to display msg_type The type of the message. Changes the appearance of the message. Available types are:: error: red text warning: orange text success: green text info:...
salt/modules/sensehat.py
def show_message(message, msg_type=None, text_color=None, back_color=None, scroll_speed=0.1): ''' Displays a message on the LED matrix. message The message to display msg_type The type of the message. Changes the appearance of the message. Available types are:: ...
def show_message(message, msg_type=None, text_color=None, back_color=None, scroll_speed=0.1): ''' Displays a message on the LED matrix. message The message to display msg_type The type of the message. Changes the appearance of the message. Available types are:: ...
[ "Displays", "a", "message", "on", "the", "LED", "matrix", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L140-L189
[ "def", "show_message", "(", "message", ",", "msg_type", "=", "None", ",", "text_color", "=", "None", ",", "back_color", "=", "None", ",", "scroll_speed", "=", "0.1", ")", ":", "text_color", "=", "text_color", "or", "[", "255", ",", "255", ",", "255", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
show_letter
Displays a single letter on the LED matrix. letter The letter to display text_color The color in which the letter is shown. Defaults to '[255, 255, 255]' (white). back_color The background color of the display. Defaults to '[0, 0, 0]' (black). CLI Example: .. code-block:: ...
salt/modules/sensehat.py
def show_letter(letter, text_color=None, back_color=None): ''' Displays a single letter on the LED matrix. letter The letter to display text_color The color in which the letter is shown. Defaults to '[255, 255, 255]' (white). back_color The background color of the display. D...
def show_letter(letter, text_color=None, back_color=None): ''' Displays a single letter on the LED matrix. letter The letter to display text_color The color in which the letter is shown. Defaults to '[255, 255, 255]' (white). back_color The background color of the display. D...
[ "Displays", "a", "single", "letter", "on", "the", "LED", "matrix", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/sensehat.py#L192-L215
[ "def", "show_letter", "(", "letter", ",", "text_color", "=", "None", ",", "back_color", "=", "None", ")", ":", "text_color", "=", "text_color", "or", "[", "255", ",", "255", ",", "255", "]", "back_color", "=", "back_color", "or", "[", "0", ",", "0", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_add
POST a payload
salt/modules/netbox.py
def _add(app, endpoint, payload): ''' POST a payload ''' nb = _nb_obj(auth_required=True) try: return getattr(getattr(nb, app), endpoint).create(**payload) except RequestError as e: log.error('%s, %s, %s', e.req.request.headers, e.request_body, e.error) return False
def _add(app, endpoint, payload): ''' POST a payload ''' nb = _nb_obj(auth_required=True) try: return getattr(getattr(nb, app), endpoint).create(**payload) except RequestError as e: log.error('%s, %s, %s', e.req.request.headers, e.request_body, e.error) return False
[ "POST", "a", "payload" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L98-L107
[ "def", "_add", "(", "app", ",", "endpoint", ",", "payload", ")", ":", "nb", "=", "_nb_obj", "(", "auth_required", "=", "True", ")", "try", ":", "return", "getattr", "(", "getattr", "(", "nb", ",", "app", ")", ",", "endpoint", ")", ".", "create", "(...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
slugify
Slugify given value. Credit to Djangoproject https://docs.djangoproject.com/en/2.0/_modules/django/utils/text/#slugify
salt/modules/netbox.py
def slugify(value): '''' Slugify given value. Credit to Djangoproject https://docs.djangoproject.com/en/2.0/_modules/django/utils/text/#slugify ''' value = re.sub(r'[^\w\s-]', '', value).strip().lower() return re.sub(r'[-\s]+', '-', value)
def slugify(value): '''' Slugify given value. Credit to Djangoproject https://docs.djangoproject.com/en/2.0/_modules/django/utils/text/#slugify ''' value = re.sub(r'[^\w\s-]', '', value).strip().lower() return re.sub(r'[-\s]+', '-', value)
[ "Slugify", "given", "value", ".", "Credit", "to", "Djangoproject", "https", ":", "//", "docs", ".", "djangoproject", ".", "com", "/", "en", "/", "2", ".", "0", "/", "_modules", "/", "django", "/", "utils", "/", "text", "/", "#slugify" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L110-L116
[ "def", "slugify", "(", "value", ")", ":", "value", "=", "re", ".", "sub", "(", "r'[^\\w\\s-]'", ",", "''", ",", "value", ")", ".", "strip", "(", ")", ".", "lower", "(", ")", "return", "re", ".", "sub", "(", "r'[-\\s]+'", ",", "'-'", ",", "value",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get
Helper function to do a GET request to Netbox. Returns the actual pynetbox object, which allows manipulation from other functions.
salt/modules/netbox.py
def _get(app, endpoint, id=None, auth_required=False, **kwargs): ''' Helper function to do a GET request to Netbox. Returns the actual pynetbox object, which allows manipulation from other functions. ''' nb = _nb_obj(auth_required=auth_required) if id: item = getattr(getattr(nb, app), en...
def _get(app, endpoint, id=None, auth_required=False, **kwargs): ''' Helper function to do a GET request to Netbox. Returns the actual pynetbox object, which allows manipulation from other functions. ''' nb = _nb_obj(auth_required=auth_required) if id: item = getattr(getattr(nb, app), en...
[ "Helper", "function", "to", "do", "a", "GET", "request", "to", "Netbox", ".", "Returns", "the", "actual", "pynetbox", "object", "which", "allows", "manipulation", "from", "other", "functions", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L119-L130
[ "def", "_get", "(", "app", ",", "endpoint", ",", "id", "=", "None", ",", "auth_required", "=", "False", ",", "*", "*", "kwargs", ")", ":", "nb", "=", "_nb_obj", "(", "auth_required", "=", "auth_required", ")", "if", "id", ":", "item", "=", "getattr",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
filter_
Get a list of items from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` kwargs Optional arguments that can be used to filter. All filter keywords are available in Netbox, ...
salt/modules/netbox.py
def filter_(app, endpoint, **kwargs): ''' Get a list of items from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` kwargs Optional arguments that can be used to filter. ...
def filter_(app, endpoint, **kwargs): ''' Get a list of items from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` kwargs Optional arguments that can be used to filter. ...
[ "Get", "a", "list", "of", "items", "from", "NetBox", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L140-L167
[ "def", "filter_", "(", "app", ",", "endpoint", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "[", "]", "nb", "=", "_nb_obj", "(", "auth_required", "=", "True", "if", "app", "in", "AUTH_ENDPOINTS", "else", "False", ")", "nb_query", "=", "getattr", "(...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_
Get a single item from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` Returns a single dictionary To get an item based on ID. .. code-block:: bash salt myminion netbox.ge...
salt/modules/netbox.py
def get_(app, endpoint, id=None, **kwargs): ''' Get a single item from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` Returns a single dictionary To get an item based on ID. ...
def get_(app, endpoint, id=None, **kwargs): ''' Get a single item from NetBox. app String of netbox app, e.g., ``dcim``, ``circuits``, ``ipam`` endpoint String of app endpoint, e.g., ``sites``, ``regions``, ``devices`` Returns a single dictionary To get an item based on ID. ...
[ "Get", "a", "single", "item", "from", "NetBox", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L170-L194
[ "def", "get_", "(", "app", ",", "endpoint", ",", "id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "_dict", "(", "_get", "(", "app", ",", "endpoint", ",", "id", "=", "id", ",", "auth_required", "=", "True", "if", "app", "in", "AUTH_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_manufacturer
.. versionadded:: 2019.2.0 Create a device manufacturer. name The name of the manufacturer, e.g., ``Juniper`` CLI Example: .. code-block:: bash salt myminion netbox.create_manufacturer Juniper
salt/modules/netbox.py
def create_manufacturer(name): ''' .. versionadded:: 2019.2.0 Create a device manufacturer. name The name of the manufacturer, e.g., ``Juniper`` CLI Example: .. code-block:: bash salt myminion netbox.create_manufacturer Juniper ''' nb_man = get_('dcim', 'manufacturer...
def create_manufacturer(name): ''' .. versionadded:: 2019.2.0 Create a device manufacturer. name The name of the manufacturer, e.g., ``Juniper`` CLI Example: .. code-block:: bash salt myminion netbox.create_manufacturer Juniper ''' nb_man = get_('dcim', 'manufacturer...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L197-L221
[ "def", "create_manufacturer", "(", "name", ")", ":", "nb_man", "=", "get_", "(", "'dcim'", ",", "'manufacturers'", ",", "name", "=", "name", ")", "if", "nb_man", ":", "return", "False", "else", ":", "payload", "=", "{", "'name'", ":", "name", ",", "'sl...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_device_type
.. versionadded:: 2019.2.0 Create a device type. If the manufacturer doesn't exist, create a new manufacturer. model String of device model, e.g., ``MX480`` manufacturer String of device manufacturer, e.g., ``Juniper`` CLI Example: .. code-block:: bash salt myminion netb...
salt/modules/netbox.py
def create_device_type(model, manufacturer): ''' .. versionadded:: 2019.2.0 Create a device type. If the manufacturer doesn't exist, create a new manufacturer. model String of device model, e.g., ``MX480`` manufacturer String of device manufacturer, e.g., ``Juniper`` CLI Examp...
def create_device_type(model, manufacturer): ''' .. versionadded:: 2019.2.0 Create a device type. If the manufacturer doesn't exist, create a new manufacturer. model String of device model, e.g., ``MX480`` manufacturer String of device manufacturer, e.g., ``Juniper`` CLI Examp...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L224-L256
[ "def", "create_device_type", "(", "model", ",", "manufacturer", ")", ":", "nb_type", "=", "get_", "(", "'dcim'", ",", "'device-types'", ",", "model", "=", "model", ")", "if", "nb_type", ":", "return", "False", "nb_man", "=", "get_", "(", "'dcim'", ",", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_device_role
.. versionadded:: 2019.2.0 Create a device role role String of device role, e.g., ``router`` CLI Example: .. code-block:: bash salt myminion netbox.create_device_role router
salt/modules/netbox.py
def create_device_role(role, color): ''' .. versionadded:: 2019.2.0 Create a device role role String of device role, e.g., ``router`` CLI Example: .. code-block:: bash salt myminion netbox.create_device_role router ''' nb_role = get_('dcim', 'device-roles', name=role...
def create_device_role(role, color): ''' .. versionadded:: 2019.2.0 Create a device role role String of device role, e.g., ``router`` CLI Example: .. code-block:: bash salt myminion netbox.create_device_role router ''' nb_role = get_('dcim', 'device-roles', name=role...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L259-L283
[ "def", "create_device_role", "(", "role", ",", "color", ")", ":", "nb_role", "=", "get_", "(", "'dcim'", ",", "'device-roles'", ",", "name", "=", "role", ")", "if", "nb_role", ":", "return", "False", "else", ":", "payload", "=", "{", "'name'", ":", "ro...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_platform
.. versionadded:: 2019.2.0 Create a new device platform platform String of device platform, e.g., ``junos`` CLI Example: .. code-block:: bash salt myminion netbox.create_platform junos
salt/modules/netbox.py
def create_platform(platform): ''' .. versionadded:: 2019.2.0 Create a new device platform platform String of device platform, e.g., ``junos`` CLI Example: .. code-block:: bash salt myminion netbox.create_platform junos ''' nb_platform = get_('dcim', 'platforms', slu...
def create_platform(platform): ''' .. versionadded:: 2019.2.0 Create a new device platform platform String of device platform, e.g., ``junos`` CLI Example: .. code-block:: bash salt myminion netbox.create_platform junos ''' nb_platform = get_('dcim', 'platforms', slu...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L286-L310
[ "def", "create_platform", "(", "platform", ")", ":", "nb_platform", "=", "get_", "(", "'dcim'", ",", "'platforms'", ",", "slug", "=", "slugify", "(", "platform", ")", ")", "if", "nb_platform", ":", "return", "False", "else", ":", "payload", "=", "{", "'n...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_site
.. versionadded:: 2019.2.0 Create a new device site site String of device site, e.g., ``BRU`` CLI Example: .. code-block:: bash salt myminion netbox.create_site BRU
salt/modules/netbox.py
def create_site(site): ''' .. versionadded:: 2019.2.0 Create a new device site site String of device site, e.g., ``BRU`` CLI Example: .. code-block:: bash salt myminion netbox.create_site BRU ''' nb_site = get_('dcim', 'sites', name=site) if nb_site: retu...
def create_site(site): ''' .. versionadded:: 2019.2.0 Create a new device site site String of device site, e.g., ``BRU`` CLI Example: .. code-block:: bash salt myminion netbox.create_site BRU ''' nb_site = get_('dcim', 'sites', name=site) if nb_site: retu...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L313-L337
[ "def", "create_site", "(", "site", ")", ":", "nb_site", "=", "get_", "(", "'dcim'", ",", "'sites'", ",", "name", "=", "site", ")", "if", "nb_site", ":", "return", "False", "else", ":", "payload", "=", "{", "'name'", ":", "site", ",", "'slug'", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_device
.. versionadded:: 2019.2.0 Create a new device with a name, role, model, manufacturer and site. All these components need to be already in Netbox. name The name of the device, e.g., ``edge_router`` role String of device role, e.g., ``router`` model String of device model, e...
salt/modules/netbox.py
def create_device(name, role, model, manufacturer, site): ''' .. versionadded:: 2019.2.0 Create a new device with a name, role, model, manufacturer and site. All these components need to be already in Netbox. name The ...
def create_device(name, role, model, manufacturer, site): ''' .. versionadded:: 2019.2.0 Create a new device with a name, role, model, manufacturer and site. All these components need to be already in Netbox. name The ...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L340-L391
[ "def", "create_device", "(", "name", ",", "role", ",", "model", ",", "manufacturer", ",", "site", ")", ":", "try", ":", "nb_role", "=", "get_", "(", "'dcim'", ",", "'device-roles'", ",", "name", "=", "role", ")", "if", "not", "nb_role", ":", "return", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
update_device
.. versionadded:: 2019.2.0 Add attributes to an existing device, identified by name. name The name of the device, e.g., ``edge_router`` kwargs Arguments to change in device, e.g., ``serial=JN2932930`` CLI Example: .. code-block:: bash salt myminion netbox.update_device ed...
salt/modules/netbox.py
def update_device(name, **kwargs): ''' .. versionadded:: 2019.2.0 Add attributes to an existing device, identified by name. name The name of the device, e.g., ``edge_router`` kwargs Arguments to change in device, e.g., ``serial=JN2932930`` CLI Example: .. code-block:: bash...
def update_device(name, **kwargs): ''' .. versionadded:: 2019.2.0 Add attributes to an existing device, identified by name. name The name of the device, e.g., ``edge_router`` kwargs Arguments to change in device, e.g., ``serial=JN2932930`` CLI Example: .. code-block:: bash...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L394-L420
[ "def", "update_device", "(", "name", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "__utils__", "[", "'args.clean_kwargs'", "]", "(", "*", "*", "kwargs", ")", "nb_device", "=", "_get", "(", "'dcim'", ",", "'devices'", ",", "auth_required", "=", "True...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_inventory_item
.. versionadded:: 2019.2.0 Add an inventory item to an existing device. device_name The name of the device, e.g., ``edge_router``. item_name String of inventory item name, e.g., ``Transceiver``. manufacturer_name String of inventory item manufacturer, e.g., ``Fiberstore``. ...
salt/modules/netbox.py
def create_inventory_item(device_name, item_name, manufacturer_name=None, serial='', part_id='', description=''): ''' .. versionadded:: 2019.2.0 Add an inventory item to an exis...
def create_inventory_item(device_name, item_name, manufacturer_name=None, serial='', part_id='', description=''): ''' .. versionadded:: 2019.2.0 Add an inventory item to an exis...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L423-L473
[ "def", "create_inventory_item", "(", "device_name", ",", "item_name", ",", "manufacturer_name", "=", "None", ",", "serial", "=", "''", ",", "part_id", "=", "''", ",", "description", "=", "''", ")", ":", "nb_device", "=", "get_", "(", "'dcim'", ",", "'devic...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
delete_inventory_item
.. versionadded:: 2019.2.0 Remove an item from a devices inventory. Identified by the netbox id item_id Integer of item to be deleted CLI Example: .. code-block:: bash salt myminion netbox.delete_inventory_item 1354
salt/modules/netbox.py
def delete_inventory_item(item_id): ''' .. versionadded:: 2019.2.0 Remove an item from a devices inventory. Identified by the netbox id item_id Integer of item to be deleted CLI Example: .. code-block:: bash salt myminion netbox.delete_inventory_item 1354 ''' nb_inve...
def delete_inventory_item(item_id): ''' .. versionadded:: 2019.2.0 Remove an item from a devices inventory. Identified by the netbox id item_id Integer of item to be deleted CLI Example: .. code-block:: bash salt myminion netbox.delete_inventory_item 1354 ''' nb_inve...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L476-L493
[ "def", "delete_inventory_item", "(", "item_id", ")", ":", "nb_inventory_item", "=", "_get", "(", "'dcim'", ",", "'inventory-items'", ",", "auth_required", "=", "True", ",", "id", "=", "item_id", ")", "nb_inventory_item", ".", "delete", "(", ")", "return", "{",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_interface_connection
.. versionadded:: 2019.2.0 Create an interface connection between 2 interfaces interface_a Interface id for Side A interface_b Interface id for Side B CLI Example: .. code-block:: bash salt myminion netbox.create_interface_connection 123 456
salt/modules/netbox.py
def create_interface_connection(interface_a, interface_b): ''' .. versionadded:: 2019.2.0 Create an interface connection between 2 interfaces interface_a Interface id for Side A interface_b Interface id for Side B CLI Example: .. code-block:: bash salt myminion n...
def create_interface_connection(interface_a, interface_b): ''' .. versionadded:: 2019.2.0 Create an interface connection between 2 interfaces interface_a Interface id for Side A interface_b Interface id for Side B CLI Example: .. code-block:: bash salt myminion n...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L496-L519
[ "def", "create_interface_connection", "(", "interface_a", ",", "interface_b", ")", ":", "payload", "=", "{", "'interface_a'", ":", "interface_a", ",", "'interface_b'", ":", "interface_b", "}", "ret", "=", "_add", "(", "'dcim'", ",", "'interface-connections'", ",",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_interfaces
.. versionadded:: 2019.2.0 Returns interfaces for a specific device using arbitrary netbox filters device_name The name of the device, e.g., ``edge_router`` kwargs Optional arguments to be used for filtering CLI Example: .. code-block:: bash salt myminion netbox.get_inte...
salt/modules/netbox.py
def get_interfaces(device_name=None, **kwargs): ''' .. versionadded:: 2019.2.0 Returns interfaces for a specific device using arbitrary netbox filters device_name The name of the device, e.g., ``edge_router`` kwargs Optional arguments to be used for filtering CLI Example: ...
def get_interfaces(device_name=None, **kwargs): ''' .. versionadded:: 2019.2.0 Returns interfaces for a specific device using arbitrary netbox filters device_name The name of the device, e.g., ``edge_router`` kwargs Optional arguments to be used for filtering CLI Example: ...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L522-L546
[ "def", "get_interfaces", "(", "device_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "device_name", ":", "device_name", "=", "__opts__", "[", "'id'", "]", "netbox_device", "=", "get_", "(", "'dcim'", ",", "'devices'", ",", "name", "=...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
openconfig_interfaces
.. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-interfaces <http://ops.openconfig.net/branches/master/openconfig-interfaces.html>`_ YANG model, containing physical and configuration data available in Netbox, e.g., IP addresses, MTU, enabled / disabled, etc. ...
salt/modules/netbox.py
def openconfig_interfaces(device_name=None): ''' .. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-interfaces <http://ops.openconfig.net/branches/master/openconfig-interfaces.html>`_ YANG model, containing physical and configuration data available in Netbo...
def openconfig_interfaces(device_name=None): ''' .. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-interfaces <http://ops.openconfig.net/branches/master/openconfig-interfaces.html>`_ YANG model, containing physical and configuration data available in Netbo...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L549-L641
[ "def", "openconfig_interfaces", "(", "device_name", "=", "None", ")", ":", "oc_if", "=", "{", "}", "interfaces", "=", "get_interfaces", "(", "device_name", "=", "device_name", ")", "ipaddresses", "=", "get_ipaddresses", "(", "device_name", "=", "device_name", ")...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
openconfig_lacp
.. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-lacp <http://ops.openconfig.net/branches/master/openconfig-lacp.html>`_ YANG model, with configuration data for Link Aggregation Control Protocol (LACP) for aggregate interfaces. .. note:: The ``in...
salt/modules/netbox.py
def openconfig_lacp(device_name=None): ''' .. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-lacp <http://ops.openconfig.net/branches/master/openconfig-lacp.html>`_ YANG model, with configuration data for Link Aggregation Control Protocol (LACP) for ag...
def openconfig_lacp(device_name=None): ''' .. versionadded:: 2019.2.0 Return a dictionary structured as standardised in the `openconfig-lacp <http://ops.openconfig.net/branches/master/openconfig-lacp.html>`_ YANG model, with configuration data for Link Aggregation Control Protocol (LACP) for ag...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L644-L697
[ "def", "openconfig_lacp", "(", "device_name", "=", "None", ")", ":", "oc_lacp", "=", "{", "}", "interfaces", "=", "get_interfaces", "(", "device_name", "=", "device_name", ")", "for", "interface", "in", "interfaces", ":", "if", "not", "interface", "[", "'lag...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_interface
.. versionadded:: 2019.2.0 Attach an interface to a device. If not all arguments are provided, they will default to Netbox defaults. device_name The name of the device, e.g., ``edge_router`` interface_name The name of the interface, e.g., ``TenGigE0/0/0/0`` mac_address Stri...
salt/modules/netbox.py
def create_interface(device_name, interface_name, mac_address=None, description=None, enabled=None, lag=None, lag_parent=None, form_factor=None): ''' .. versionadded...
def create_interface(device_name, interface_name, mac_address=None, description=None, enabled=None, lag=None, lag_parent=None, form_factor=None): ''' .. versionadded...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L700-L766
[ "def", "create_interface", "(", "device_name", ",", "interface_name", ",", "mac_address", "=", "None", ",", "description", "=", "None", ",", "enabled", "=", "None", ",", "lag", "=", "None", ",", "lag_parent", "=", "None", ",", "form_factor", "=", "None", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
update_interface
.. versionadded:: 2019.2.0 Update an existing interface with new attributes. device_name The name of the device, e.g., ``edge_router`` interface_name The name of the interface, e.g., ``ae13`` kwargs Arguments to change in interface, e.g., ``mac_address=50:87:69:53:32:D0`` ...
salt/modules/netbox.py
def update_interface(device_name, interface_name, **kwargs): ''' .. versionadded:: 2019.2.0 Update an existing interface with new attributes. device_name The name of the device, e.g., ``edge_router`` interface_name The name of the interface, e.g., ``ae13`` kwargs Argume...
def update_interface(device_name, interface_name, **kwargs): ''' .. versionadded:: 2019.2.0 Update an existing interface with new attributes. device_name The name of the device, e.g., ``edge_router`` interface_name The name of the interface, e.g., ``ae13`` kwargs Argume...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L769-L802
[ "def", "update_interface", "(", "device_name", ",", "interface_name", ",", "*", "*", "kwargs", ")", ":", "nb_device", "=", "get_", "(", "'dcim'", ",", "'devices'", ",", "name", "=", "device_name", ")", "nb_interface", "=", "_get", "(", "'dcim'", ",", "'int...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
delete_interface
.. versionadded:: 2019.2.0 Delete an interface from a device. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface, e.g., ``ae13`` CLI Example: .. code-block:: bash salt myminion netbox.delete_interface edge_router ae13
salt/modules/netbox.py
def delete_interface(device_name, interface_name): ''' .. versionadded:: 2019.2.0 Delete an interface from a device. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface, e.g., ``ae13`` CLI Example: .. code-block:: bash ...
def delete_interface(device_name, interface_name): ''' .. versionadded:: 2019.2.0 Delete an interface from a device. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface, e.g., ``ae13`` CLI Example: .. code-block:: bash ...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L805-L828
[ "def", "delete_interface", "(", "device_name", ",", "interface_name", ")", ":", "nb_device", "=", "get_", "(", "'dcim'", ",", "'devices'", ",", "name", "=", "device_name", ")", "nb_interface", "=", "_get", "(", "'dcim'", ",", "'interfaces'", ",", "auth_require...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
make_interface_child
.. versionadded:: 2019.2.0 Set an interface as part of a LAG. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface to be attached to LAG, e.g., ``xe-1/0/2``. parent_name The name of the LAG interface, e.g., ``ae13``. CLI Exa...
salt/modules/netbox.py
def make_interface_child(device_name, interface_name, parent_name): ''' .. versionadded:: 2019.2.0 Set an interface as part of a LAG. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface to be attached to LAG, e.g., ``xe-1/0/2``. ...
def make_interface_child(device_name, interface_name, parent_name): ''' .. versionadded:: 2019.2.0 Set an interface as part of a LAG. device_name The name of the device, e.g., ``edge_router``. interface_name The name of the interface to be attached to LAG, e.g., ``xe-1/0/2``. ...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L852-L878
[ "def", "make_interface_child", "(", "device_name", ",", "interface_name", ",", "parent_name", ")", ":", "nb_device", "=", "get_", "(", "'dcim'", ",", "'devices'", ",", "name", "=", "device_name", ")", "nb_parent", "=", "get_", "(", "'dcim'", ",", "'interfaces'...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_ipaddress
.. versionadded:: 2019.2.0 Add an IP address, and optionally attach it to an interface. ip_address The IP address and CIDR, e.g., ``192.168.1.1/24`` family Integer of IP family, e.g., ``4`` device The name of the device to attach IP to, e.g., ``edge_router`` interface ...
salt/modules/netbox.py
def create_ipaddress(ip_address, family, device=None, interface=None): ''' .. versionadded:: 2019.2.0 Add an IP address, and optionally attach it to an interface. ip_address The IP address and CIDR, e.g., ``192.168.1.1/24`` family Integer of IP family, e.g., ``4`` device ...
def create_ipaddress(ip_address, family, device=None, interface=None): ''' .. versionadded:: 2019.2.0 Add an IP address, and optionally attach it to an interface. ip_address The IP address and CIDR, e.g., ``192.168.1.1/24`` family Integer of IP family, e.g., ``4`` device ...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L907-L947
[ "def", "create_ipaddress", "(", "ip_address", ",", "family", ",", "device", "=", "None", ",", "interface", "=", "None", ")", ":", "nb_addr", "=", "None", "payload", "=", "{", "'family'", ":", "family", ",", "'address'", ":", "ip_address", "}", "if", "int...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
delete_ipaddress
.. versionadded:: 2019.2.0 Delete an IP address. IP addresses in Netbox are a combination of address and the interface it is assigned to. id The Netbox id for the IP address. CLI Example: .. code-block:: bash salt myminion netbox.delete_ipaddress 9002
salt/modules/netbox.py
def delete_ipaddress(ipaddr_id): ''' .. versionadded:: 2019.2.0 Delete an IP address. IP addresses in Netbox are a combination of address and the interface it is assigned to. id The Netbox id for the IP address. CLI Example: .. code-block:: bash salt myminion netbox.dele...
def delete_ipaddress(ipaddr_id): ''' .. versionadded:: 2019.2.0 Delete an IP address. IP addresses in Netbox are a combination of address and the interface it is assigned to. id The Netbox id for the IP address. CLI Example: .. code-block:: bash salt myminion netbox.dele...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L950-L971
[ "def", "delete_ipaddress", "(", "ipaddr_id", ")", ":", "nb_ipaddr", "=", "_get", "(", "'ipam'", ",", "'ip-addresses'", ",", "auth_required", "=", "True", ",", "id", "=", "ipaddr_id", ")", "if", "nb_ipaddr", ":", "nb_ipaddr", ".", "delete", "(", ")", "retur...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_circuit_provider
.. versionadded:: 2019.2.0 Create a new Netbox circuit provider name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_provider Telia 1299
salt/modules/netbox.py
def create_circuit_provider(name, asn=None): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit provider name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_provid...
def create_circuit_provider(name, asn=None): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit provider name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_provid...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L974-L1013
[ "def", "create_circuit_provider", "(", "name", ",", "asn", "=", "None", ")", ":", "nb_circuit_provider", "=", "get_", "(", "'circuits'", ",", "'providers'", ",", "name", "=", "name", ")", "payload", "=", "{", "}", "if", "nb_circuit_provider", ":", "if", "n...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_circuit_provider
.. versionadded:: 2019.2.0 Get a circuit provider with a given name and optional ASN. name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.get_circuit_provider Telia 1299
salt/modules/netbox.py
def get_circuit_provider(name, asn=None): ''' .. versionadded:: 2019.2.0 Get a circuit provider with a given name and optional ASN. name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.ge...
def get_circuit_provider(name, asn=None): ''' .. versionadded:: 2019.2.0 Get a circuit provider with a given name and optional ASN. name The name of the circuit provider asn The ASN of the circuit provider CLI Example: .. code-block:: bash salt myminion netbox.ge...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L1016-L1037
[ "def", "get_circuit_provider", "(", "name", ",", "asn", "=", "None", ")", ":", "if", "asn", ":", "nb_circuit_provider", "=", "get_", "(", "'circuits'", ",", "'providers'", ",", "asn", "=", "asn", ")", "else", ":", "nb_circuit_provider", "=", "get_", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_circuit_type
.. versionadded:: 2019.2.0 Create a new Netbox circuit type. name The name of the circuit type CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_type Transit
salt/modules/netbox.py
def create_circuit_type(name): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit type. name The name of the circuit type CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_type Transit ''' nb_circuit_type = get_('circuits', 'circuit-types'...
def create_circuit_type(name): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit type. name The name of the circuit type CLI Example: .. code-block:: bash salt myminion netbox.create_circuit_type Transit ''' nb_circuit_type = get_('circuits', 'circuit-types'...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L1040-L1067
[ "def", "create_circuit_type", "(", "name", ")", ":", "nb_circuit_type", "=", "get_", "(", "'circuits'", ",", "'circuit-types'", ",", "slug", "=", "slugify", "(", "name", ")", ")", "if", "nb_circuit_type", ":", "return", "False", "else", ":", "payload", "=", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_circuit
.. versionadded:: 2019.2.0 Create a new Netbox circuit name Name of the circuit provider_id The netbox id of the circuit provider circuit_type The name of the circuit type asn The ASN of the circuit provider description The description of the circuit ...
salt/modules/netbox.py
def create_circuit(name, provider_id, circuit_type, description=None): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit name Name of the circuit provider_id The netbox id of the circuit provider circuit_type The name of the circuit type asn The ASN...
def create_circuit(name, provider_id, circuit_type, description=None): ''' .. versionadded:: 2019.2.0 Create a new Netbox circuit name Name of the circuit provider_id The netbox id of the circuit provider circuit_type The name of the circuit type asn The ASN...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L1070-L1113
[ "def", "create_circuit", "(", "name", ",", "provider_id", ",", "circuit_type", ",", "description", "=", "None", ")", ":", "nb_circuit_provider", "=", "get_", "(", "'circuits'", ",", "'providers'", ",", "provider_id", ")", "nb_circuit_type", "=", "get_", "(", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_circuit_termination
.. versionadded:: 2019.2.0 Terminate a circuit on an interface circuit The name of the circuit interface The name of the interface to terminate on device The name of the device the interface belongs to speed The speed of the circuit, in Kbps xconnect_id ...
salt/modules/netbox.py
def create_circuit_termination(circuit, interface, device, speed, xconnect_id=None, term_side='A'): ''' .. versionadded:: 2019.2.0 Terminate a circuit on an interface circuit The name of the circuit interface The name of the interface to terminate on device The name of ...
def create_circuit_termination(circuit, interface, device, speed, xconnect_id=None, term_side='A'): ''' .. versionadded:: 2019.2.0 Terminate a circuit on an interface circuit The name of the circuit interface The name of the interface to terminate on device The name of ...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L1116-L1164
[ "def", "create_circuit_termination", "(", "circuit", ",", "interface", ",", "device", ",", "speed", ",", "xconnect_id", "=", "None", ",", "term_side", "=", "'A'", ")", ":", "nb_device", "=", "get_", "(", "'dcim'", ",", "'devices'", ",", "name", "=", "devic...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_cfg
Return the requested value from the aws_kms key in salt configuration. If it's not set, return the default.
salt/renderers/aws_kms.py
def _cfg(key, default=None): ''' Return the requested value from the aws_kms key in salt configuration. If it's not set, return the default. ''' root_cfg = __salt__.get('config.get', __opts__.get) kms_cfg = root_cfg('aws_kms', {}) return kms_cfg.get(key, default)
def _cfg(key, default=None): ''' Return the requested value from the aws_kms key in salt configuration. If it's not set, return the default. ''' root_cfg = __salt__.get('config.get', __opts__.get) kms_cfg = root_cfg('aws_kms', {}) return kms_cfg.get(key, default)
[ "Return", "the", "requested", "value", "from", "the", "aws_kms", "key", "in", "salt", "configuration", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L102-L110
[ "def", "_cfg", "(", "key", ",", "default", "=", "None", ")", ":", "root_cfg", "=", "__salt__", ".", "get", "(", "'config.get'", ",", "__opts__", ".", "get", ")", "kms_cfg", "=", "root_cfg", "(", "'aws_kms'", ",", "{", "}", ")", "return", "kms_cfg", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_session
Return the boto3 session to use for the KMS client. If aws_kms:profile_name is set in the salt configuration, use that profile. Otherwise, fall back on the default aws profile. We use the boto3 profile system to avoid having to duplicate individual boto3 configuration settings in salt configuration.
salt/renderers/aws_kms.py
def _session(): ''' Return the boto3 session to use for the KMS client. If aws_kms:profile_name is set in the salt configuration, use that profile. Otherwise, fall back on the default aws profile. We use the boto3 profile system to avoid having to duplicate individual boto3 configuration setti...
def _session(): ''' Return the boto3 session to use for the KMS client. If aws_kms:profile_name is set in the salt configuration, use that profile. Otherwise, fall back on the default aws profile. We use the boto3 profile system to avoid having to duplicate individual boto3 configuration setti...
[ "Return", "the", "boto3", "session", "to", "use", "for", "the", "KMS", "client", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L125-L151
[ "def", "_session", "(", ")", ":", "profile_name", "=", "_cfg", "(", "'profile_name'", ")", "if", "profile_name", ":", "log", ".", "info", "(", "'Using the \"%s\" aws profile.'", ",", "profile_name", ")", "else", ":", "log", ".", "info", "(", "'aws_kms:profile_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_api_decrypt
Return the response dictionary from the KMS decrypt API call.
salt/renderers/aws_kms.py
def _api_decrypt(): ''' Return the response dictionary from the KMS decrypt API call. ''' kms = _kms() data_key = _cfg_data_key() try: return kms.decrypt(CiphertextBlob=data_key) except botocore.exceptions.ClientError as orig_exc: error_code = orig_exc.response.get('Error', {...
def _api_decrypt(): ''' Return the response dictionary from the KMS decrypt API call. ''' kms = _kms() data_key = _cfg_data_key() try: return kms.decrypt(CiphertextBlob=data_key) except botocore.exceptions.ClientError as orig_exc: error_code = orig_exc.response.get('Error', {...
[ "Return", "the", "response", "dictionary", "from", "the", "KMS", "decrypt", "API", "call", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L162-L176
[ "def", "_api_decrypt", "(", ")", ":", "kms", "=", "_kms", "(", ")", "data_key", "=", "_cfg_data_key", "(", ")", "try", ":", "return", "kms", ".", "decrypt", "(", "CiphertextBlob", "=", "data_key", ")", "except", "botocore", ".", "exceptions", ".", "Clien...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_plaintext_data_key
Return the configured KMS data key decrypted and encoded in urlsafe base64. Cache the result to minimize API calls to AWS.
salt/renderers/aws_kms.py
def _plaintext_data_key(): ''' Return the configured KMS data key decrypted and encoded in urlsafe base64. Cache the result to minimize API calls to AWS. ''' response = getattr(_plaintext_data_key, 'response', None) cache_hit = response is not None if not cache_hit: response = _api_...
def _plaintext_data_key(): ''' Return the configured KMS data key decrypted and encoded in urlsafe base64. Cache the result to minimize API calls to AWS. ''' response = getattr(_plaintext_data_key, 'response', None) cache_hit = response is not None if not cache_hit: response = _api_...
[ "Return", "the", "configured", "KMS", "data", "key", "decrypted", "and", "encoded", "in", "urlsafe", "base64", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L179-L195
[ "def", "_plaintext_data_key", "(", ")", ":", "response", "=", "getattr", "(", "_plaintext_data_key", ",", "'response'", ",", "None", ")", "cache_hit", "=", "response", "is", "not", "None", "if", "not", "cache_hit", ":", "response", "=", "_api_decrypt", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_decrypt_ciphertext
Given a blob of ciphertext as a bytestring, try to decrypt the cipher and return the decrypted string. If the cipher cannot be decrypted, log the error, and return the ciphertext back out.
salt/renderers/aws_kms.py
def _decrypt_ciphertext(cipher, translate_newlines=False): ''' Given a blob of ciphertext as a bytestring, try to decrypt the cipher and return the decrypted string. If the cipher cannot be decrypted, log the error, and return the ciphertext back out. ''' if translate_newlines: cipher = ...
def _decrypt_ciphertext(cipher, translate_newlines=False): ''' Given a blob of ciphertext as a bytestring, try to decrypt the cipher and return the decrypted string. If the cipher cannot be decrypted, log the error, and return the ciphertext back out. ''' if translate_newlines: cipher = ...
[ "Given", "a", "blob", "of", "ciphertext", "as", "a", "bytestring", "try", "to", "decrypt", "the", "cipher", "and", "return", "the", "decrypted", "string", ".", "If", "the", "cipher", "cannot", "be", "decrypted", "log", "the", "error", "and", "return", "the...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L206-L222
[ "def", "_decrypt_ciphertext", "(", "cipher", ",", "translate_newlines", "=", "False", ")", ":", "if", "translate_newlines", ":", "cipher", "=", "cipher", ".", "replace", "(", "r'\\n'", ",", "'\\n'", ")", "if", "hasattr", "(", "cipher", ",", "'encode'", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_decrypt_object
Recursively try to decrypt any object. Recur on objects that are not strings. Decrypt strings that are valid Fernet tokens. Return the rest unchanged.
salt/renderers/aws_kms.py
def _decrypt_object(obj, translate_newlines=False): ''' Recursively try to decrypt any object. Recur on objects that are not strings. Decrypt strings that are valid Fernet tokens. Return the rest unchanged. ''' if salt.utils.stringio.is_readable(obj): return _decrypt_object(obj.getva...
def _decrypt_object(obj, translate_newlines=False): ''' Recursively try to decrypt any object. Recur on objects that are not strings. Decrypt strings that are valid Fernet tokens. Return the rest unchanged. ''' if salt.utils.stringio.is_readable(obj): return _decrypt_object(obj.getva...
[ "Recursively", "try", "to", "decrypt", "any", "object", ".", "Recur", "on", "objects", "that", "are", "not", "strings", ".", "Decrypt", "strings", "that", "are", "valid", "Fernet", "tokens", ".", "Return", "the", "rest", "unchanged", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L225-L252
[ "def", "_decrypt_object", "(", "obj", ",", "translate_newlines", "=", "False", ")", ":", "if", "salt", ".", "utils", ".", "stringio", ".", "is_readable", "(", "obj", ")", ":", "return", "_decrypt_object", "(", "obj", ".", "getvalue", "(", ")", ",", "tran...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
render
Decrypt the data to be rendered that was encrypted using AWS KMS envelope encryption.
salt/renderers/aws_kms.py
def render(data, saltenv='base', sls='', argline='', **kwargs): # pylint: disable=unused-argument ''' Decrypt the data to be rendered that was encrypted using AWS KMS envelope encryption. ''' translate_newlines = kwargs.get('translate_newlines', False) return _decrypt_object(data, translate_newline...
def render(data, saltenv='base', sls='', argline='', **kwargs): # pylint: disable=unused-argument ''' Decrypt the data to be rendered that was encrypted using AWS KMS envelope encryption. ''' translate_newlines = kwargs.get('translate_newlines', False) return _decrypt_object(data, translate_newline...
[ "Decrypt", "the", "data", "to", "be", "rendered", "that", "was", "encrypted", "using", "AWS", "KMS", "envelope", "encryption", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L255-L260
[ "def", "render", "(", "data", ",", "saltenv", "=", "'base'", ",", "sls", "=", "''", ",", "argline", "=", "''", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=unused-argument", "translate_newlines", "=", "kwargs", ".", "get", "(", "'translate_newlines'...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_serial_sanitizer
Replaces the last 1/4 of a string with X's
salt/modules/grains.py
def _serial_sanitizer(instr): '''Replaces the last 1/4 of a string with X's''' length = len(instr) index = int(math.floor(length * .75)) return '{0}{1}'.format(instr[:index], 'X' * (length - index))
def _serial_sanitizer(instr): '''Replaces the last 1/4 of a string with X's''' length = len(instr) index = int(math.floor(length * .75)) return '{0}{1}'.format(instr[:index], 'X' * (length - index))
[ "Replaces", "the", "last", "1", "/", "4", "of", "a", "string", "with", "X", "s" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L55-L59
[ "def", "_serial_sanitizer", "(", "instr", ")", ":", "length", "=", "len", "(", "instr", ")", "index", "=", "int", "(", "math", ".", "floor", "(", "length", "*", ".75", ")", ")", "return", "'{0}{1}'", ".", "format", "(", "instr", "[", ":", "index", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get
Attempt to retrieve the named value from grains, if the named value is not available return the passed default. The default return is an empty string. The value can also represent a value in a nested dict using a ":" delimiter for the dict. This means that if a dict in grains looks like this:: {'p...
salt/modules/grains.py
def get(key, default='', delimiter=DEFAULT_TARGET_DELIM, ordered=True): ''' Attempt to retrieve the named value from grains, if the named value is not available return the passed default. The default return is an empty string. The value can also represent a value in a nested dict using a ":" delimiter ...
def get(key, default='', delimiter=DEFAULT_TARGET_DELIM, ordered=True): ''' Attempt to retrieve the named value from grains, if the named value is not available return the passed default. The default return is an empty string. The value can also represent a value in a nested dict using a ":" delimiter ...
[ "Attempt", "to", "retrieve", "the", "named", "value", "from", "grains", "if", "the", "named", "value", "is", "not", "available", "return", "the", "passed", "default", ".", "The", "default", "return", "is", "an", "empty", "string", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L80-L123
[ "def", "get", "(", "key", ",", "default", "=", "''", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ",", "ordered", "=", "True", ")", ":", "if", "ordered", "is", "True", ":", "grains", "=", "__grains__", "else", ":", "grains", "=", "salt", ".", "utils"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
has_value
Determine whether a key exists in the grains dictionary. Given a grains dictionary that contains the following structure:: {'pkg': {'apache': 'httpd'}} One would determine if the apache key in the pkg dict exists by:: pkg:apache CLI Example: .. code-block:: bash salt '*' g...
salt/modules/grains.py
def has_value(key): ''' Determine whether a key exists in the grains dictionary. Given a grains dictionary that contains the following structure:: {'pkg': {'apache': 'httpd'}} One would determine if the apache key in the pkg dict exists by:: pkg:apache CLI Example: .. code-...
def has_value(key): ''' Determine whether a key exists in the grains dictionary. Given a grains dictionary that contains the following structure:: {'pkg': {'apache': 'httpd'}} One would determine if the apache key in the pkg dict exists by:: pkg:apache CLI Example: .. code-...
[ "Determine", "whether", "a", "key", "exists", "in", "the", "grains", "dictionary", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L126-L147
[ "def", "has_value", "(", "key", ")", ":", "return", "salt", ".", "utils", ".", "data", ".", "traverse_dict_and_list", "(", "__grains__", ",", "key", ",", "KeyError", ")", "is", "not", "KeyError" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
items
Return all of the minion's grains CLI Example: .. code-block:: bash salt '*' grains.items Sanitized CLI Example: .. code-block:: bash salt '*' grains.items sanitize=True
salt/modules/grains.py
def items(sanitize=False): ''' Return all of the minion's grains CLI Example: .. code-block:: bash salt '*' grains.items Sanitized CLI Example: .. code-block:: bash salt '*' grains.items sanitize=True ''' if salt.utils.data.is_true(sanitize): out = dict(__gr...
def items(sanitize=False): ''' Return all of the minion's grains CLI Example: .. code-block:: bash salt '*' grains.items Sanitized CLI Example: .. code-block:: bash salt '*' grains.items sanitize=True ''' if salt.utils.data.is_true(sanitize): out = dict(__gr...
[ "Return", "all", "of", "the", "minion", "s", "grains" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L150-L173
[ "def", "items", "(", "sanitize", "=", "False", ")", ":", "if", "salt", ".", "utils", ".", "data", ".", "is_true", "(", "sanitize", ")", ":", "out", "=", "dict", "(", "__grains__", ")", "for", "key", ",", "func", "in", "six", ".", "iteritems", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
item
Return one or more grains CLI Example: .. code-block:: bash salt '*' grains.item os salt '*' grains.item os osrelease oscodename Sanitized CLI Example: .. code-block:: bash salt '*' grains.item host sanitize=True
salt/modules/grains.py
def item(*args, **kwargs): ''' Return one or more grains CLI Example: .. code-block:: bash salt '*' grains.item os salt '*' grains.item os osrelease oscodename Sanitized CLI Example: .. code-block:: bash salt '*' grains.item host sanitize=True ''' ret = {} ...
def item(*args, **kwargs): ''' Return one or more grains CLI Example: .. code-block:: bash salt '*' grains.item os salt '*' grains.item os osrelease oscodename Sanitized CLI Example: .. code-block:: bash salt '*' grains.item host sanitize=True ''' ret = {} ...
[ "Return", "one", "or", "more", "grains" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L176-L211
[ "def", "item", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "}", "default", "=", "kwargs", ".", "get", "(", "'default'", ",", "''", ")", "delimiter", "=", "kwargs", ".", "get", "(", "'delimiter'", ",", "DEFAULT_TARGET_DELIM",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
setvals
Set new grains values in the grains config file destructive If an operation results in a key being removed, delete the key, too. Defaults to False. CLI Example: .. code-block:: bash salt '*' grains.setvals "{'key1': 'val1', 'key2': 'val2'}"
salt/modules/grains.py
def setvals(grains, destructive=False): ''' Set new grains values in the grains config file destructive If an operation results in a key being removed, delete the key, too. Defaults to False. CLI Example: .. code-block:: bash salt '*' grains.setvals "{'key1': 'val1', 'key...
def setvals(grains, destructive=False): ''' Set new grains values in the grains config file destructive If an operation results in a key being removed, delete the key, too. Defaults to False. CLI Example: .. code-block:: bash salt '*' grains.setvals "{'key1': 'val1', 'key...
[ "Set", "new", "grains", "values", "in", "the", "grains", "config", "file" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L214-L310
[ "def", "setvals", "(", "grains", ",", "destructive", "=", "False", ")", ":", "new_grains", "=", "grains", "if", "not", "isinstance", "(", "new_grains", ",", "collections", ".", "Mapping", ")", ":", "raise", "SaltException", "(", "'setvals grains must be a dictio...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
append
.. versionadded:: 0.17.0 Append a value to a list in the grains config file. If the grain doesn't exist, the grain key is added and the value is appended to the new grain as a list item. key The grain key to be appended to val The value to append to the grain key convert ...
salt/modules/grains.py
def append(key, val, convert=False, delimiter=DEFAULT_TARGET_DELIM): ''' .. versionadded:: 0.17.0 Append a value to a list in the grains config file. If the grain doesn't exist, the grain key is added and the value is appended to the new grain as a list item. key The grain key to be ap...
def append(key, val, convert=False, delimiter=DEFAULT_TARGET_DELIM): ''' .. versionadded:: 0.17.0 Append a value to a list in the grains config file. If the grain doesn't exist, the grain key is added and the value is appended to the new grain as a list item. key The grain key to be ap...
[ "..", "versionadded", "::", "0", ".", "17", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L337-L391
[ "def", "append", "(", "key", ",", "val", ",", "convert", "=", "False", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "grains", "=", "get", "(", "key", ",", "[", "]", ",", "delimiter", ")", "if", "convert", ":", "if", "not", "isinstance", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
remove
.. versionadded:: 0.17.0 Remove a value from a list in the grains config file key The grain key to remove. val The value to remove. delimiter The key can be a nested dict key. Use this parameter to specify the delimiter you use, instead of the default ``:``. Y...
salt/modules/grains.py
def remove(key, val, delimiter=DEFAULT_TARGET_DELIM): ''' .. versionadded:: 0.17.0 Remove a value from a list in the grains config file key The grain key to remove. val The value to remove. delimiter The key can be a nested dict key. Use this parameter to spec...
def remove(key, val, delimiter=DEFAULT_TARGET_DELIM): ''' .. versionadded:: 0.17.0 Remove a value from a list in the grains config file key The grain key to remove. val The value to remove. delimiter The key can be a nested dict key. Use this parameter to spec...
[ "..", "versionadded", "::", "0", ".", "17", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L394-L434
[ "def", "remove", "(", "key", ",", "val", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "grains", "=", "get", "(", "key", ",", "[", "]", ",", "delimiter", ")", "if", "not", "isinstance", "(", "grains", ",", "list", ")", ":", "return", "'The...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
filter_by
.. versionadded:: 0.17.0 Look up the given grain in a given dictionary for the current OS and return the result Although this may occasionally be useful at the CLI, the primary intent of this function is for use in Jinja to make short work of creating lookup tables for OS-specific data. For exampl...
salt/modules/grains.py
def filter_by(lookup_dict, grain='os_family', merge=None, default='default', base=None): ''' .. versionadded:: 0.17.0 Look up the given grain in a given dictionary for the current OS and return the result Although this may occasionally be useful at the CLI, the primary intent of this function ...
def filter_by(lookup_dict, grain='os_family', merge=None, default='default', base=None): ''' .. versionadded:: 0.17.0 Look up the given grain in a given dictionary for the current OS and return the result Although this may occasionally be useful at the CLI, the primary intent of this function ...
[ "..", "versionadded", "::", "0", ".", "17", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L492-L600
[ "def", "filter_by", "(", "lookup_dict", ",", "grain", "=", "'os_family'", ",", "merge", "=", "None", ",", "default", "=", "'default'", ",", "base", "=", "None", ")", ":", "return", "salt", ".", "utils", ".", "data", ".", "filter_by", "(", "lookup_dict", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_dict_from_path
Given a lookup string in the form of 'foo:bar:baz" return a nested dictionary of the appropriate depth with the final segment as a value. >>> _dict_from_path('foo:bar:baz', 'somevalue') {"foo": {"bar": {"baz": "somevalue"}}
salt/modules/grains.py
def _dict_from_path(path, val, delimiter=DEFAULT_TARGET_DELIM): ''' Given a lookup string in the form of 'foo:bar:baz" return a nested dictionary of the appropriate depth with the final segment as a value. >>> _dict_from_path('foo:bar:baz', 'somevalue') {"foo": {"bar": {"baz": "somevalue"}} '''...
def _dict_from_path(path, val, delimiter=DEFAULT_TARGET_DELIM): ''' Given a lookup string in the form of 'foo:bar:baz" return a nested dictionary of the appropriate depth with the final segment as a value. >>> _dict_from_path('foo:bar:baz', 'somevalue') {"foo": {"bar": {"baz": "somevalue"}} '''...
[ "Given", "a", "lookup", "string", "in", "the", "form", "of", "foo", ":", "bar", ":", "baz", "return", "a", "nested", "dictionary", "of", "the", "appropriate", "depth", "with", "the", "final", "segment", "as", "a", "value", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L603-L616
[ "def", "_dict_from_path", "(", "path", ",", "val", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "nested_dict", "=", "_infinitedict", "(", ")", "keys", "=", "path", ".", "rsplit", "(", "delimiter", ")", "lastplace", "=", "reduce", "(", "operator",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_or_set_hash
Perform a one-time generation of a hash and write it to the local grains. If that grain has already been set return the value instead. This is useful for generating passwords or keys that are specific to a single minion that don't need to be stored somewhere centrally. State Example: .. code-bloc...
salt/modules/grains.py
def get_or_set_hash(name, length=8, chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'): ''' Perform a one-time generation of a hash and write it to the local grains. If that grain has already been set return the value instead. This is useful for generating passwords or keys tha...
def get_or_set_hash(name, length=8, chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'): ''' Perform a one-time generation of a hash and write it to the local grains. If that grain has already been set return the value instead. This is useful for generating passwords or keys tha...
[ "Perform", "a", "one", "-", "time", "generation", "of", "a", "hash", "and", "write", "it", "to", "the", "local", "grains", ".", "If", "that", "grain", "has", "already", "been", "set", "return", "the", "value", "instead", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L619-L666
[ "def", "get_or_set_hash", "(", "name", ",", "length", "=", "8", ",", "chars", "=", "'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'", ")", ":", "ret", "=", "get", "(", "name", ",", "None", ")", "if", "ret", "is", "None", ":", "val", "=", "''", ".", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set
Set a key to an arbitrary value. It is used like setval but works with nested keys. This function is conservative. It will only overwrite an entry if its value and the given one are not a list or a dict. The ``force`` parameter is used to allow overwriting in all cases. .. versionadded:: 2015.8.0 ...
salt/modules/grains.py
def set(key, val='', force=False, destructive=False, delimiter=DEFAULT_TARGET_DELIM): ''' Set a key to an arbitrary value. It is used like setval but works with nested keys. This function is conservative. It will only overwrite an entry if its value and the given one...
def set(key, val='', force=False, destructive=False, delimiter=DEFAULT_TARGET_DELIM): ''' Set a key to an arbitrary value. It is used like setval but works with nested keys. This function is conservative. It will only overwrite an entry if its value and the given one...
[ "Set", "a", "key", "to", "an", "arbitrary", "value", ".", "It", "is", "used", "like", "setval", "but", "works", "with", "nested", "keys", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L669-L787
[ "def", "set", "(", "key", ",", "val", "=", "''", ",", "force", "=", "False", ",", "destructive", "=", "False", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "ret", "=", "{", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", ",", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
equals
Used to make sure the minion's grain key/value matches. Returns ``True`` if matches otherwise ``False``. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' grains.equals fqdn <expected_fqdn> salt '*' grains.equals systemd:version 219
salt/modules/grains.py
def equals(key, value): ''' Used to make sure the minion's grain key/value matches. Returns ``True`` if matches otherwise ``False``. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' grains.equals fqdn <expected_fqdn> salt '*' grains.equals systemd:versio...
def equals(key, value): ''' Used to make sure the minion's grain key/value matches. Returns ``True`` if matches otherwise ``False``. .. versionadded:: 2017.7.0 CLI Example: .. code-block:: bash salt '*' grains.equals fqdn <expected_fqdn> salt '*' grains.equals systemd:versio...
[ "Used", "to", "make", "sure", "the", "minion", "s", "grain", "key", "/", "value", "matches", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grains.py#L790-L805
[ "def", "equals", "(", "key", ",", "value", ")", ":", "return", "six", ".", "text_type", "(", "value", ")", "==", "six", ".", "text_type", "(", "get", "(", "key", ")", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_xapi_session
Get a session to XenAPI. By default, use the local UNIX socket.
salt/modules/xapi_virt.py
def _get_xapi_session(): ''' Get a session to XenAPI. By default, use the local UNIX socket. ''' _xenapi = _check_xenapi() xapi_uri = __salt__['config.option']('xapi.uri') xapi_login = __salt__['config.option']('xapi.login') xapi_password = __salt__['config.option']('xapi.password') if...
def _get_xapi_session(): ''' Get a session to XenAPI. By default, use the local UNIX socket. ''' _xenapi = _check_xenapi() xapi_uri = __salt__['config.option']('xapi.uri') xapi_login = __salt__['config.option']('xapi.login') xapi_password = __salt__['config.option']('xapi.password') if...
[ "Get", "a", "session", "to", "XenAPI", ".", "By", "default", "use", "the", "local", "UNIX", "socket", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L76-L102
[ "def", "_get_xapi_session", "(", ")", ":", "_xenapi", "=", "_check_xenapi", "(", ")", "xapi_uri", "=", "__salt__", "[", "'config.option'", "]", "(", "'xapi.uri'", ")", "xapi_login", "=", "__salt__", "[", "'config.option'", "]", "(", "'xapi.login'", ")", "xapi_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_xtool
Internal, returns xl or xm command line path
salt/modules/xapi_virt.py
def _get_xtool(): ''' Internal, returns xl or xm command line path ''' for xtool in ['xl', 'xm']: path = salt.utils.path.which(xtool) if path is not None: return path
def _get_xtool(): ''' Internal, returns xl or xm command line path ''' for xtool in ['xl', 'xm']: path = salt.utils.path.which(xtool) if path is not None: return path
[ "Internal", "returns", "xl", "or", "xm", "command", "line", "path" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L114-L121
[ "def", "_get_xtool", "(", ")", ":", "for", "xtool", "in", "[", "'xl'", ",", "'xm'", "]", ":", "path", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "xtool", ")", "if", "path", "is", "not", "None", ":", "return", "path" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_label_uuid
Internal, returns label's uuid
salt/modules/xapi_virt.py
def _get_label_uuid(xapi, rectype, label): ''' Internal, returns label's uuid ''' try: return getattr(xapi, rectype).get_by_name_label(label)[0] except Exception: return False
def _get_label_uuid(xapi, rectype, label): ''' Internal, returns label's uuid ''' try: return getattr(xapi, rectype).get_by_name_label(label)[0] except Exception: return False
[ "Internal", "returns", "label", "s", "uuid" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L131-L138
[ "def", "_get_label_uuid", "(", "xapi", ",", "rectype", ",", "label", ")", ":", "try", ":", "return", "getattr", "(", "xapi", ",", "rectype", ")", ".", "get_by_name_label", "(", "label", ")", "[", "0", "]", "except", "Exception", ":", "return", "False" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_record_by_label
Internal, returns a full record for uuid
salt/modules/xapi_virt.py
def _get_record_by_label(xapi, rectype, label): ''' Internal, returns a full record for uuid ''' uuid = _get_label_uuid(xapi, rectype, label) if uuid is False: return False return getattr(xapi, rectype).get_record(uuid)
def _get_record_by_label(xapi, rectype, label): ''' Internal, returns a full record for uuid ''' uuid = _get_label_uuid(xapi, rectype, label) if uuid is False: return False return getattr(xapi, rectype).get_record(uuid)
[ "Internal", "returns", "a", "full", "record", "for", "uuid" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L148-L155
[ "def", "_get_record_by_label", "(", "xapi", ",", "rectype", ",", "label", ")", ":", "uuid", "=", "_get_label_uuid", "(", "xapi", ",", "rectype", ",", "label", ")", "if", "uuid", "is", "False", ":", "return", "False", "return", "getattr", "(", "xapi", ","...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_metrics_record
Internal, returns metrics record for a rectype
salt/modules/xapi_virt.py
def _get_metrics_record(xapi, rectype, record): ''' Internal, returns metrics record for a rectype ''' metrics_id = record['metrics'] return getattr(xapi, '{0}_metrics'.format(rectype)).get_record(metrics_id)
def _get_metrics_record(xapi, rectype, record): ''' Internal, returns metrics record for a rectype ''' metrics_id = record['metrics'] return getattr(xapi, '{0}_metrics'.format(rectype)).get_record(metrics_id)
[ "Internal", "returns", "metrics", "record", "for", "a", "rectype" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L158-L163
[ "def", "_get_metrics_record", "(", "xapi", ",", "rectype", ",", "record", ")", ":", "metrics_id", "=", "record", "[", "'metrics'", "]", "return", "getattr", "(", "xapi", ",", "'{0}_metrics'", ".", "format", "(", "rectype", ")", ")", ".", "get_record", "(",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_val
Internal, get value from record
salt/modules/xapi_virt.py
def _get_val(record, keys): ''' Internal, get value from record ''' data = record for key in keys: if key in data: data = data[key] else: return None return data
def _get_val(record, keys): ''' Internal, get value from record ''' data = record for key in keys: if key in data: data = data[key] else: return None return data
[ "Internal", "get", "value", "from", "record" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L166-L176
[ "def", "_get_val", "(", "record", ",", "keys", ")", ":", "data", "=", "record", "for", "key", "in", "keys", ":", "if", "key", "in", "data", ":", "data", "=", "data", "[", "key", "]", "else", ":", "return", "None", "return", "data" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_domains
Return a list of virtual machine names on the minion CLI Example: .. code-block:: bash salt '*' virt.list_domains
salt/modules/xapi_virt.py
def list_domains(): ''' Return a list of virtual machine names on the minion CLI Example: .. code-block:: bash salt '*' virt.list_domains ''' with _get_xapi_session() as xapi: hosts = xapi.VM.get_all() ret = [] for _host in hosts: if xapi.VM.get_re...
def list_domains(): ''' Return a list of virtual machine names on the minion CLI Example: .. code-block:: bash salt '*' virt.list_domains ''' with _get_xapi_session() as xapi: hosts = xapi.VM.get_all() ret = [] for _host in hosts: if xapi.VM.get_re...
[ "Return", "a", "list", "of", "virtual", "machine", "names", "on", "the", "minion" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L179-L197
[ "def", "list_domains", "(", ")", ":", "with", "_get_xapi_session", "(", ")", "as", "xapi", ":", "hosts", "=", "xapi", ".", "VM", ".", "get_all", "(", ")", "ret", "=", "[", "]", "for", "_host", "in", "hosts", ":", "if", "xapi", ".", "VM", ".", "ge...
e8541fd6e744ab0df786c0f76102e41631f45d46