text
stringlengths
81
112k
.. versionadded:: 2019.2.0 Delete a route from a route table. :param name: The route to delete. :param route_table: The route table containing the route. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash salt-call...
.. versionadded:: 2019.2.0 Get details about a specific route. :param name: The route to query. :param route_table: The route table containing the route. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash salt-call...
.. versionadded:: 2019.2.0 Create or update a route within a specified route table. :param name: The name of the route to create. :param address_prefix: The destination CIDR to which the route applies. :param next_hop_type: The type of Azure hop the packet should be sent to. Possible values are: ...
.. versionadded:: 2019.2.0 List all routes within a route table. :param route_table: The route table to query. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash salt-call azurearm_network.routes_list test-rt-table test...
.. versionadded:: 2019.2.0 Delete a route table. :param name: The name of the route table to delete. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash salt-call azurearm_network.route_table_delete test-rt-table testgro...
.. versionadded:: 2019.2.0 Get details about a specific route table. :param name: The name of the route table to query. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash salt-call azurearm_network.route_table_get test-...
.. versionadded:: 2019.2.0 Create or update a route table within a specified resource group. :param name: The name of the route table to create. :param resource_group: The resource group name assigned to the route table. CLI Example: .. code-block:: bash salt-call azurearm_netw...
.. versionadded:: 2019.2.0 List all route tables within a resource group. :param resource_group: The resource group name to list route tables within. CLI Example: .. code-block:: bash salt-call azurearm_network.route_tables_list testgroup def route_tables_list(resource_group, **kwa...
.. versionadded:: 2019.2.0 List all route tables within a subscription. CLI Example: .. code-block:: bash salt-call azurearm_network.route_tables_list_all def route_tables_list_all(**kwargs): ''' .. versionadded:: 2019.2.0 List all route tables within a subscription. CLI Examp...
Given a specific platform (under the Capirca conventions), return the generator class. The generator class is identified looking under the <platform> module for a class inheriting the `ACLGenerator` class. def _import_platform_generator(platform): ''' Given a specific platform (under the Capirca co...
Build a map of services based on the IANA assignment list: http://www.iana.org/assignments/port-numbers It will load the /etc/services file and will build the mapping on the fly, similar to the Capirca's SERVICES file: https://github.com/google/capirca/blob/master/def/SERVICES.svc As this module i...
Look into services and return the port value using the service name as lookup value. def _translate_port(port): ''' Look into services and return the port value using the service name as lookup value. ''' services = _get_services_mapping() if port in services and services[port]['port']: ...
Return the object list. def _make_it_list(dict_, field_name, value): ''' Return the object list. ''' prev_value = [] # firsly we'll collect the prev value if field_name in dict_: prev_value = dict_[field_name] if value is None: return prev_value elif isinstance(value, (t...
Cleanup the term opts: - strip Null and empty valuee, defaulting their value to their base definition from _TERM_FIELDS - convert to `nacaddr.IP` fields from `_IP_FILEDS` - create lists for those fields requiring it def _clean_term_opts(term_opts): ''' Cleanup the term opts: - strip Null and ...
Find an dictionary in a list of dictionaries, given its main key. def _lookup_element(lst, key): ''' Find an dictionary in a list of dictionaries, given its main key. ''' if not lst: return {} for ele in lst: if not ele or not isinstance(ele, dict): continue if e...
Retrieve the pillar data from the right environment. def _get_pillar_cfg(pillar_key, pillarenv=None, saltenv=None): ''' Retrieve the pillar data from the right environment. ''' pillar_cfg = __salt__['pillar.get'](pillar_key, ...
Return a list of non-empty dictionaries. def _cleanup(lst): ''' Return a list of non-empty dictionaries. ''' clean = [] for ele in lst: if ele and isinstance(ele, dict): clean.append(ele) return clean
Merge lists of dictionaries. Each element of the list is a dictionary having one single key. That key is then used as unique lookup. The first element list has higher priority than the second. When there's an overlap between the two lists, it won't change the position, but the content. def _merge_l...
Return an instance of the ``_Term`` class given the term options. def _get_term_object(filter_name, term_name, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, **term_fields):...
Return an instance of the ``_Policy`` class given the filters config. def _get_policy_object(platform, filters=None, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True): ''' Return ...
Refactor revision tag comments. Capirca generates the filter text having the following tag keys: - $Id:$ - $Revision:$ - $Date:$ This function goes through all the config lines and replaces those tags with the content requested by the user. If a certain value is not provided, the correspon...
Return the configuration of a single policy term. platform The name of the Capirca platform. filter_name The name of the policy filter. term_name The name of the term. filter_options Additional filter options. These options are platform-specific. E.g.: ``inet6...
Return the configuration of a policy filter. platform The name of the Capirca platform. filter_name The name of the policy filter. filter_options Additional filter options. These options are platform-specific. See the complete list of options_. .. _options: https:...
Return the configuration of the whole policy. platform The name of the Capirca platform. filters List of filters for this policy. If not specified or empty, will try to load the configuration from the pillar, unless ``merge_pillar`` is set as ``False``. prepend: ``True`` ...
Helper that can be used inside a state SLS, in order to get the filter configuration given its name. filter_name The name of the filter. pillar_key The root key of the whole policy config. pillarenv Query the master to generate fresh pillar data on the fly, specificall...
Helper that can be used inside a state SLS, in order to get the term configuration given its name, under a certain filter uniquely identified by its name. filter_name The name of the filter. term_name The name of the term. pillar_key: ``acl`` The root key of the whole poli...
Execute the salt call! def run(self): ''' Execute the salt call! ''' self.parse_args() if self.options.file_root: # check if the argument is pointing to a file on disk file_root = os.path.abspath(self.options.file_root) self.config['file_root...
Add content to a document generated using `highstate_doc.render`. This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers to include extra documents. .. code-block:: yaml {{sls}} example note: highstate_doc.note: - name:...
.. versionadded:: 2017.7.0 List updates that match the passed criteria. This allows for more filter options than :func:`list`. Good for finding a specific GUID or KB. Args: software (bool): Include software updates in the results (default is True) drivers (bool): ...
.. versionadded:: 2017.7.0 Returns details for the named update Args: name (str): The name of the update you're searching for. This can be the GUID, a KB number, or any part of the name of the update. GUIDs and KBs are preferred. Run ``list`` to get the GUID for th...
.. versionadded:: 2017.7.0 Returns a detailed list of available updates or a summary. If download or install is True the same list will be downloaded and/or installed. Args: software (bool): Include software updates in the results (default is True) drivers (bool): ...
.. versionadded:: 2017.7.0 Downloads updates that match the list of passed identifiers. It's easier to use this function by using list_updates and setting install=True. Args: names (str, list): A single update or a list of updates to download. This can be any combination o...
.. versionadded:: 2017.7.0 Uninstall updates. Args: names (str, list): A single update or a list of updates to uninstall. This can be any combination of GUIDs, KB numbers, or names. GUIDs or KBs are preferred. Returns: dict: A dictionary containing th...
Change Windows Update settings. If no parameters are passed, the current value will be returned. Supported: - Windows Vista / Server 2008 - Windows 7 / Server 2008R2 - Windows 8 / Server 2012 - Windows 8.1 / Server 2012R2 .. note: Microsoft began using the Unified U...
Get current Windows Update settings. Returns: dict: A dictionary of Windows Update settings: Featured Updates: Boolean value that indicates whether to display notifications for featured updates. Group Policy Required (Read-only): Boolean value that indi...
Check to see if Microsoft Update is Enabled Return Boolean def _get_msupdate_status(): ''' Check to see if Microsoft Update is Enabled Return Boolean ''' # To get the status of Microsoft Update we actually have to check the # Microsoft Update Service Manager # Initialize the PyCom syste...
Get metadata about an S3 object. Returns None if the object does not exist. You can pass AWS SSE-C related args and/or RequestPayer in extra_args. CLI Example: .. code-block:: bash salt myminion boto_s3.get_object_metadata \\ my_bucket/path/to/object \\ ...
Upload a local file as an S3 object. CLI Example: .. code-block:: bash salt myminion boto_s3.upload_file \\ /path/to/local/file \\ my_bucket/path/to/object \\ region=us-east-1 \\ key=key \\ ...
Decorator for adding profiling to a nested function in Salt def profile_func(filename=None): ''' Decorator for adding profiling to a nested function in Salt ''' def proffunc(fun): def profiled_func(*args, **kwargs): logging.info('Profiling function %s', fun.__name__) try...
Return the django admin def _get_django_admin(bin_env): ''' Return the django admin ''' if not bin_env: if salt.utils.path.which('django-admin.py'): return 'django-admin.py' elif salt.utils.path.which('django-admin'): return 'django-admin' else: ...
Run arbitrary django management command CLI Example: .. code-block:: bash salt '*' django.command <settings_module> <command> def command(settings_module, command, bin_env=None, pythonpath=None, env=None, runas=None, *args, **kw...
Run syncdb Execute the Django-Admin syncdb command, if South is available on the minion the ``migrate`` option can be passed as ``True`` calling the migrations to run after the syncdb completes NOTE: The syncdb command was deprecated in Django 1.7 and removed in Django 1.9. For Django versions 1.9...
Run migrate Execute the Django-Admin migrate command (requires Django 1.7 or higher). .. versionadded:: Neon settings_module Specifies the settings module to use. The settings module should be in Python package syntax, e.g. mysite.settings. If this isn’t provided, django-admin wil...
Create a super user for the database. This function defaults to use the ``--noinput`` flag which prevents the creation of a password for the superuser. CLI Example: .. code-block:: bash salt '*' django.createsuperuser <settings_module> user user@example.com def createsuperuser(settings_modul...
Load fixture data Fixtures: comma separated list of fixtures to load CLI Example: .. code-block:: bash salt '*' django.loaddata <settings_module> <comma delimited list of fixtures> def loaddata(settings_module, fixtures, bin_env=None, database=None...
Collect static files from each of your applications into a single location that can easily be served in production. CLI Example: .. code-block:: bash salt '*' django.collectstatic <settings_module> def collectstatic(settings_module, bin_env=None, no_post_proce...
Grant the requested privilege(s) on the specified object to a role name Name of the role to which privileges should be granted object_name Name of the object on which the grant is to be performed. 'ALL' may be used for objects of type 'table' or 'sequence'. object_type The ob...
List configured exports CLI Example: .. code-block:: bash salt '*' nfs.list_exports def list_exports(exports='/etc/exports'): ''' List configured exports CLI Example: .. code-block:: bash salt '*' nfs.list_exports ''' ret = {} with salt.utils.files.fopen(export...
Remove an export CLI Example: .. code-block:: bash salt '*' nfs.del_export /media/storage def del_export(exports='/etc/exports', path=None): ''' Remove an export CLI Example: .. code-block:: bash salt '*' nfs.del_export /media/storage ''' edict = list_exports(expor...
Add an export CLI Example: .. code-block:: bash salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw'] def add_export(exports='/etc/exports', path=None, hosts=None, options=None): ''' Add an export CLI Example: .. code-block:: bash salt '*' nfs3.add_exp...
Write an exports file to disk If multiple shares were initially configured per line, like: /media/storage /media/data *(ro,sync,no_subtree_check) ...then they will be saved to disk with only one share per line: /media/storage *(ro,sync,no_subtree_check) /media/data *(ro,sync,no_subtr...
Trigger a reload of the exports file to apply changes CLI Example: .. code-block:: bash salt '*' nfs3.reload_exports def reload_exports(): ''' Trigger a reload of the exports file to apply changes CLI Example: .. code-block:: bash salt '*' nfs3.reload_exports ''' r...
.. versionchanged:: 2018.3.0 The ``tag`` argument has been added. It is now required unless pulling from a registry. Ensure that an image is present. The image can either be pulled from a Docker registry, built from a Dockerfile, loaded from a saved image, or built by running SLS files agai...
Ensure that an image is absent from the Minion. Image names can be specified either using ``repo:tag`` notation, or just the repo name (in which case a tag of ``latest`` is assumed). images Run this state on more than one image at a time. The following two examples accomplish the same thing...
The docker_image watcher, called to invoke the watch command. .. note:: This state exists to support special handling of the ``watch`` :ref:`requisite <requisites>`. It should not be called directly. Parameters for this function should be set by the state being triggered. def mod_watch(n...
Render a Genshi template. A method should be passed in as part of the kwargs. If no method is passed in, xml is assumed. Valid methods are: .. code-block: - xml - xhtml - html - text - newtext - oldtext Note that the ``text`` method will call ``NewTextTempl...
Display ret data def output(ret, **kwargs): ''' Display ret data ''' # Prefer kwargs before opts retcode = kwargs.get('_retcode', 0) base_indent = kwargs.get('nested_indent', 0) \ or __opts__.get('nested_indent', 0) nest = NestDisplay(retcode=retcode) lines = nest.display(ret, b...
Recursively iterate down through data structures to determine output def display(self, ret, indent, prefix, out): ''' Recursively iterate down through data structures to determine output ''' if isinstance(ret, bytes): try: ret = salt.utils.stringutils.to_unic...
Reads and returns the contents of a text file def _read_file(path): ''' Reads and returns the contents of a text file ''' try: with salt.utils.files.fopen(path, 'rb') as contents: return salt.utils.yaml.safe_load(contents) except (OSError, IOError): return {}
Write the mount cache file. def write_cache(cache, opts): ''' Write the mount cache file. ''' cache_file = get_cache(opts) try: _cache = salt.utils.stringutils.to_bytes( salt.utils.yaml.safe_dump(cache) ) with salt.utils.files.fopen(cache_file, 'wb+') as fp_: ...
Returns the diff of two text blobs. def _get_diff_text(old, new): ''' Returns the diff of two text blobs. ''' diff = difflib.unified_diff(old.splitlines(1), new.splitlines(1)) return ''.join([x.replace('\r', '') for x in diff])
Return the config as text from a config tree. def _print_config_text(tree, indentation=0): ''' Return the config as text from a config tree. ''' config = '' for key, value in six.iteritems(tree): config += '{indent}{line}\n'.format(indent=' '*indentation, line=key) if value: ...
Transform Cisco IOS style configuration to structured Python dictionary. Depending on the value of the ``with_tags`` argument, this function may provide different views, valuable in different situations. config The configuration sent as text. This argument is ignored when ``path`` is config...
Return a clean version of the config, without any special signs (such as ``!`` as an individual line) or empty lines, but just lines with significant value in the configuration of the network device. config The configuration sent as text. This argument is ignored when ``path`` is configured...
Return the merge tree of the ``initial_config`` with the ``merge_config``, as a Python dictionary. initial_config The initial configuration sent as text. This argument is ignored when ``initial_path`` is set. initial_path Absolute or remote path from where to load the initial confi...
Return the merge result of the ``initial_config`` with the ``merge_config``, as plain text. initial_config The initial configuration sent as text. This argument is ignored when ``initial_path`` is set. initial_path Absolute or remote path from where to load the initial configuratio...
Return the merge diff, as text, after merging the merge config into the initial config. initial_config The initial configuration sent as text. This argument is ignored when ``initial_path`` is set. initial_path Absolute or remote path from where to load the initial configuration ...
Return the diff, as Python dictionary, between the candidate and the running configuration. candidate_config The candidate configuration sent as text. This argument is ignored when ``candidate_path`` is set. candidate_path Absolute or remote path from where to load the candidate co...
Return the diff, as text, between the candidate and the running config. candidate_config The candidate configuration sent as text. This argument is ignored when ``candidate_path`` is set. candidate_path Absolute or remote path from where to load the candidate configuration text...
Show an item via pcs command (mainly for use with the pcs state module) item config, property, resource, constraint etc. item_id id of the item item_type item type show show command (probably None, default: show) extra_args additional options for the pcs ...
Create an item via pcs command (mainly for use with the pcs state module) item config, property, resource, constraint etc. item_id id of the item item_type item type create create command (create or set f.e., default: create) extra_args additional options...
Authorize nodes to the cluster nodes a list of nodes which should be authorized to the cluster pcsuser user for communitcation with PCS (default: hacluster) pcspasswd password for pcsuser (default: hacluster) extra_args list of extra option for the \'pcs cluster auth\' c...
Check if nodes are already authorized nodes a list of nodes to be checked for authorization to the cluster CLI Example: .. code-block:: bash salt '*' pcs.is_auth nodes='[node1.example.org node2.example.org]' def is_auth(nodes): ''' Check if nodes are already authorized node...
Setup pacemaker cluster via pcs command nodes a list of nodes which should be set up pcsclustername Name of the Pacemaker cluster (default: pcscluster) extra_args list of extra option for the \'pcs cluster setup\' command CLI Example: .. code-block:: bash salt '*'...
Add a node to the pacemaker cluster via pcs command node node that should be added extra_args list of extra option for the \'pcs cluster node add\' command CLI Example: .. code-block:: bash salt '*' pcs.cluster_node_add node=node2.example.org def cluster_node_add(node, extra...
Create a CIB-file from the current CIB of the cluster cibfile name/path of the file containing the CIB scope specific section of the CIB (default: configuration) extra_args additional options for creating the CIB-file CLI Example: .. code-block:: bash salt '*' pcs...
Show the value of a cluster property prop name of the property extra_args additional options for the pcs property command cibfile use cibfile instead of the live CIB CLI Example: .. code-block:: bash salt '*' pcs.prop_show cibfile='/tmp/2_node_cluster.cib' prop='n...
Set the value of a cluster property prop name of the property value value of the property prop extra_args additional options for the pcs property command cibfile use cibfile instead of the live CIB CLI Example: .. code-block:: bash salt '*' pcs.prop_se...
Show the value of a cluster stonith stonith_id name for the stonith resource extra_args additional options for the pcs stonith command cibfile use cibfile instead of the live CIB CLI Example: .. code-block:: bash salt '*' pcs.stonith_show stonith_id='eps_fence' ci...
Create a stonith resource via pcs command stonith_id name for the stonith resource stonith_device_type name of the stonith agent fence_eps, fence_xvm f.e. stonith_device_options additional options for creating the stonith resource cibfile use cibfile instead of the live ...
Show a resource via pcs command resource_id name of the resource extra_args additional options for the pcs command cibfile use cibfile instead of the live CIB CLI Example: .. code-block:: bash salt '*' pcs.resource_show resource_id='galera' cibfile='/tmp/cib_for_g...
Create a resource via pcs command resource_id name for the resource resource_type resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP) resource_options additional options for creating the resource cibfile use cibfile instead of the live CIB for manipulation CLI E...
Wrap text to the required dimensions and clean it up, prepare for display. :param txt: :param width: :return: def wrap(txt, width=80, ident=0): ''' Wrap text to the required dimensions and clean it up, prepare for display. :param txt: :param width: :return: ''' ident = ' ' * i...
Print message with an indent. :param message: :param indent: :return: def put(self, message, indent=0): ''' Print message with an indent. :param message: :param indent: :return: ''' color = self._colors_conf.get(indent + indent % 2, self...
Hint message. :param message: :param title: :param title_color: :param color: :param ident: :return: def msg(self, message, title=None, title_color=None, color='BLUE', ident=0): ''' Hint message. :param message: :param title: :pa...
Highlighter works the way that message parameter is a template, the "values" is a list of arguments going one after another as values there. And so the "colors" should designate either highlight color or alternate for each. Example: highlight('Hello {}, there! It is {}.', 'user', 'd...
Decorator to ensure that the named container exists. def _ensure_exists(wrapped): ''' Decorator to ensure that the named container exists. ''' @functools.wraps(wrapped) def check_exists(name, *args, **kwargs): if not exists(name): raise CommandExecutionError( 'Co...
Return the container root directory. Starting with systemd 219, new images go into /var/lib/machines. def _root(name='', all_roots=False): ''' Return the container root directory. Starting with systemd 219, new images go into /var/lib/machines. ''' if _sd_version() >= 219: if all_roots:...
Make the container root directory def _make_container_root(name): ''' Make the container root directory ''' path = _root(name) if os.path.exists(path): __context__['retcode'] = salt.defaults.exitcodes.SALT_BUILD_FAIL raise CommandExecutionError( 'Container {0} already ex...
Bootstrap an Arch Linux container def _bootstrap_arch(name, **kwargs): ''' Bootstrap an Arch Linux container ''' if not salt.utils.path.which('pacstrap'): raise CommandExecutionError( 'pacstrap not found, is the arch-install-scripts package ' 'installed?' ) d...
Bootstrap a Debian Linux container def _bootstrap_debian(name, **kwargs): ''' Bootstrap a Debian Linux container ''' version = kwargs.get('version', False) if not version: if __grains__['os'].lower() == 'debian': version = __grains__['osrelease'] else: versio...
Bootstrap a Fedora container def _bootstrap_fedora(name, **kwargs): ''' Bootstrap a Fedora container ''' dst = _make_container_root(name) if not kwargs.get('version', False): if __grains__['os'].lower() == 'fedora': version = __grains__['osrelease'] else: ver...
Raises an exception if the systemd version is not greater than the passed version. def _ensure_systemd(version): ''' Raises an exception if the systemd version is not greater than the passed version. ''' try: version = int(version) except ValueError: raise CommandExecutionEr...
Helper function to run machinectl def _machinectl(cmd, output_loglevel='debug', ignore_retcode=False, use_vt=False): ''' Helper function to run machinectl ''' prefix = 'machinectl --no-legend --no-pager' return __salt__['cmd.run_all']('{0} {1}'.format...
Common logic for nspawn.run functions def _run(name, cmd, output=None, no_start=False, stdin=None, python_shell=True, preserve_state=False, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): ''' ...
Returns the PID of a container name Container name CLI Example: .. code-block:: bash salt myminion nspawn.pid arch1 def pid(name): ''' Returns the PID of a container name Container name CLI Example: .. code-block:: bash salt myminion nspawn.pid ar...
Bootstrap a container from package servers, if dist is None the os the minion is running as will be created, otherwise the needed bootstrapping tools will need to be available on the host. CLI Example: .. code-block:: bash salt myminion nspawn.bootstrap_container <name> def bootstrap_contain...
Bootstrap a container from package servers, if dist is None the os the minion is running as will be created, otherwise the needed bootstrapping tools will need to be available on the host. CLI Example:: salt '*' nspawn.bootstrap_salt arch1 def bootstrap_salt(name, config=None, ...
Lists all nspawn containers CLI Example: .. code-block:: bash salt myminion nspawn.list_all def list_all(): ''' Lists all nspawn containers CLI Example: .. code-block:: bash salt myminion nspawn.list_all ''' ret = [] if _sd_version() >= 219: for line in...
Lists running nspawn containers .. note:: ``nspawn.list`` also works to list running containers CLI Example: .. code-block:: bash salt myminion nspawn.list_running salt myminion nspawn.list def list_running(): ''' Lists running nspawn containers .. note:: ...