repository_name stringclasses 316
values | func_path_in_repository stringlengths 6 223 | func_name stringlengths 1 134 | language stringclasses 1
value | func_code_string stringlengths 57 65.5k | func_documentation_string stringlengths 1 46.3k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 | called_functions listlengths 1 156 ⌀ | enclosing_scope stringlengths 2 1.48M |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/log/setup.py | __remove_temp_logging_handler | python | def __remove_temp_logging_handler():
'''
This function will run once logging has been configured. It just removes
the temporary stream Handler from the logging handlers.
'''
if is_logging_configured():
# In this case, the temporary logging handler has been removed, return!
return
... | This function will run once logging has been configured. It just removes
the temporary stream Handler from the logging handlers. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/setup.py#L1172-L1197 | [
"def is_logging_configured():\n return __CONSOLE_CONFIGURED or __LOGFILE_CONFIGURED\n"
] | # -*- coding: utf-8 -*-
'''
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
salt.log.setup
~~~~~~~~~~~~~~
This is where Salt's logging gets set up.
This module should be imported as soon as possible, preferably the first
module salt or any salt depending library imports so any new logging
... |
saltstack/salt | salt/log/setup.py | __global_logging_exception_handler | python | def __global_logging_exception_handler(exc_type, exc_value, exc_traceback):
'''
This function will log all un-handled python exceptions.
'''
if exc_type.__name__ == "KeyboardInterrupt":
# Do not log the exception or display the traceback on Keyboard Interrupt
# Stop the logging queue lis... | This function will log all un-handled python exceptions. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/setup.py#L1200-L1221 | null | # -*- coding: utf-8 -*-
'''
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
salt.log.setup
~~~~~~~~~~~~~~
This is where Salt's logging gets set up.
This module should be imported as soon as possible, preferably the first
module salt or any salt depending library imports so any new logging
... |
saltstack/salt | salt/modules/grub_legacy.py | conf | python | def conf():
'''
Parse GRUB conf file
CLI Example:
.. code-block:: bash
salt '*' grub.conf
'''
stanza = ''
stanzas = []
in_stanza = False
ret = {}
pos = 0
try:
with salt.utils.files.fopen(_detect_conf(), 'r') as _fp:
for line in _fp:
... | Parse GRUB conf file
CLI Example:
.. code-block:: bash
salt '*' grub.conf | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grub_legacy.py#L55-L115 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Support for GRUB Legacy
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
# Import salt libs
import salt.utils.files
import salt.utils.decorators as decorators
from salt.exceptions import CommandExecutionError
# Define the module's... |
saltstack/salt | salt/modules/grub_legacy.py | _parse_line | python | def _parse_line(line=''):
'''
Used by conf() to break config lines into
name/value pairs
'''
parts = line.split()
key = parts.pop(0)
value = ' '.join(parts)
return key, value | Used by conf() to break config lines into
name/value pairs | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/grub_legacy.py#L118-L126 | null | # -*- coding: utf-8 -*-
'''
Support for GRUB Legacy
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
# Import salt libs
import salt.utils.files
import salt.utils.decorators as decorators
from salt.exceptions import CommandExecutionError
# Define the module's... |
saltstack/salt | salt/modules/nxos_upgrade.py | check_upgrade_impact | python | def check_upgrade_impact(system_image, kickstart_image=None, issu=True, **kwargs):
'''
Display upgrade impact information without actually upgrading the device.
system_image (Mandatory Option)
Path on bootflash: to system image upgrade file.
kickstart_image
Path on bootflash: to kickst... | Display upgrade impact information without actually upgrading the device.
system_image (Mandatory Option)
Path on bootflash: to system image upgrade file.
kickstart_image
Path on bootflash: to kickstart image upgrade file.
(Not required if using combined system/kickstart image file)
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_upgrade.py#L77-L139 | [
"def _parse_upgrade_data(data):\n '''\n Helper method to parse upgrade data from the NX-OS device.\n '''\n upgrade_result = {}\n upgrade_result['upgrade_data'] = None\n upgrade_result['succeeded'] = False\n upgrade_result['upgrade_required'] = False\n upgrade_result['upgrade_non_disruptive']... | # -*- coding: utf-8 -*-
# Copyright (c) 2018 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... |
saltstack/salt | salt/modules/nxos_upgrade.py | upgrade | python | def upgrade(system_image, kickstart_image=None, issu=True, **kwargs):
'''
Upgrade NX-OS switch.
system_image (Mandatory Option)
Path on bootflash: to system image upgrade file.
kickstart_image
Path on bootflash: to kickstart image upgrade file.
(Not required if using combined s... | Upgrade NX-OS switch.
system_image (Mandatory Option)
Path on bootflash: to system image upgrade file.
kickstart_image
Path on bootflash: to kickstart image upgrade file.
(Not required if using combined system/kickstart image file)
Default: None
issu
Set this optio... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_upgrade.py#L142-L248 | [
"def check_upgrade_impact(system_image, kickstart_image=None, issu=True, **kwargs):\n '''\n Display upgrade impact information without actually upgrading the device.\n\n system_image (Mandatory Option)\n Path on bootflash: to system image upgrade file.\n\n kickstart_image\n Path on bootfla... | # -*- coding: utf-8 -*-
# Copyright (c) 2018 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... |
saltstack/salt | salt/modules/nxos_upgrade.py | _upgrade | python | def _upgrade(system_image, kickstart_image, issu, **kwargs):
'''
Helper method that does the heavy lifting for upgrades.
'''
si = system_image
ki = kickstart_image
dev = 'bootflash'
cmd = 'terminal dont-ask ; install all'
if ki is None:
logmsg = 'Upgrading device using combined ... | Helper method that does the heavy lifting for upgrades. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_upgrade.py#L251-L297 | [
"def _parse_upgrade_data(data):\n '''\n Helper method to parse upgrade data from the NX-OS device.\n '''\n upgrade_result = {}\n upgrade_result['upgrade_data'] = None\n upgrade_result['succeeded'] = False\n upgrade_result['upgrade_required'] = False\n upgrade_result['upgrade_non_disruptive']... | # -*- coding: utf-8 -*-
# Copyright (c) 2018 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... |
saltstack/salt | salt/modules/nxos_upgrade.py | _parse_upgrade_data | python | def _parse_upgrade_data(data):
'''
Helper method to parse upgrade data from the NX-OS device.
'''
upgrade_result = {}
upgrade_result['upgrade_data'] = None
upgrade_result['succeeded'] = False
upgrade_result['upgrade_required'] = False
upgrade_result['upgrade_non_disruptive'] = False
... | Helper method to parse upgrade data from the NX-OS device. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nxos_upgrade.py#L300-L405 | null | # -*- coding: utf-8 -*-
# Copyright (c) 2018 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... |
saltstack/salt | salt/modules/dockercompose.py | __standardize_result | python | def __standardize_result(status, message, data=None, debug_msg=None):
'''
Standardizes all responses
:param status:
:param message:
:param data:
:param debug_msg:
:return:
'''
result = {
'status': status,
'message': message
}
if data is not None:
res... | Standardizes all responses
:param status:
:param message:
:param data:
:param debug_msg:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L160-L181 | null |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __get_docker_file_path | python | def __get_docker_file_path(path):
'''
Determines the filepath to use
:param path:
:return:
'''
if os.path.isfile(path):
return path
for dc_filename in DEFAULT_DC_FILENAMES:
file_path = os.path.join(path, dc_filename)
if os.path.isfile(file_path):
return f... | Determines the filepath to use
:param path:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L184-L196 | null |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __read_docker_compose_file | python | def __read_docker_compose_file(file_path):
'''
Read the compose file if it exists in the directory
:param file_path:
:return:
'''
if not os.path.isfile(file_path):
return __standardize_result(False,
'Path {} is not present'.format(file_path),
... | Read the compose file if it exists in the directory
:param file_path:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L200-L223 | null |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __load_docker_compose | python | def __load_docker_compose(path):
'''
Read the compose file and load its' contents
:param path:
:return:
'''
file_path = __get_docker_file_path(path)
if file_path is None:
msg = 'Could not find docker-compose file at {0}'.format(path)
return None, __standardize_result(False, ... | Read the compose file and load its' contents
:param path:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L226-L263 | [
"def load(stream, Loader=SaltYamlSafeLoader):\n return yaml.load(stream, Loader=Loader)\n",
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __dump_docker_compose | python | def __dump_docker_compose(path, content, already_existed):
'''
Dumps
:param path:
:param content: the not-yet dumped content
:return:
'''
try:
dumped = yaml.safe_dump(content, indent=2, default_flow_style=False)
return __write_docker_compose(path, dumped, already_existed)
... | Dumps
:param path:
:param content: the not-yet dumped content
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L266-L280 | null |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __write_docker_compose | python | def __write_docker_compose(path, docker_compose, already_existed):
'''
Write docker-compose to a path
in order to use it with docker-compose ( config check )
:param path:
docker_compose
contains the docker-compose file
:return:
'''
if path.lower().endswith(('.yml', '.yaml')):
... | Write docker-compose to a path
in order to use it with docker-compose ( config check )
:param path:
docker_compose
contains the docker-compose file
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L283-L315 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __load_project | python | def __load_project(path):
'''
Load a docker-compose project from path
:param path:
:return:
'''
file_path = __get_docker_file_path(path)
if file_path is None:
msg = 'Could not find docker-compose file at {0}'.format(path)
return __standardize_result(False,
... | Load a docker-compose project from path
:param path:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L318-L331 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __load_project_from_file_path | python | def __load_project_from_file_path(file_path):
'''
Load a docker-compose project from file path
:param path:
:return:
'''
try:
project = get_project(project_dir=os.path.dirname(file_path),
config_path=[os.path.basename(file_path)])
except Exception as in... | Load a docker-compose project from file path
:param path:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L334-L346 | null |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __load_compose_definitions | python | def __load_compose_definitions(path, definition):
'''
Will load the compose file located at path
Then determines the format/contents of the sent definition
err or results are only set if there were any
:param path:
:param definition:
:return tuple(compose_result, loaded_definition, err):
... | Will load the compose file located at path
Then determines the format/contents of the sent definition
err or results are only set if there were any
:param path:
:param definition:
:return tuple(compose_result, loaded_definition, err): | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L349-L379 | [
"def load(stream, Loader=SaltYamlSafeLoader):\n return yaml.load(stream, Loader=Loader)\n",
"def deserialize(stream_or_string, **options):\n '''\n Deserialize any string or stream like object into a Python data structure.\n\n :param stream_or_string: stream or string to deserialize.\n :param option... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | __dump_compose_file | python | def __dump_compose_file(path, compose_result, success_msg, already_existed):
'''
Utility function to dump the compose result to a file.
:param path:
:param compose_result:
:param success_msg: the message to give upon success
:return:
'''
ret = __dump_docker_compose(path,
... | Utility function to dump the compose result to a file.
:param path:
:param compose_result:
:param success_msg: the message to give upon success
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L382-L397 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | _get_convergence_plans | python | def _get_convergence_plans(project, service_names):
'''
Get action executed for each container
:param project:
:param service_names:
:return:
'''
ret = {}
plans = project._get_convergence_plans(project.get_services(service_names),
ConvergenceSt... | Get action executed for each container
:param project:
:param service_names:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L413-L434 | null |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | get | python | def get(path):
'''
Get the content of the docker-compose file into a directory
path
Path where the docker-compose file is stored on the server
CLI Example:
.. code-block:: bash
salt myminion dockercompose.get /path/where/docker-compose/stored
'''
file_path = __get_docker_... | Get the content of the docker-compose file into a directory
path
Path where the docker-compose file is stored on the server
CLI Example:
.. code-block:: bash
salt myminion dockercompose.get /path/where/docker-compose/stored | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L437-L463 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | create | python | def create(path, docker_compose):
'''
Create and validate a docker-compose file into a directory
path
Path where the docker-compose file will be stored on the server
docker_compose
docker_compose file
CLI Example:
.. code-block:: bash
salt myminion dockercompose.crea... | Create and validate a docker-compose file into a directory
path
Path where the docker-compose file will be stored on the server
docker_compose
docker_compose file
CLI Example:
.. code-block:: bash
salt myminion dockercompose.create /path/where/docker-compose/stored content | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L466-L495 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | pull | python | def pull(path, service_names=None):
'''
Pull image for containers in the docker-compose file, service_names is a
python list, if omitted pull all images
path
Path where the docker-compose file is stored on the server
service_names
If specified will pull only the image for the specif... | Pull image for containers in the docker-compose file, service_names is a
python list, if omitted pull all images
path
Path where the docker-compose file is stored on the server
service_names
If specified will pull only the image for the specified services
CLI Example:
.. code-bloc... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L498-L525 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | pause | python | def pause(path, service_names=None):
'''
Pause running containers in the docker-compose file, service_names is a python
list, if omitted pause all containers
path
Path where the docker-compose file is stored on the server
service_names
If specified will pause only the specified serv... | Pause running containers in the docker-compose file, service_names is a python
list, if omitted pause all containers
path
Path where the docker-compose file is stored on the server
service_names
If specified will pause only the specified services
CLI Example:
.. code-block:: bash
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L637-L671 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | rm | python | def rm(path, service_names=None):
'''
Remove stopped containers in the docker-compose file, service_names is a python
list, if omitted remove all stopped containers
path
Path where the docker-compose file is stored on the server
service_names
If specified will remove only the specif... | Remove stopped containers in the docker-compose file, service_names is a python
list, if omitted remove all stopped containers
path
Path where the docker-compose file is stored on the server
service_names
If specified will remove only the specified stopped services
CLI Example:
..... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L785-L811 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | ps | python | def ps(path):
'''
List all running containers and report some information about them
path
Path where the docker-compose file is stored on the server
CLI Example:
.. code-block:: bash
salt myminion dockercompose.ps /path/where/docker-compose/stored
'''
project = __load_pr... | List all running containers and report some information about them
path
Path where the docker-compose file is stored on the server
CLI Example:
.. code-block:: bash
salt myminion dockercompose.ps /path/where/docker-compose/stored | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L814-L854 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | up | python | def up(path, service_names=None):
'''
Create and start containers defined in the docker-compose.yml file
located in path, service_names is a python list, if omitted create and
start all containers
path
Path where the docker-compose file is stored on the server
service_names
If s... | Create and start containers defined in the docker-compose.yml file
located in path, service_names is a python list, if omitted create and
start all containers
path
Path where the docker-compose file is stored on the server
service_names
If specified will create and start only the specif... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L857-L891 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | service_upsert | python | def service_upsert(path, service_name, definition):
'''
Create or update the definition of a docker-compose service
This does not pull or up the service
This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
path
Path where the docker-compose file is stored ... | Create or update the definition of a docker-compose service
This does not pull or up the service
This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
path
Path where the docker-compose file is stored on the server
service_name
Name of the service to cr... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L927-L956 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | service_remove | python | def service_remove(path, service_name):
'''
Remove the definition of a docker-compose service
This does not rm the container
This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
path
Path where the docker-compose file is stored on the server
service_na... | Remove the definition of a docker-compose service
This does not rm the container
This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
path
Path where the docker-compose file is stored on the server
service_name
Name of the service to remove
CLI Ex... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L959-L987 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/modules/dockercompose.py | service_set_tag | python | def service_set_tag(path, service_name, tag):
'''
Change the tag of a docker-compose service
This does not pull or up the service
This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
path
Path where the docker-compose file is stored on the server
servi... | Change the tag of a docker-compose service
This does not pull or up the service
This wil re-write your yaml file. Comments will be lost. Indentation is set to 2 spaces
path
Path where the docker-compose file is stored on the server
service_name
Name of the service to remove
tag
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L990-L1025 | [
"def __standardize_result(status, message, data=None, debug_msg=None):\n '''\n Standardizes all responses\n\n :param status:\n :param message:\n :param data:\n :param debug_msg:\n :return:\n '''\n result = {\n 'status': status,\n 'message': message\n }\n\n if data is n... |
# -*- coding: utf-8 -*-
'''
Module to import docker-compose via saltstack
.. versionadded:: 2016.3.0
:maintainer: Jean Praloran <jeanpralo@gmail.com>
:maturity: new
:depends: docker-compose>=1.5
:platform: all
Introduction
------------
This module allows one to deal with docker-compose file in a directory.
This is... |
saltstack/salt | salt/state.py | split_low_tag | python | def split_low_tag(tag):
'''
Take a low tag and split it back into the low dict that it came from
'''
state, id_, name, fun = tag.split('_|-')
return {'state': state,
'__id__': id_,
'name': name,
'fun': fun} | Take a low tag and split it back into the low dict that it came from | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L144-L153 | null | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | _calculate_fake_duration | python | def _calculate_fake_duration():
'''
Generate a NULL duration for when states do not run
but we want the results to be consistent.
'''
utc_start_time = datetime.datetime.utcnow()
local_start_time = utc_start_time - \
(datetime.datetime.utcnow() - datetime.datetime.now())
utc_finish_ti... | Generate a NULL duration for when states do not run
but we want the results to be consistent. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L178-L192 | null | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | get_accumulator_dir | python | def get_accumulator_dir(cachedir):
'''
Return the directory that accumulator data is stored in, creating it if it
doesn't exist.
'''
fn_ = os.path.join(cachedir, 'accumulator')
if not os.path.isdir(fn_):
# accumulator_dir is not present, create it
os.makedirs(fn_)
return fn_ | Return the directory that accumulator data is stored in, creating it if it
doesn't exist. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L195-L204 | null | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | trim_req | python | def trim_req(req):
'''
Trim any function off of a requisite
'''
reqfirst = next(iter(req))
if '.' in reqfirst:
return {reqfirst.split('.')[0]: req[reqfirst]}
return req | Trim any function off of a requisite | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L207-L214 | null | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | state_args | python | def state_args(id_, state, high):
'''
Return a set of the arguments passed to the named state
'''
args = set()
if id_ not in high:
return args
if state not in high[id_]:
return args
for item in high[id_][state]:
if not isinstance(item, dict):
continue
... | Return a set of the arguments passed to the named state | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L217-L232 | null | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | find_name | python | def find_name(name, state, high):
'''
Scan high data for the id referencing the given name and return a list of (IDs, state) tuples that match
Note: if `state` is sls, then we are looking for all IDs that match the given SLS
'''
ext_id = []
if name in high:
ext_id.append((name, state))
... | Scan high data for the id referencing the given name and return a list of (IDs, state) tuples that match
Note: if `state` is sls, then we are looking for all IDs that match the given SLS | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L235-L262 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | find_sls_ids | python | def find_sls_ids(sls, high):
'''
Scan for all ids in the given sls and return them in a dict; {name: state}
'''
ret = []
for nid, item in six.iteritems(high):
try:
sls_tgt = item['__sls__']
except TypeError:
if nid != '__exclude__':
log.error(
... | Scan for all ids in the given sls and return them in a dict; {name: state} | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L265-L286 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | format_log | python | def format_log(ret):
'''
Format the state into a log message
'''
msg = ''
if isinstance(ret, dict):
# Looks like the ret may be a valid state return
if 'changes' in ret:
# Yep, looks like a valid state return
chg = ret['changes']
if not chg:
... | Format the state into a log message | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L289-L330 | [
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | master_compile | python | def master_compile(master_opts, minion_opts, grains, id_, saltenv):
'''
Compile the master side low state data, and build the hidden state file
'''
st_ = MasterHighState(master_opts, minion_opts, grains, id_, saltenv)
return st_.compile_highstate() | Compile the master side low state data, and build the hidden state file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L333-L338 | [
"def compile_highstate(self):\n '''\n Return just the highstate or the errors\n '''\n err = []\n top = self.get_top()\n err += self.verify_tops(top)\n matches = self.top_matches(top)\n high, errors = self.render_highstate(matches)\n err += errors\n\n if err:\n return err\n\n ... | # -*- coding: utf-8 -*-
'''
The State Compiler is used to execute states in Salt. A state is unlike
an execution module in that instead of just executing a command, it
ensures that a certain state is present on the system.
The data sent to the state calls is as follows:
{ 'state': '<state module name>',
'fun... |
saltstack/salt | salt/state.py | Compiler.render_template | python | def render_template(self, template, **kwargs):
'''
Enforce the states in a template
'''
high = compile_template(template,
self.rend,
self.opts['renderer'],
self.opts['renderer_blacklist'],
... | Enforce the states in a template | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L381-L393 | [
"def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n input_data='',\n **kwargs):\n '''\n Ta... | class Compiler(object):
'''
Class used to compile and manage the High Data structure
'''
def __init__(self, opts, renderers):
self.opts = opts
self.rend = renderers
def pad_funcs(self, high):
'''
Turns dot delimited function refs into function strings
'''
... |
saltstack/salt | salt/state.py | Compiler.pad_funcs | python | def pad_funcs(self, high):
'''
Turns dot delimited function refs into function strings
'''
for name in high:
if not isinstance(high[name], dict):
if isinstance(high[name], six.string_types):
# Is this is a short state? It needs to be padded... | Turns dot delimited function refs into function strings | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L395-L442 | null | class Compiler(object):
'''
Class used to compile and manage the High Data structure
'''
def __init__(self, opts, renderers):
self.opts = opts
self.rend = renderers
def render_template(self, template, **kwargs):
'''
Enforce the states in a template
'''
... |
saltstack/salt | salt/state.py | Compiler.verify_high | python | def verify_high(self, high):
'''
Verify that the high data is viable and follows the data structure
'''
errors = []
if not isinstance(high, dict):
errors.append('High data is not a dictionary and is invalid')
reqs = OrderedDict()
for name, body in six.... | Verify that the high data is viable and follows the data structure | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L444-L584 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | class Compiler(object):
'''
Class used to compile and manage the High Data structure
'''
def __init__(self, opts, renderers):
self.opts = opts
self.rend = renderers
def render_template(self, template, **kwargs):
'''
Enforce the states in a template
'''
... |
saltstack/salt | salt/state.py | Compiler.order_chunks | python | def order_chunks(self, chunks):
'''
Sort the chunk list verifying that the chunks follow the order
specified in the order options.
'''
cap = 1
for chunk in chunks:
if 'order' in chunk:
if not isinstance(chunk['order'], int):
... | Sort the chunk list verifying that the chunks follow the order
specified in the order options. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L586-L618 | [
"def decode(data, encoding=None, errors='strict', keep=False,\n normalize=False, preserve_dict_class=False, preserve_tuples=False,\n to_str=False):\n '''\n Generic function which will decode whichever type is passed, if necessary.\n Optionally use to_str=True to ensure strings are str t... | class Compiler(object):
'''
Class used to compile and manage the High Data structure
'''
def __init__(self, opts, renderers):
self.opts = opts
self.rend = renderers
def render_template(self, template, **kwargs):
'''
Enforce the states in a template
'''
... |
saltstack/salt | salt/state.py | Compiler.apply_exclude | python | def apply_exclude(self, high):
'''
Read in the __exclude__ list and remove all excluded objects from the
high data
'''
if '__exclude__' not in high:
return high
ex_sls = set()
ex_id = set()
exclude = high.pop('__exclude__')
for exc in e... | Read in the __exclude__ list and remove all excluded objects from the
high data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L677-L711 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n"
] | class Compiler(object):
'''
Class used to compile and manage the High Data structure
'''
def __init__(self, opts, renderers):
self.opts = opts
self.rend = renderers
def render_template(self, template, **kwargs):
'''
Enforce the states in a template
'''
... |
saltstack/salt | salt/state.py | State._gather_pillar | python | def _gather_pillar(self):
'''
Whenever a state run starts, gather the pillar data fresh
'''
if self._pillar_override:
if self._pillar_enc:
try:
self._pillar_override = salt.utils.crypt.decrypt(
self._pillar_override,... | Whenever a state run starts, gather the pillar data fresh | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L767-L808 | [
"def load(stream, Loader=SaltYamlSafeLoader):\n return yaml.load(stream, Loader=Loader)\n",
"def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,\n pillar_override=None, pillarenv=None, extra_minion_data=None):\n '''\n Return the correct pillar driver based on the fil... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._mod_init | python | def _mod_init(self, low):
'''
Check the module initialization function, if this is the first run
of a state package that has a mod_init function, then execute the
mod_init function in the state module.
'''
# ensure that the module is loaded
try:
self.s... | Check the module initialization function, if this is the first run
of a state package that has a mod_init function, then execute the
mod_init function in the state module. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L810-L827 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._mod_aggregate | python | def _mod_aggregate(self, low, running, chunks):
'''
Execute the aggregation systems to runtime modify the low chunk
'''
agg_opt = self.functions['config.option']('state_aggregate')
if 'aggregate' in low:
agg_opt = low['aggregate']
if agg_opt is True:
... | Execute the aggregation systems to runtime modify the low chunk | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L829-L848 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._run_check | python | def _run_check(self, low_data):
'''
Check that unless doesn't return 0, and that onlyif returns a 0.
'''
ret = {'result': False, 'comment': []}
cmd_opts = {}
if 'shell' in self.opts['grains']:
cmd_opts['shell'] = self.opts['grains'].get('shell')
if '... | Check that unless doesn't return 0, and that onlyif returns a 0. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L850-L876 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._run_check_onlyif | python | def _run_check_onlyif(self, low_data, cmd_opts):
'''
Check that unless doesn't return 0, and that onlyif returns a 0.
'''
ret = {'result': False}
if not isinstance(low_data['onlyif'], list):
low_data_onlyif = [low_data['onlyif']]
else:
low_data_on... | Check that unless doesn't return 0, and that onlyif returns a 0. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L878-L921 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._run_check_cmd | python | def _run_check_cmd(self, low_data):
'''
Alter the way a successful state run is determined
'''
ret = {'result': False}
cmd_opts = {}
if 'shell' in self.opts['grains']:
cmd_opts['shell'] = self.opts['grains'].get('shell')
for entry in low_data['check_cm... | Alter the way a successful state run is determined | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L968-L985 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._load_states | python | def _load_states(self):
'''
Read the state loader value and loadup the correct states subsystem
'''
if self.states_loader == 'thorium':
self.states = salt.loader.thorium(self.opts, self.functions, {}) # TODO: Add runners, proxy?
else:
self.states = salt.l... | Read the state loader value and loadup the correct states subsystem | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L993-L1001 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.load_modules | python | def load_modules(self, data=None, proxy=None):
'''
Load the modules into the state
'''
log.info('Loading fresh modules for state activity')
self.utils = salt.loader.utils(self.opts)
self.functions = salt.loader.minion_mods(self.opts, self.state_con,
... | Load the modules into the state | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1003-L1035 | [
"def _load_states(self):\n '''\n Read the state loader value and loadup the correct states subsystem\n '''\n if self.states_loader == 'thorium':\n self.states = salt.loader.thorium(self.opts, self.functions, {}) # TODO: Add runners, proxy?\n else:\n self.states = salt.loader.states(sel... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.module_refresh | python | def module_refresh(self):
'''
Refresh all the modules
'''
log.debug('Refreshing modules...')
if self.opts['grains'].get('os') != 'MacOS':
# In case a package has been installed into the current python
# process 'site-packages', the 'site' module needs to b... | Refresh all the modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1037-L1054 | [
"def load_modules(self, data=None, proxy=None):\n '''\n Load the modules into the state\n '''\n log.info('Loading fresh modules for state activity')\n self.utils = salt.loader.utils(self.opts)\n self.functions = salt.loader.minion_mods(self.opts, self.state_con,\n ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.check_refresh | python | def check_refresh(self, data, ret):
'''
Check to see if the modules for this state instance need to be updated,
only update if the state is a file or a package and if it changed
something. If the file function is managed check to see if the file is a
possible module type, e.g. a ... | Check to see if the modules for this state instance need to be updated,
only update if the state is a file or a package and if it changed
something. If the file function is managed check to see if the file is a
possible module type, e.g. a python, pyx, or .so. Always refresh if the
funct... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1056-L1096 | [
"def _gather_pillar(self):\n '''\n Whenever a state run starts, gather the pillar data fresh\n '''\n if self._pillar_override:\n if self._pillar_enc:\n try:\n self._pillar_override = salt.utils.crypt.decrypt(\n self._pillar_override,\n ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.verify_data | python | def verify_data(self, data):
'''
Verify the data, return an error statement if something is wrong
'''
errors = []
if 'state' not in data:
errors.append('Missing "state" data')
if 'fun' not in data:
errors.append('Missing "fun" data')
if 'na... | Verify the data, return an error statement if something is wrong | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1098-L1186 | [
"def get_function_argspec(func, is_class_method=None):\n '''\n A small wrapper around getargspec that also supports callable classes\n :param is_class_method: Pass True if you are sure that the function being passed\n is a class method. The reason for this is that on Python 3\n ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.verify_chunks | python | def verify_chunks(self, chunks):
'''
Verify the chunks in a list of low data structures
'''
err = []
for chunk in chunks:
err.extend(self.verify_data(chunk))
return err | Verify the chunks in a list of low data structures | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1346-L1353 | [
"def verify_data(self, data):\n '''\n Verify the data, return an error statement if something is wrong\n '''\n errors = []\n if 'state' not in data:\n errors.append('Missing \"state\" data')\n if 'fun' not in data:\n errors.append('Missing \"fun\" data')\n if 'name' not in data:\n... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.order_chunks | python | def order_chunks(self, chunks):
'''
Sort the chunk list verifying that the chunks follow the order
specified in the order options.
'''
cap = 1
for chunk in chunks:
if 'order' in chunk:
if not isinstance(chunk['order'], int):
... | Sort the chunk list verifying that the chunks follow the order
specified in the order options. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1355-L1386 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.compile_high_data | python | def compile_high_data(self, high, orchestration_jid=None):
'''
"Compile" the high data as it is retrieved from the CLI or YAML into
the individual state executor structures
'''
chunks = []
for name, body in six.iteritems(high):
if name.startswith('__'):
... | "Compile" the high data as it is retrieved from the CLI or YAML into
the individual state executor structures | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1388-L1452 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def order_chunks(self, chunks):\n '''\n Sort the chunk list verifying that the chunks follow the order\n specified in the order options.\n '''\n cap = 1\n for chunk in chunks:\n... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.reconcile_extend | python | def reconcile_extend(self, high):
'''
Pull the extend data and add it to the respective high data
'''
errors = []
if '__extend__' not in high:
return high, errors
ext = high.pop('__extend__')
for ext_chunk in ext:
for name, body in six.iter... | Pull the extend data and add it to the respective high data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1454-L1520 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def find_name(name, state, high):\n '''\n Scan high data for the id referencing the given name and return a list of (IDs, state) tuples that match\n\n Note: if `state` is sls, then we are looking for all IDs that match the given SLS\n '''\n ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.requisite_in | python | def requisite_in(self, high):
'''
Extend the data reference with requisite_in arguments
'''
req_in = {'require_in', 'watch_in', 'onfail_in', 'onchanges_in', 'use', 'use_in', 'prereq', 'prereq_in'}
req_in_all = req_in.union({'require', 'watch', 'onfail', 'onfail_stop', 'onchanges'... | Extend the data reference with requisite_in arguments | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1562-L1787 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def state_args(id_, state, high):\n '''\n Return a set of the arguments passed to the named state\n '''\n args = set()\n if id_ not in high:\n return args\n if state not ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State._call_parallel_target | python | def _call_parallel_target(self, name, cdata, low):
'''
The target function to call that will create the parallel thread/process
'''
# we need to re-record start/end duration here because it is impossible to
# correctly calculate further down the chain
utc_start_time = dat... | The target function to call that will create the parallel thread/process | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1789-L1830 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_parallel | python | def call_parallel(self, cdata, low):
'''
Call the state defined in the given cdata in parallel
'''
# There are a number of possibilities to not have the cdata
# populated with what we might have expected, so just be smart
# enough to not raise another KeyError as the name... | Call the state defined in the given cdata in parallel | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1832-L1854 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call | python | def call(self, low, chunks=None, running=None, retries=1):
'''
Call a state directly with the low data structure, verify data
before processing.
'''
use_uptime = False
if os.path.isfile('/proc/uptime'):
use_uptime = True
with salt.utils.files.fopen... | Call a state directly with the low data structure, verify data
before processing. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L1857-L2100 | [
"def format_call(fun,\n data,\n initial_ret=None,\n expected_extra_kws=(),\n is_class_method=None):\n '''\n Build the required arguments and keyword arguments required for the passed\n function.\n\n :param fun: The function to get the argspec f... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.format_slots | python | def format_slots(self, cdata):
'''
Read in the arguments from the low level slot syntax to make a last
minute runtime call to gather relevant data for the specific routine
Will parse strings, first level of dictionary values, and strings and
first level dict values inside of lis... | Read in the arguments from the low level slot syntax to make a last
minute runtime call to gather relevant data for the specific routine
Will parse strings, first level of dictionary values, and strings and
first level dict values inside of lists | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2159-L2209 | [
"def decode(data, encoding=None, errors='strict', keep=False,\n normalize=False, preserve_dict_class=False, preserve_tuples=False,\n to_str=False):\n '''\n Generic function which will decode whichever type is passed, if necessary.\n Optionally use to_str=True to ensure strings are str t... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.verify_retry_data | python | def verify_retry_data(self, retry_data):
'''
verifies the specified retry data
'''
retry_defaults = {
'until': True,
'attempts': 2,
'splay': 0,
'interval': 30,
}
expected_data = {
'until': bool,
... | verifies the specified retry data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2211-L2246 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_chunks | python | def call_chunks(self, chunks):
'''
Iterate over a list of chunks and call them, checking for requires.
'''
# Check for any disabled states
disabled = {}
if 'state_runs_disabled' in self.opts['grains']:
for low in chunks[:]:
state_ = '{0}.{1}'.f... | Iterate over a list of chunks and call them, checking for requires. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2248-L2295 | [
"def _gen_tag(low):\n '''\n Generate the running dict tag string from the low data structure\n '''\n return '{0[state]}_|-{0[__id__]}_|-{0[name]}_|-{0[fun]}'.format(low)\n",
"def check_failhard(self, low, running):\n '''\n Check if the low data chunk should send a failhard signal\n '''\n t... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.check_failhard | python | def check_failhard(self, low, running):
'''
Check if the low data chunk should send a failhard signal
'''
tag = _gen_tag(low)
if self.opts.get('test', False):
return False
if low.get('failhard', self.opts['failhard']) and tag in running:
if running... | Check if the low data chunk should send a failhard signal | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2297-L2308 | [
"def _gen_tag(low):\n '''\n Generate the running dict tag string from the low data structure\n '''\n return '{0[state]}_|-{0[__id__]}_|-{0[name]}_|-{0[fun]}'.format(low)\n"
] | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.check_pause | python | def check_pause(self, low):
'''
Check to see if this low chunk has been paused
'''
if not self.jid:
# Can't pause on salt-ssh since we can't track continuous state
return
pause_path = os.path.join(self.opts['cachedir'], 'state_pause', self.jid)
sta... | Check to see if this low chunk has been paused | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2310-L2353 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.reconcile_procs | python | def reconcile_procs(self, running):
'''
Check the running dict for processes and resolve them
'''
retset = set()
for tag in running:
proc = running[tag].get('proc')
if proc:
if not proc.is_alive():
ret_cache = os.path.jo... | Check the running dict for processes and resolve them | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2355-L2385 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.check_requisite | python | def check_requisite(self, low, running, chunks, pre=False):
'''
Look into the running data to check the status of all requisite
states
'''
disabled_reqs = self.opts.get('disabled_requisites', [])
if not isinstance(disabled_reqs, list):
disabled_reqs = [disable... | Look into the running data to check the status of all requisite
states | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2387-L2572 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def _gen_tag(low):\n '''\n Generate the running dict tag string from the low data structure\n '''\n return '{0[state]}_|-{0[__id__]}_|-{0[name]}_|-{0[fun]}'.format(low)\n",
"def trim_req(req):\n '''\n Trim any function off of a requis... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.event | python | def event(self, chunk_ret, length, fire_event=False):
'''
Fire an event on the master bus
If `fire_event` is set to True an event will be sent with the
chunk name in the tag and the chunk result in the event data.
If `fire_event` is set to a string such as `mystate/is/finished`... | Fire an event on the master bus
If `fire_event` is set to True an event will be sent with the
chunk name in the tag and the chunk result in the event data.
If `fire_event` is set to a string such as `mystate/is/finished`,
an event will be sent with the string added to the tag and the c... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2574-L2611 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_chunk | python | def call_chunk(self, low, running, chunks):
'''
Check if a chunk has any requires, execute the requires and then
the chunk
'''
low = self._mod_aggregate(low, running, chunks)
self._mod_init(low)
tag = _gen_tag(low)
if not low.get('prerequired'):
... | Check if a chunk has any requires, execute the requires and then
the chunk | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2613-L2841 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n",
"def _gen_tag(low):\n '''\n Generate the running dict tag string from the low data structure\n '''\n return '{0[state]}_|-{0[__id__]}_|-{0[name]}_|-{0[fun]}'.format(low)\n",
"def... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_listen | python | def call_listen(self, chunks, running):
'''
Find all of the listen routines and call the associated mod_watch runs
'''
listeners = []
crefs = {}
for chunk in chunks:
crefs[(chunk['state'], chunk['__id__'], chunk['name'])] = chunk
if 'listen' in chu... | Find all of the listen routines and call the associated mod_watch runs | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2843-L2914 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def _l_tag(name, id_):\n low = {'name': 'listen_{0}'.format(name),\n '__id__': 'listen_{0}'.format(id_),\n 'state': 'Listen_Error',\n 'fun': 'Listen_Error'}\n return _gen_tag(low)\n",
"def call_chunks(self, chunks):\... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.inject_default_call | python | def inject_default_call(self, high):
'''
Sets .call function to a state, if not there.
:param high:
:return:
'''
for chunk in high:
state = high[chunk]
if not isinstance(state, collections.Mapping):
continue
for state_r... | Sets .call function to a state, if not there.
:param high:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2916-L2936 | null | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_high | python | def call_high(self, high, orchestration_jid=None):
'''
Process a high data call and ensure the defined states.
'''
self.inject_default_call(high)
errors = []
# If there is extension data reconcile it
high, ext_errors = self.reconcile_extend(high)
errors.ex... | Process a high data call and ensure the defined states. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L2938-L2986 | [
"def verify_high(self, high):\n '''\n Verify that the high data is viable and follows the data structure\n '''\n errors = []\n if not isinstance(high, dict):\n errors.append('High data is not a dictionary and is invalid')\n reqs = OrderedDict()\n for name, body in six.iteritems(high):\n ... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_template | python | def call_template(self, template):
'''
Enforce the states in a template
'''
high = compile_template(template,
self.rend,
self.opts['renderer'],
self.opts['renderer_blacklist'],
... | Enforce the states in a template | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3067-L3081 | [
"def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n input_data='',\n **kwargs):\n '''\n Ta... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | State.call_template_str | python | def call_template_str(self, template):
'''
Enforce the states in a template, pass the template as a string
'''
high = compile_template_str(template,
self.rend,
self.opts['renderer'],
... | Enforce the states in a template, pass the template as a string | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3083-L3097 | [
"def compile_template_str(template, renderers, default, blacklist, whitelist):\n '''\n Take template as a string and return the high data structure\n derived from the template.\n '''\n fn_ = salt.utils.files.mkstemp()\n with salt.utils.files.fopen(fn_, 'wb') as ofile:\n ofile.write(SLS_ENCO... | class State(object):
'''
Class used to execute salt states
'''
def __init__(
self,
opts,
pillar_override=None,
jid=None,
pillar_enc=None,
proxy=None,
context=None,
mocked=False,
loader='states',
... |
saltstack/salt | salt/state.py | BaseHighState.__gen_opts | python | def __gen_opts(self, opts):
'''
The options used by the High State object are derived from options
on the minion and the master, or just the minion if the high state
call is entirely local.
'''
# If the state is intended to be applied locally, then the local opts
... | The options used by the High State object are derived from options
on the minion and the master, or just the minion if the high state
call is entirely local. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3124-L3169 | [
"def create(path, saltenv=None):\n '''\n join `path` and `saltenv` into a 'salt://' URL.\n '''\n if salt.utils.platform.is_windows():\n path = salt.utils.path.sanitize_win_path(path)\n path = salt.utils.data.decode(path)\n\n query = 'saltenv={0}'.format(saltenv) if saltenv else ''\n url ... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._get_envs | python | def _get_envs(self):
'''
Pull the file server environments out of the master options
'''
envs = ['base']
if 'file_roots' in self.opts:
envs.extend([x for x in list(self.opts['file_roots'])
if x not in envs])
env_order = self.opts.get('... | Pull the file server environments out of the master options | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3171-L3191 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.get_tops | python | def get_tops(self):
'''
Gather the top files
'''
tops = DefaultOrderedDict(list)
include = DefaultOrderedDict(list)
done = DefaultOrderedDict(list)
found = 0 # did we find any contents in the top files?
# Gather initial top files
merging_strategy ... | Gather the top files | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3193-L3313 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n inp... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.merge_tops | python | def merge_tops(self, tops):
'''
Cleanly merge the top files
'''
merging_strategy = self.opts['top_file_merging_strategy']
try:
merge_attr = '_merge_tops_{0}'.format(merging_strategy)
merge_func = getattr(self, merge_attr)
if not hasattr(merge_f... | Cleanly merge the top files | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3315-L3333 | [
"def _merge_tops_merge(self, tops):\n '''\n The default merging strategy. The base env is authoritative, so it is\n checked first, followed by the remaining environments. In top files\n from environments other than \"base\", only the section matching the\n environment from the top file will be consid... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._merge_tops_merge | python | def _merge_tops_merge(self, tops):
'''
The default merging strategy. The base env is authoritative, so it is
checked first, followed by the remaining environments. In top files
from environments other than "base", only the section matching the
environment from the top file will b... | The default merging strategy. The base env is authoritative, so it is
checked first, followed by the remaining environments. In top files
from environments other than "base", only the section matching the
environment from the top file will be considered, and it too will be
ignored if tha... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3335-L3384 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._merge_tops_same | python | def _merge_tops_same(self, tops):
'''
For each saltenv, only consider the top file from that saltenv. All
sections matching a given saltenv, which appear in a different
saltenv's top file, will be ignored.
'''
top = DefaultOrderedDict(OrderedDict)
for cenv, ctops ... | For each saltenv, only consider the top file from that saltenv. All
sections matching a given saltenv, which appear in a different
saltenv's top file, will be ignored. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3386-L3447 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._merge_tops_merge_all | python | def _merge_tops_merge_all(self, tops):
'''
Merge the top files into a single dictionary
'''
def _read_tgt(tgt):
match_type = None
states = []
for item in tgt:
if isinstance(item, dict):
match_type = item
... | Merge the top files into a single dictionary | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3449-L3485 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.verify_tops | python | def verify_tops(self, tops):
'''
Verify the contents of the top file data
'''
errors = []
if not isinstance(tops, dict):
errors.append('Top data was not formed as a dict')
# No further checks will work, bail out
return errors
for salten... | Verify the contents of the top file data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3487-L3536 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n"
] | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.get_top | python | def get_top(self):
'''
Returns the high data derived from the top file
'''
try:
tops = self.get_tops()
except SaltRenderError as err:
log.error('Unable to render top file: %s', err.error)
return {}
return self.merge_tops(tops) | Returns the high data derived from the top file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3538-L3547 | [
"def get_tops(self):\n '''\n Gather the top files\n '''\n tops = DefaultOrderedDict(list)\n include = DefaultOrderedDict(list)\n done = DefaultOrderedDict(list)\n found = 0 # did we find any contents in the top files?\n # Gather initial top files\n merging_strategy = self.opts['top_file_... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.top_matches | python | def top_matches(self, top):
'''
Search through the top high data for matches and return the states
that this minion needs to execute.
Returns:
{'saltenv': ['state1', 'state2', ...]}
'''
matches = DefaultOrderedDict(OrderedDict)
# pylint: disable=cell-var-... | Search through the top high data for matches and return the states
that this minion needs to execute.
Returns:
{'saltenv': ['state1', 'state2', ...]} | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3549-L3601 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def _master_tops(self):\n '''\n Get results from the master_tops system. Override this function if the\n execution of the master_tops needs customization.\n '''\n return self.client.master_tops()\n",
"def _master_tops(self):\n '''\n ... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.load_dynamic | python | def load_dynamic(self, matches):
'''
If autoload_dynamic_modules is True then automatically load the
dynamic modules
'''
if not self.opts['autoload_dynamic_modules']:
return
syncd = self.state.functions['saltutil.sync_all'](list(matches),
... | If autoload_dynamic_modules is True then automatically load the
dynamic modules | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3610-L3622 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.render_state | python | def render_state(self, sls, saltenv, mods, matches, local=False):
'''
Render a state file and retrieve all of the include states
'''
errors = []
if not local:
state_data = self.client.get_state(sls, saltenv)
fn_ = state_data.get('dest', False)
else... | Render a state file and retrieve all of the include states | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3624-L3807 | [
"def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n input_data='',\n **kwargs):\n '''\n Ta... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._handle_iorder | python | def _handle_iorder(self, state):
'''
Take a state and apply the iorder system
'''
if self.opts['state_auto_order']:
for name in state:
for s_dec in state[name]:
if not isinstance(s_dec, six.string_types):
# PyDSL Ord... | Take a state and apply the iorder system | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3809-L3844 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._handle_state_decls | python | def _handle_state_decls(self, state, sls, saltenv, errors):
'''
Add sls and saltenv components to the state
'''
for name in state:
if not isinstance(state[name], dict):
if name == '__extend__':
continue
if name == '__exclude... | Add sls and saltenv components to the state | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3846-L3901 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._handle_extend | python | def _handle_extend(self, state, sls, saltenv, errors):
'''
Take the extend dec out of state and apply to the highstate global
dec
'''
if 'extend' in state:
ext = state.pop('extend')
if not isinstance(ext, dict):
errors.append(('Extension va... | Take the extend dec out of state and apply to the highstate global
dec | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3903-L3933 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._handle_exclude | python | def _handle_exclude(self, state, sls, saltenv, errors):
'''
Take the exclude dec out of the state and apply it to the highstate
global dec
'''
if 'exclude' in state:
exc = state.pop('exclude')
if not isinstance(exc, list):
err = ('Exclude D... | Take the exclude dec out of the state and apply it to the highstate
global dec | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3935-L3946 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.render_highstate | python | def render_highstate(self, matches):
'''
Gather the state files and render them into a single unified salt
high data structure.
'''
highstate = self.building_highstate
all_errors = []
mods = set()
statefiles = []
for saltenv, states in six.iteritem... | Gather the state files and render them into a single unified salt
high data structure. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L3948-L3995 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def render_state(self, sls, saltenv, mods, matches, local=False):\n '''\n Render a state file and retrieve all of the include states\n '''\n errors = []\n if not local:\n state_data = self.client.get_state(sls, saltenv)\n fn_... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState._check_pillar | python | def _check_pillar(self, force=False):
'''
Check the pillar for errors, refuse to run the state if there are
errors in the pillar and return the pillar errors
'''
if force:
return True
if '_errors' in self.state.opts['pillar']:
return False
... | Check the pillar for errors, refuse to run the state if there are
errors in the pillar and return the pillar errors | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4035-L4044 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.matches_whitelist | python | def matches_whitelist(self, matches, whitelist):
'''
Reads over the matches and returns a matches dict with just the ones
that are in the whitelist
'''
if not whitelist:
return matches
ret_matches = {}
if not isinstance(whitelist, list):
wh... | Reads over the matches and returns a matches dict with just the ones
that are in the whitelist | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4046-L4061 | null | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.call_highstate | python | def call_highstate(self, exclude=None, cache=None, cache_name='highstate',
force=False, whitelist=None, orchestration_jid=None):
'''
Run the sequence to execute the salt highstate for this minion
'''
# Check that top file exists
tag_name = 'no_|-states_|-st... | Run the sequence to execute the salt highstate for this minion | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4063-L4142 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.compile_highstate | python | def compile_highstate(self):
'''
Return just the highstate or the errors
'''
err = []
top = self.get_top()
err += self.verify_tops(top)
matches = self.top_matches(top)
high, errors = self.render_highstate(matches)
err += errors
if err:
... | Return just the highstate or the errors | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4144-L4158 | [
"def verify_tops(self, tops):\n '''\n Verify the contents of the top file data\n '''\n errors = []\n if not isinstance(tops, dict):\n errors.append('Top data was not formed as a dict')\n # No further checks will work, bail out\n return errors\n for saltenv, matches in six.iter... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.compile_low_chunks | python | def compile_low_chunks(self):
'''
Compile the highstate but don't run it, return the low chunks to
see exactly what the highstate will execute
'''
top = self.get_top()
matches = self.top_matches(top)
high, errors = self.render_highstate(matches)
# If ther... | Compile the highstate but don't run it, return the low chunks to
see exactly what the highstate will execute | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4160-L4185 | [
"def verify_high(self, high):\n '''\n Verify that the high data is viable and follows the data structure\n '''\n errors = []\n if not isinstance(high, dict):\n errors.append('High data is not a dictionary and is invalid')\n reqs = OrderedDict()\n for name, body in six.iteritems(high):\n ... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | BaseHighState.compile_state_usage | python | def compile_state_usage(self):
'''
Return all used and unused states for the minion based on the top match data
'''
err = []
top = self.get_top()
err += self.verify_tops(top)
if err:
return err
matches = self.top_matches(top)
state_us... | Return all used and unused states for the minion based on the top match data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4187-L4223 | [
"def verify_tops(self, tops):\n '''\n Verify the contents of the top file data\n '''\n errors = []\n if not isinstance(tops, dict):\n errors.append('Top data was not formed as a dict')\n # No further checks will work, bail out\n return errors\n for saltenv, matches in six.iter... | class BaseHighState(object):
'''
The BaseHighState is an abstract base class that is the foundation of
running a highstate, extend it and add a self.state object of type State.
When extending this class, please note that ``self.client`` and
``self.matcher`` should be instantiated and handled.
'... |
saltstack/salt | salt/state.py | MasterState.load_modules | python | def load_modules(self, data=None, proxy=None):
'''
Load the modules into the state
'''
log.info('Loading fresh modules for state activity')
# Load a modified client interface that looks like the interface used
# from the minion, but uses remote execution
#
... | Load the modules into the state | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4298-L4315 | null | class MasterState(State):
'''
Create a State object for master side compiling
'''
def __init__(self, opts, minion):
State.__init__(self, opts)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.