mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2018.3' into bugs/ssh_state_test_failures
This commit is contained in:
commit
bd98c49dc7
63 changed files with 1597 additions and 1440 deletions
10
doc/conf.py
10
doc/conf.py
|
@ -250,9 +250,9 @@ on_saltstack = 'SALT_ON_SALTSTACK' in os.environ
|
|||
project = 'Salt'
|
||||
|
||||
version = salt.version.__version__
|
||||
latest_release = '2017.7.4' # latest release
|
||||
previous_release = '2016.11.9' # latest release from previous branch
|
||||
previous_release_dir = '2016.11' # path on web server for previous branch
|
||||
latest_release = '2018.3.0' # latest release
|
||||
previous_release = '2017.7.5' # latest release from previous branch
|
||||
previous_release_dir = '2017.7' # path on web server for previous branch
|
||||
next_release = '' # next release
|
||||
next_release_dir = '' # path on web server for next release branch
|
||||
|
||||
|
@ -263,8 +263,8 @@ if on_saltstack:
|
|||
copyright = time.strftime("%Y")
|
||||
|
||||
# < --- START do not merge these settings to other branches START ---> #
|
||||
build_type = 'develop' # latest, previous, develop, next
|
||||
release = version # version, latest_release, previous_release
|
||||
build_type = 'latest' # latest, previous, develop, next
|
||||
release = latest_release # version, latest_release, previous_release
|
||||
# < --- END do not merge these settings to other branches END ---> #
|
||||
|
||||
# Set google custom search engine
|
||||
|
|
|
@ -11,6 +11,7 @@ proxy modules
|
|||
:template: autosummary.rst.tmpl
|
||||
|
||||
chronos
|
||||
cimc
|
||||
cisconso
|
||||
dummy
|
||||
esxi
|
||||
|
@ -19,6 +20,7 @@ proxy modules
|
|||
marathon
|
||||
napalm
|
||||
nxos
|
||||
panos
|
||||
philips_hue
|
||||
rest_sample
|
||||
ssh_sample
|
||||
|
|
5
doc/ref/proxy/all/salt.proxy.cimc.rst
Normal file
5
doc/ref/proxy/all/salt.proxy.cimc.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
salt.proxy.cimc module
|
||||
======================
|
||||
|
||||
.. automodule:: salt.proxy.cimc
|
||||
:members:
|
5
doc/ref/proxy/all/salt.proxy.panos.rst
Normal file
5
doc/ref/proxy/all/salt.proxy.panos.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
salt.proxy.panos module
|
||||
=======================
|
||||
|
||||
.. automodule:: salt.proxy.panos
|
||||
:members:
|
|
@ -30,7 +30,7 @@ The :py:func:`docker_network.present <salt.states.docker_network.present>`
|
|||
state has undergone a full rewrite, which includes the following improvements:
|
||||
|
||||
Full API Support for Network Management
|
||||
---------------------------------------
|
||||
=======================================
|
||||
|
||||
The improvements made to input handling in the
|
||||
:py:func:`docker_container.running <salt.states.docker_container.running>`
|
||||
|
@ -39,14 +39,14 @@ state for 2017.7.0 have now been expanded to :py:func:`docker_network.present
|
|||
tunable configuration arguments.
|
||||
|
||||
Custom Subnets
|
||||
--------------
|
||||
==============
|
||||
|
||||
Custom subnets can now be configured. Both IPv4 and mixed IPv4/IPv6 networks
|
||||
are supported. See :ref:`here <salt-states-docker-network-present-ipam>` for
|
||||
more information.
|
||||
|
||||
Network Configuration in :py:func:`docker_container.running` States
|
||||
-------------------------------------------------------------------
|
||||
===================================================================
|
||||
|
||||
A long-requested feature has finally been added! It is now possible to
|
||||
configure static IPv4/IPv6 addresses, as well as links and labels. See
|
||||
|
@ -85,174 +85,6 @@ Additionally, the ``tag`` argument must now be explicitly passed to the
|
|||
:py:func:`docker_image.present <salt.states.docker_image.present>` state,
|
||||
unless the image is being pulled from a docker registry.
|
||||
|
||||
``utils`` functions moved into separate modules
|
||||
===============================================
|
||||
|
||||
The Salt utility functions from ``salt.utils`` have been moved into different
|
||||
modules, grouped logically based on their functionality. This change is
|
||||
backwards compatible, but the old imports will no longer be supported starting
|
||||
with release Neon.
|
||||
|
||||
The functions have been moved as follows:
|
||||
|
||||
- ``salt.utils.appendproctitle``: use ``salt.utils.process.appendproctitle``
|
||||
instead.
|
||||
- ``salt.utils.daemonize``: use ``salt.utils.process.daemonize`` instead.
|
||||
- ``salt.utils.daemonize_if``: use ``salt.utils.process.daemonize_if`` instead.
|
||||
- ``salt.utils.reinit_crypto``: use ``salt.utils.crypt.reinit_crypto`` instead.
|
||||
- ``salt.utils.pem_finger``: use ``salt.utils.crypt.pem_finger`` instead.
|
||||
- ``salt.utils.to_bytes``: use ``salt.utils.stringutils.to_bytes`` instead.
|
||||
- ``salt.utils.to_str``: use ``salt.utils.stringutils.to_str`` instead.
|
||||
- ``salt.utils.to_unicode``: use ``salt.utils.stringutils.to_unicode`` instead.
|
||||
- ``salt.utils.str_to_num``: use ``salt.utils.stringutils.to_num`` instead.
|
||||
- ``salt.utils.is_quoted``: use ``salt.utils.stringutils.is_quoted`` instead.
|
||||
- ``salt.utils.dequote``: use ``salt.utils.stringutils.dequote`` instead.
|
||||
- ``salt.utils.is_hex``: use ``salt.utils.stringutils.is_hex`` instead.
|
||||
- ``salt.utils.is_bin_str``: use ``salt.utils.stringutils.is_bin_str`` instead.
|
||||
- ``salt.utils.rand_string``: use ``salt.utils.stringutils.random`` instead.
|
||||
- ``salt.utils.contains_whitespace``: use
|
||||
``salt.utils.stringutils.contains_whitespace`` instead.
|
||||
- ``salt.utils.build_whitespace_split_regex``: use
|
||||
``salt.utils.stringutils.build_whitespace_split_regex`` instead.
|
||||
- ``salt.utils.expr_match``: use ``salt.utils.stringutils.expr_match`` instead.
|
||||
- ``salt.utils.check_whitelist_blacklist``: use
|
||||
``salt.utils.stringutils.check_whitelist_blacklist`` instead.
|
||||
- ``salt.utils.check_include_exclude``: use
|
||||
``salt.utils.stringutils.check_include_exclude`` instead.
|
||||
- ``salt.utils.print_cli``: use ``salt.utils.stringutils.print_cli`` instead.
|
||||
- ``salt.utils.clean_kwargs``: use ``salt.utils.args.clean_kwargs`` instead.
|
||||
- ``salt.utils.invalid_kwargs``: use ``salt.utils.args.invalid_kwargs``
|
||||
instead.
|
||||
- ``salt.utils.shlex_split``: use ``salt.utils.args.shlex_split`` instead.
|
||||
- ``salt.utils.arg_lookup``: use ``salt.utils.args.arg_lookup`` instead.
|
||||
- ``salt.utils.argspec_report``: use ``salt.utils.args.argspec_report``
|
||||
instead.
|
||||
- ``salt.utils.split_input``: use ``salt.utils.args.split_input`` instead.
|
||||
- ``salt.utils.test_mode``: use ``salt.utils.args.test_mode`` instead.
|
||||
- ``salt.utils.format_call``: use ``salt.utils.args.format_call`` instead.
|
||||
- ``salt.utils.which``: use ``salt.utils.path.which`` instead.
|
||||
- ``salt.utils.which_bin``: use ``salt.utils.path.which_bin`` instead.
|
||||
- ``salt.utils.path_join``: use ``salt.utils.path.join`` instead.
|
||||
- ``salt.utils.check_or_die``: use ``salt.utils.path.check_or_die`` instead.
|
||||
- ``salt.utils.sanitize_win_path_string``: use
|
||||
``salt.utils.path.sanitize_win_path`` instead.
|
||||
- ``salt.utils.rand_str``: use ``salt.utils.hashutils.random_hash`` instead.
|
||||
- ``salt.utils.get_hash``: use ``salt.utils.hashutils.get_hash`` instead.
|
||||
- ``salt.utils.is_windows``: use ``salt.utils.platform.is_windows`` instead.
|
||||
- ``salt.utils.is_proxy``: use ``salt.utils.platform.is_proxy`` instead.
|
||||
- ``salt.utils.is_linux``: use ``salt.utils.platform.is_linux`` instead.
|
||||
- ``salt.utils.is_darwin``: use ``salt.utils.platform.is_darwin`` instead.
|
||||
- ``salt.utils.is_sunos``: use ``salt.utils.platform.is_sunos`` instead.
|
||||
- ``salt.utils.is_smartos``: use ``salt.utils.platform.is_smartos`` instead.
|
||||
- ``salt.utils.is_smartos_globalzone``: use
|
||||
``salt.utils.platform.is_smartos_globalzone`` instead.
|
||||
- ``salt.utils.is_smartos_zone``: use ``salt.utils.platform.is_smartos_zone``
|
||||
instead.
|
||||
- ``salt.utils.is_freebsd``: use ``salt.utils.platform.is_freebsd`` instead.
|
||||
- ``salt.utils.is_netbsd``: use ``salt.utils.platform.is_netbsd`` instead.
|
||||
- ``salt.utils.is_openbsd``: use ``salt.utils.platform.is_openbsd`` instead.
|
||||
- ``salt.utils.is_aix``: use ``salt.utils.platform.is_aix`` instead.
|
||||
- ``salt.utils.safe_rm``: use ``salt.utils.files.safe_rm`` instead.
|
||||
- ``salt.utils.is_empty``: use ``salt.utils.files.is_empty`` instead.
|
||||
- ``salt.utils.fopen``: use ``salt.utils.files.fopen`` instead.
|
||||
- ``salt.utils.flopen``: use ``salt.utils.files.flopen`` instead.
|
||||
- ``salt.utils.fpopen``: use ``salt.utils.files.fpopen`` instead.
|
||||
- ``salt.utils.rm_rf``: use ``salt.utils.files.rm_rf`` instead.
|
||||
- ``salt.utils.mkstemp``: use ``salt.utils.files.mkstemp`` instead.
|
||||
- ``salt.utils.istextfile``: use ``salt.utils.files.is_text_file`` instead.
|
||||
- ``salt.utils.is_bin_file``: use ``salt.utils.files.is_binary`` instead.
|
||||
- ``salt.utils.list_files``: use ``salt.utils.files.list_files`` instead.
|
||||
- ``salt.utils.safe_walk``: use ``salt.utils.files.safe_walk`` instead.
|
||||
- ``salt.utils.st_mode_to_octal``: use ``salt.utils.files.st_mode_to_octal``
|
||||
instead.
|
||||
- ``salt.utils.normalize_mode``: use ``salt.utils.files.normalize_mode``
|
||||
instead.
|
||||
- ``salt.utils.human_size_to_bytes``: use
|
||||
``salt.utils.files.human_size_to_bytes`` instead.
|
||||
- ``salt.utils.backup_minion``: use ``salt.utils.files.backup_minion`` instead.
|
||||
- ``salt.utils.str_version_to_evr``: use ``salt.utils.pkg.rpm.version_to_evr``
|
||||
instead.
|
||||
- ``salt.utils.parse_docstring``: use ``salt.utils.doc.parse_docstring``
|
||||
instead.
|
||||
- ``salt.utils.compare_versions``: use ``salt.utils.versions.compare`` instead.
|
||||
- ``salt.utils.version_cmp``: use ``salt.utils.versions.version_cmp`` instead.
|
||||
- ``salt.utils.warn_until``: use ``salt.utils.versions.warn_until`` instead.
|
||||
- ``salt.utils.kwargs_warn_until``: use
|
||||
``salt.utils.versions.kwargs_warn_until`` instead.
|
||||
- ``salt.utils.get_color_theme``: use ``salt.utils.color.get_color_theme``
|
||||
instead.
|
||||
- ``salt.utils.get_colors``: use ``salt.utils.color.get_colors`` instead.
|
||||
- ``salt.utils.gen_state_tag``: use ``salt.utils.state.gen_tag`` instead.
|
||||
- ``salt.utils.search_onfail_requisites``: use
|
||||
``salt.utils.state.search_onfail_requisites`` instead.
|
||||
- ``salt.utils.check_state_result``: use ``salt.utils.state.check_result``
|
||||
instead.
|
||||
- ``salt.utils.get_user``: use ``salt.utils.user.get_user`` instead.
|
||||
- ``salt.utils.get_uid``: use ``salt.utils.user.get_uid`` instead.
|
||||
- ``salt.utils.get_specific_user``: use ``salt.utils.user.get_specific_user``
|
||||
instead.
|
||||
- ``salt.utils.chugid``: use ``salt.utils.user.chugid`` instead.
|
||||
- ``salt.utils.chugid_and_umask``: use ``salt.utils.user.chugid_and_umask``
|
||||
instead.
|
||||
- ``salt.utils.get_default_group``: use ``salt.utils.user.get_default_group``
|
||||
instead.
|
||||
- ``salt.utils.get_group_list``: use ``salt.utils.user.get_group_list``
|
||||
instead.
|
||||
- ``salt.utils.get_group_dict``: use ``salt.utils.user.get_group_dict``
|
||||
instead.
|
||||
- ``salt.utils.get_gid_list``: use ``salt.utils.user.get_gid_list`` instead.
|
||||
- ``salt.utils.get_gid``: use ``salt.utils.user.get_gid`` instead.
|
||||
- ``salt.utils.enable_ctrl_logoff_handler``: use
|
||||
``salt.utils.win_functions.enable_ctrl_logoff_handler`` instead.
|
||||
- ``salt.utils.traverse_dict``: use ``salt.utils.data.traverse_dict`` instead.
|
||||
- ``salt.utils.traverse_dict_and_list``: use
|
||||
``salt.utils.data.traverse_dict_and_list`` instead.
|
||||
- ``salt.utils.filter_by``: use ``salt.utils.data.filter_by`` instead.
|
||||
- ``salt.utils.subdict_match``: use ``salt.utils.data.subdict_match`` instead.
|
||||
- ``salt.utils.substr_in_list``: use ``salt.utils.data.substr_in_list`` instead.
|
||||
- ``salt.utils.is_dictlist``: use ``salt.utils.data.is_dictlist``.
|
||||
- ``salt.utils.repack_dictlist``: use ``salt.utils.data.repack_dictlist``
|
||||
instead.
|
||||
- ``salt.utils.compare_dicts``: use ``salt.utils.data.compare_dicts`` instead.
|
||||
- ``salt.utils.compare_lists``: use ``salt.utils.data.compare_lists`` instead.
|
||||
- ``salt.utils.decode_dict``: use ``salt.utils.data.encode_dict`` instead.
|
||||
- ``salt.utils.decode_list``: use ``salt.utils.data.encode_list`` instead.
|
||||
- ``salt.utils.exactly_n``: use ``salt.utils.data.exactly_n`` instead.
|
||||
- ``salt.utils.exactly_one``: use ``salt.utils.data.exactly_one`` instead.
|
||||
- ``salt.utils.is_list``: use ``salt.utils.data.is_list`` instead.
|
||||
- ``salt.utils.is_iter``: use ``salt.utils.data.is_iter`` instead.
|
||||
- ``salt.utils.isorted``: use ``salt.utils.data.sorted_ignorecase`` instead.
|
||||
- ``salt.utils.is_true``: use ``salt.utils.data.is_true`` instead.
|
||||
- ``salt.utils.mysql_to_dict``: use ``salt.utils.data.mysql_to_dict`` instead.
|
||||
- ``salt.utils.simple_types_filter``: use
|
||||
``salt.utils.data.simple_types_filter`` instead.
|
||||
- ``salt.utils.ip_bracket``: use ``salt.utils.zeromq.ip_bracket`` instead.
|
||||
- ``salt.utils.gen_mac``: use ``salt.utils.network.gen_mac`` instead.
|
||||
- ``salt.utils.mac_str_to_bytes``: use ``salt.utils.network.mac_str_to_bytes``
|
||||
instead.
|
||||
- ``salt.utils.refresh_dns``: use ``salt.utils.network.refresh_dns`` instead.
|
||||
- ``salt.utils.dns_check``: use ``salt.utils.network.dns_check`` instead.
|
||||
- ``salt.utils.get_context``: use ``salt.utils.stringutils.get_context`` instead.
|
||||
- ``salt.utils.get_master_key``: use ``salt.utils.master.get_master_key``
|
||||
instead.
|
||||
- ``salt.utils.get_values_of_matching_keys``: use
|
||||
``salt.utils.master.get_values_of_matching_keys`` instead.
|
||||
- ``salt.utils.date_cast``: use ``salt.utils.dateutils.date_cast`` instead.
|
||||
- ``salt.utils.date_format``: use ``salt.utils.dateutils.strftime`` instead.
|
||||
- ``salt.utils.total_seconds``: use ``salt.utils.dateutils.total_seconds``
|
||||
instead.
|
||||
- ``salt.utils.find_json``: use ``salt.utils.json.find_json`` instead.
|
||||
- ``salt.utils.import_json``: use ``salt.utils.json.import_json`` instead.
|
||||
- ``salt.utils.namespaced_function``: use
|
||||
``salt.utils.functools.namespaced_function`` instead.
|
||||
- ``salt.utils.alias_function``: use ``salt.utils.functools.alias_function``
|
||||
instead.
|
||||
- ``salt.utils.profile_func``: use ``salt.utils.profile.profile_func`` instead.
|
||||
- ``salt.utils.activate_profile``: use ``salt.utils.profile.activate_profile``
|
||||
instead.
|
||||
- ``salt.utils.output_profile``: use ``salt.utils.profile.output_profile``
|
||||
instead.
|
||||
|
||||
State and Execution Module Support for ``docker run`` Functionality
|
||||
===================================================================
|
||||
|
||||
|
@ -456,16 +288,14 @@ programatically <orchestrate-runner-parsing-results-programatically>`. The
|
|||
failed returns in these cases are now included in the changes dictionary,
|
||||
making for much easier parsing.
|
||||
|
||||
New Grains
|
||||
----------
|
||||
|
||||
New core grains have been added to expose any storage inititator setting.
|
||||
|
||||
The new grains added are:
|
||||
|
||||
* ``fc_wwn``: Show all fibre channel world wide port names for a host
|
||||
Grains
|
||||
------
|
||||
* ``fc_wwn``: Show all fibre channel world wide port names for a host, must be enabled with `fibre_channel_grains`
|
||||
* ``iscsi_iqn``: Show the iSCSI IQN name for a host
|
||||
* ``swap_total``: Show the configured swap_total for Linux, \*BSD, OS X and Solaris/SunOS
|
||||
* ``virtual``:
|
||||
* identifies reports KVM and VMM hypervisors when running an OpenBSD guest
|
||||
* for detecting Solaris Logical Domains (LDOMs) running on T-Series SPARC hardware. The ``virtual_subtype`` grain is populated as a list of domain roles.
|
||||
|
||||
Salt Minion Auto-discovery
|
||||
------------------------
|
||||
|
@ -481,9 +311,9 @@ Configuration
|
|||
|
||||
By default, automatic discovery is disabled.
|
||||
|
||||
..warning::
|
||||
Due to the current limitations that will be changing in a future, before you turn on auto-discovery,
|
||||
make sure your network is secured and trusted.
|
||||
.. warning::
|
||||
Due to the current limitations that will be changing in a future release, before you turn on auto-discovery,
|
||||
make sure your network is secured and trusted.
|
||||
|
||||
Auto-discovery is configured on Master and Minion. Both of them are configured via the ``discovery`` option
|
||||
as follows:
|
||||
|
@ -589,12 +419,6 @@ This feature has a couple of _temporary_ limitations that are subject to change
|
|||
security applied (priv/pub key check, signature, fingerprint etc). That implies that administrator
|
||||
is expected to know his network and make sure it is clean.
|
||||
|
||||
Grains Changes
|
||||
--------------
|
||||
|
||||
* The ``virtual`` grain identifies reports KVM and VMM hypervisors when running
|
||||
an OpenBSD guest
|
||||
|
||||
New Modules
|
||||
-----------
|
||||
|
||||
|
@ -655,9 +479,42 @@ The ``state_output`` parameter now supports ``full_id``, ``changes_id`` and ``te
|
|||
Just like ``mixed_id``, these use the state ID as name in the highstate output.
|
||||
For more information on these output modes, see the docs for the :mod:`Highstate Outputter <salt.output.highstate>`.
|
||||
|
||||
Windows Installer: Changes to config handling
|
||||
---------------------------------------------
|
||||
Behavior with existing configuration has changed. With previous installers the
|
||||
Windows
|
||||
-------
|
||||
Python Version
|
||||
==============
|
||||
Python 2 Windows API was design when Windows did not support Unicode. Windows now supports
|
||||
Unicode however to keep backwards compatibility Python 2 Windows API has not been changed.
|
||||
Python 3 Windows API supports Unicode. Salt Python 3 installer is the recommend choice for
|
||||
users who need characters other than Non-ASCII (7bit) characters.
|
||||
|
||||
Execution module changes
|
||||
========================
|
||||
pkg
|
||||
***
|
||||
Significate changes have been made to the :mod:`win_pkg <salt.modules.win_pkg>` execution module. Users should test this release against their existing package sls definition files. These changes are also in 2016.11.9 & 2017.7.3.
|
||||
|
||||
- ``pkg.list_available`` no longer defaults to refreshing the winrepo meta database.
|
||||
- ``pkg.install`` without a ``version`` parameter no longer upgrades software if the software is already installed. Use ``pkg.install version=latest`` or in a state use ``pkg.latest`` to get the old behavior.
|
||||
- ``pkg.list_pkgs`` now returns multiple versions if software installed more than once.
|
||||
- ``pkg.list_pkgs`` now returns 'Not Found' when the version is not found instead of '(value not set)' which matches the contents of the sls definitions.
|
||||
- ``pkg.remove()`` will wait upto 3 seconds (normally about a second) to detect changes in the registry after removing software, improving reporting of version changes.
|
||||
- ``pkg.remove()`` can remove ``latest`` software, if ``latest`` is defined in sls definition.
|
||||
- Documentation was update for the execution module to match the style in new versions, some corrections as well.
|
||||
- All install/remove commands are prefix with cmd.exe shell and cmdmod is called with a command line string instead of a list. Some sls files in saltstack/salt-winrepo-ng expected the commands to be prefixed with cmd.exe (i.e. the use of ``&``).
|
||||
- Some execution module functions results, now behavour more like their Unix/Linux versions.
|
||||
|
||||
cmdmod
|
||||
******
|
||||
Linux/Unix OS command & arguments requires a python list. Windows was being treated
|
||||
the same. Windows requires commands & arguments to be a string. These changes are
|
||||
also in 2016.11.9 & 2017.7.3.
|
||||
|
||||
Installer
|
||||
=========
|
||||
Changes to config handling
|
||||
**************************
|
||||
Behavior with existing configuration has changed. With previous windows installers the
|
||||
existing config was used and the master and minion id could be modified via the
|
||||
installer. It was problematic in that it didn't account for configuration that
|
||||
may be defined in the ``minion.d`` directory. This change gives you the option
|
||||
|
@ -685,18 +542,33 @@ If neither option is passed and there is an existing config, the default is to
|
|||
use the existing config. If there is no existing config (new install) the
|
||||
default config will be used.
|
||||
|
||||
Windows Installer: Multi-master configuration
|
||||
---------------------------------------------
|
||||
Multi-master configuration
|
||||
**************************
|
||||
The installer now has the ability to apply a multi-master configuration either
|
||||
from the gui or the command line. The ``master`` field in the gui can accept
|
||||
either a single master or a comma-separated list of masters. The command-line
|
||||
switch (``/master=``) can accept the same.
|
||||
|
||||
Windows Installer: Command-line help
|
||||
------------------------------------
|
||||
Command-line help
|
||||
*****************
|
||||
The Windows installer will now display command-line help when a help switch
|
||||
(``/?``) is passed.
|
||||
|
||||
utils.pkg.win preview
|
||||
=====================
|
||||
A new utils python module has been added, which gathers information about windows
|
||||
installed software. This is currently not used by any salt execution module or state.
|
||||
Users are encource to run this and report any issues. Running the command with the
|
||||
``detail`` option will be useful for anyone developing windows package definitions.
|
||||
With salt installed in the default location the following command will print the help
|
||||
message.
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
chcp 65001
|
||||
c:\salt\bin\python.exe c:\salt\bin\lib\site-packages\salt\utils\pkg\win.py
|
||||
c:\salt\bin\python.exe c:\salt\bin\lib\site-packages\salt\utils\pkg\win.py detail system
|
||||
|
||||
Salt Cloud Features
|
||||
-------------------
|
||||
|
||||
|
@ -801,6 +673,21 @@ which designate a ``Vagrantfile`` on the host machine.
|
|||
The master can be a very limited machine, such as a Raspberry Pi, or a small
|
||||
VagrantBox VM.
|
||||
|
||||
Python PyWinRM Module
|
||||
=====================
|
||||
Versions of ``pywinrm>=0.2.1`` are finally able to disable validation of self
|
||||
signed certificates. :ref:`Here<new-pywinrm>` for more information.
|
||||
|
||||
DigitalOcean
|
||||
============
|
||||
The DigitalOcean driver has been renamed to conform to the company name. The
|
||||
new driver name is ``digitalocean``. The old name ``digital_ocean`` and a
|
||||
short one ``do`` will still be supported through virtual aliases, this is mostly
|
||||
cosmetic.
|
||||
|
||||
Azure Cloud
|
||||
===========
|
||||
The azure sdk used for the ``azurearm`` cloud driver now depends on ``azure-cli>=2.0.12``
|
||||
|
||||
New pillar/master_tops module called saltclass
|
||||
----------------------------------------------
|
||||
|
@ -990,27 +877,6 @@ Not using ``^`` as the first entry will simply merge the lists
|
|||
|
||||
Currently you can't have both a variable and an escaped variable in the same string as the escaped one will not be correctly rendered - '\${xx}' will stay as is instead of being rendered as '${xx}'
|
||||
|
||||
Newer PyWinRM Versions
|
||||
----------------------
|
||||
|
||||
Versions of ``pywinrm>=0.2.1`` are finally able to disable validation of self
|
||||
signed certificates. :ref:`Here<new-pywinrm>` for more information.
|
||||
|
||||
DigitalOcean
|
||||
------------
|
||||
|
||||
The DigitalOcean driver has been renamed to conform to the company name. The
|
||||
new driver name is ``digitalocean``. The old name ``digital_ocean`` and a
|
||||
short one ``do`` will still be supported through virtual aliases, this is mostly
|
||||
cosmetic.
|
||||
|
||||
Solaris Logical Domains In Virtual Grain
|
||||
----------------------------------------
|
||||
|
||||
Support has been added to the ``virtual`` grain for detecting Solaris LDOMs
|
||||
running on T-Series SPARC hardware. The ``virtual_subtype`` grain is
|
||||
populated as a list of domain roles.
|
||||
|
||||
Lists of comments in state returns
|
||||
----------------------------------
|
||||
|
||||
|
@ -1631,6 +1497,174 @@ removal in the Neon release, the default "box_type" has changed from
|
|||
``secretbox`` to ``sealedbox``. SecretBox is data encrypted using private key
|
||||
``sk`` and Sealedbox is encrypted using public key ``pk``.
|
||||
|
||||
``utils`` functions moved into separate modules
|
||||
-----------------------------------------------
|
||||
|
||||
The Salt utility functions from ``salt.utils`` have been moved into different
|
||||
modules, grouped logically based on their functionality. This change is
|
||||
backwards compatible, but the old imports will no longer be supported starting
|
||||
with release Neon.
|
||||
|
||||
The functions have been moved as follows:
|
||||
|
||||
- ``salt.utils.appendproctitle``: use ``salt.utils.process.appendproctitle``
|
||||
instead.
|
||||
- ``salt.utils.daemonize``: use ``salt.utils.process.daemonize`` instead.
|
||||
- ``salt.utils.daemonize_if``: use ``salt.utils.process.daemonize_if`` instead.
|
||||
- ``salt.utils.reinit_crypto``: use ``salt.utils.crypt.reinit_crypto`` instead.
|
||||
- ``salt.utils.pem_finger``: use ``salt.utils.crypt.pem_finger`` instead.
|
||||
- ``salt.utils.to_bytes``: use ``salt.utils.stringutils.to_bytes`` instead.
|
||||
- ``salt.utils.to_str``: use ``salt.utils.stringutils.to_str`` instead.
|
||||
- ``salt.utils.to_unicode``: use ``salt.utils.stringutils.to_unicode`` instead.
|
||||
- ``salt.utils.str_to_num``: use ``salt.utils.stringutils.to_num`` instead.
|
||||
- ``salt.utils.is_quoted``: use ``salt.utils.stringutils.is_quoted`` instead.
|
||||
- ``salt.utils.dequote``: use ``salt.utils.stringutils.dequote`` instead.
|
||||
- ``salt.utils.is_hex``: use ``salt.utils.stringutils.is_hex`` instead.
|
||||
- ``salt.utils.is_bin_str``: use ``salt.utils.stringutils.is_bin_str`` instead.
|
||||
- ``salt.utils.rand_string``: use ``salt.utils.stringutils.random`` instead.
|
||||
- ``salt.utils.contains_whitespace``: use
|
||||
``salt.utils.stringutils.contains_whitespace`` instead.
|
||||
- ``salt.utils.build_whitespace_split_regex``: use
|
||||
``salt.utils.stringutils.build_whitespace_split_regex`` instead.
|
||||
- ``salt.utils.expr_match``: use ``salt.utils.stringutils.expr_match`` instead.
|
||||
- ``salt.utils.check_whitelist_blacklist``: use
|
||||
``salt.utils.stringutils.check_whitelist_blacklist`` instead.
|
||||
- ``salt.utils.check_include_exclude``: use
|
||||
``salt.utils.stringutils.check_include_exclude`` instead.
|
||||
- ``salt.utils.print_cli``: use ``salt.utils.stringutils.print_cli`` instead.
|
||||
- ``salt.utils.clean_kwargs``: use ``salt.utils.args.clean_kwargs`` instead.
|
||||
- ``salt.utils.invalid_kwargs``: use ``salt.utils.args.invalid_kwargs``
|
||||
instead.
|
||||
- ``salt.utils.shlex_split``: use ``salt.utils.args.shlex_split`` instead.
|
||||
- ``salt.utils.arg_lookup``: use ``salt.utils.args.arg_lookup`` instead.
|
||||
- ``salt.utils.argspec_report``: use ``salt.utils.args.argspec_report``
|
||||
instead.
|
||||
- ``salt.utils.split_input``: use ``salt.utils.args.split_input`` instead.
|
||||
- ``salt.utils.test_mode``: use ``salt.utils.args.test_mode`` instead.
|
||||
- ``salt.utils.format_call``: use ``salt.utils.args.format_call`` instead.
|
||||
- ``salt.utils.which``: use ``salt.utils.path.which`` instead.
|
||||
- ``salt.utils.which_bin``: use ``salt.utils.path.which_bin`` instead.
|
||||
- ``salt.utils.path_join``: use ``salt.utils.path.join`` instead.
|
||||
- ``salt.utils.check_or_die``: use ``salt.utils.path.check_or_die`` instead.
|
||||
- ``salt.utils.sanitize_win_path_string``: use
|
||||
``salt.utils.path.sanitize_win_path`` instead.
|
||||
- ``salt.utils.rand_str``: use ``salt.utils.hashutils.random_hash`` instead.
|
||||
- ``salt.utils.get_hash``: use ``salt.utils.hashutils.get_hash`` instead.
|
||||
- ``salt.utils.is_windows``: use ``salt.utils.platform.is_windows`` instead.
|
||||
- ``salt.utils.is_proxy``: use ``salt.utils.platform.is_proxy`` instead.
|
||||
- ``salt.utils.is_linux``: use ``salt.utils.platform.is_linux`` instead.
|
||||
- ``salt.utils.is_darwin``: use ``salt.utils.platform.is_darwin`` instead.
|
||||
- ``salt.utils.is_sunos``: use ``salt.utils.platform.is_sunos`` instead.
|
||||
- ``salt.utils.is_smartos``: use ``salt.utils.platform.is_smartos`` instead.
|
||||
- ``salt.utils.is_smartos_globalzone``: use
|
||||
``salt.utils.platform.is_smartos_globalzone`` instead.
|
||||
- ``salt.utils.is_smartos_zone``: use ``salt.utils.platform.is_smartos_zone``
|
||||
instead.
|
||||
- ``salt.utils.is_freebsd``: use ``salt.utils.platform.is_freebsd`` instead.
|
||||
- ``salt.utils.is_netbsd``: use ``salt.utils.platform.is_netbsd`` instead.
|
||||
- ``salt.utils.is_openbsd``: use ``salt.utils.platform.is_openbsd`` instead.
|
||||
- ``salt.utils.is_aix``: use ``salt.utils.platform.is_aix`` instead.
|
||||
- ``salt.utils.safe_rm``: use ``salt.utils.files.safe_rm`` instead.
|
||||
- ``salt.utils.is_empty``: use ``salt.utils.files.is_empty`` instead.
|
||||
- ``salt.utils.fopen``: use ``salt.utils.files.fopen`` instead.
|
||||
- ``salt.utils.flopen``: use ``salt.utils.files.flopen`` instead.
|
||||
- ``salt.utils.fpopen``: use ``salt.utils.files.fpopen`` instead.
|
||||
- ``salt.utils.rm_rf``: use ``salt.utils.files.rm_rf`` instead.
|
||||
- ``salt.utils.mkstemp``: use ``salt.utils.files.mkstemp`` instead.
|
||||
- ``salt.utils.istextfile``: use ``salt.utils.files.is_text_file`` instead.
|
||||
- ``salt.utils.is_bin_file``: use ``salt.utils.files.is_binary`` instead.
|
||||
- ``salt.utils.list_files``: use ``salt.utils.files.list_files`` instead.
|
||||
- ``salt.utils.safe_walk``: use ``salt.utils.files.safe_walk`` instead.
|
||||
- ``salt.utils.st_mode_to_octal``: use ``salt.utils.files.st_mode_to_octal``
|
||||
instead.
|
||||
- ``salt.utils.normalize_mode``: use ``salt.utils.files.normalize_mode``
|
||||
instead.
|
||||
- ``salt.utils.human_size_to_bytes``: use
|
||||
``salt.utils.files.human_size_to_bytes`` instead.
|
||||
- ``salt.utils.backup_minion``: use ``salt.utils.files.backup_minion`` instead.
|
||||
- ``salt.utils.str_version_to_evr``: use ``salt.utils.pkg.rpm.version_to_evr``
|
||||
instead.
|
||||
- ``salt.utils.parse_docstring``: use ``salt.utils.doc.parse_docstring``
|
||||
instead.
|
||||
- ``salt.utils.compare_versions``: use ``salt.utils.versions.compare`` instead.
|
||||
- ``salt.utils.version_cmp``: use ``salt.utils.versions.version_cmp`` instead.
|
||||
- ``salt.utils.warn_until``: use ``salt.utils.versions.warn_until`` instead.
|
||||
- ``salt.utils.kwargs_warn_until``: use
|
||||
``salt.utils.versions.kwargs_warn_until`` instead.
|
||||
- ``salt.utils.get_color_theme``: use ``salt.utils.color.get_color_theme``
|
||||
instead.
|
||||
- ``salt.utils.get_colors``: use ``salt.utils.color.get_colors`` instead.
|
||||
- ``salt.utils.gen_state_tag``: use ``salt.utils.state.gen_tag`` instead.
|
||||
- ``salt.utils.search_onfail_requisites``: use
|
||||
``salt.utils.state.search_onfail_requisites`` instead.
|
||||
- ``salt.utils.check_state_result``: use ``salt.utils.state.check_result``
|
||||
instead.
|
||||
- ``salt.utils.get_user``: use ``salt.utils.user.get_user`` instead.
|
||||
- ``salt.utils.get_uid``: use ``salt.utils.user.get_uid`` instead.
|
||||
- ``salt.utils.get_specific_user``: use ``salt.utils.user.get_specific_user``
|
||||
instead.
|
||||
- ``salt.utils.chugid``: use ``salt.utils.user.chugid`` instead.
|
||||
- ``salt.utils.chugid_and_umask``: use ``salt.utils.user.chugid_and_umask``
|
||||
instead.
|
||||
- ``salt.utils.get_default_group``: use ``salt.utils.user.get_default_group``
|
||||
instead.
|
||||
- ``salt.utils.get_group_list``: use ``salt.utils.user.get_group_list``
|
||||
instead.
|
||||
- ``salt.utils.get_group_dict``: use ``salt.utils.user.get_group_dict``
|
||||
instead.
|
||||
- ``salt.utils.get_gid_list``: use ``salt.utils.user.get_gid_list`` instead.
|
||||
- ``salt.utils.get_gid``: use ``salt.utils.user.get_gid`` instead.
|
||||
- ``salt.utils.enable_ctrl_logoff_handler``: use
|
||||
``salt.utils.win_functions.enable_ctrl_logoff_handler`` instead.
|
||||
- ``salt.utils.traverse_dict``: use ``salt.utils.data.traverse_dict`` instead.
|
||||
- ``salt.utils.traverse_dict_and_list``: use
|
||||
``salt.utils.data.traverse_dict_and_list`` instead.
|
||||
- ``salt.utils.filter_by``: use ``salt.utils.data.filter_by`` instead.
|
||||
- ``salt.utils.subdict_match``: use ``salt.utils.data.subdict_match`` instead.
|
||||
- ``salt.utils.substr_in_list``: use ``salt.utils.data.substr_in_list`` instead.
|
||||
- ``salt.utils.is_dictlist``: use ``salt.utils.data.is_dictlist``.
|
||||
- ``salt.utils.repack_dictlist``: use ``salt.utils.data.repack_dictlist``
|
||||
instead.
|
||||
- ``salt.utils.compare_dicts``: use ``salt.utils.data.compare_dicts`` instead.
|
||||
- ``salt.utils.compare_lists``: use ``salt.utils.data.compare_lists`` instead.
|
||||
- ``salt.utils.decode_dict``: use ``salt.utils.data.encode_dict`` instead.
|
||||
- ``salt.utils.decode_list``: use ``salt.utils.data.encode_list`` instead.
|
||||
- ``salt.utils.exactly_n``: use ``salt.utils.data.exactly_n`` instead.
|
||||
- ``salt.utils.exactly_one``: use ``salt.utils.data.exactly_one`` instead.
|
||||
- ``salt.utils.is_list``: use ``salt.utils.data.is_list`` instead.
|
||||
- ``salt.utils.is_iter``: use ``salt.utils.data.is_iter`` instead.
|
||||
- ``salt.utils.isorted``: use ``salt.utils.data.sorted_ignorecase`` instead.
|
||||
- ``salt.utils.is_true``: use ``salt.utils.data.is_true`` instead.
|
||||
- ``salt.utils.mysql_to_dict``: use ``salt.utils.data.mysql_to_dict`` instead.
|
||||
- ``salt.utils.simple_types_filter``: use
|
||||
``salt.utils.data.simple_types_filter`` instead.
|
||||
- ``salt.utils.ip_bracket``: use ``salt.utils.zeromq.ip_bracket`` instead.
|
||||
- ``salt.utils.gen_mac``: use ``salt.utils.network.gen_mac`` instead.
|
||||
- ``salt.utils.mac_str_to_bytes``: use ``salt.utils.network.mac_str_to_bytes``
|
||||
instead.
|
||||
- ``salt.utils.refresh_dns``: use ``salt.utils.network.refresh_dns`` instead.
|
||||
- ``salt.utils.dns_check``: use ``salt.utils.network.dns_check`` instead.
|
||||
- ``salt.utils.get_context``: use ``salt.utils.stringutils.get_context`` instead.
|
||||
- ``salt.utils.get_master_key``: use ``salt.utils.master.get_master_key``
|
||||
instead.
|
||||
- ``salt.utils.get_values_of_matching_keys``: use
|
||||
``salt.utils.master.get_values_of_matching_keys`` instead.
|
||||
- ``salt.utils.date_cast``: use ``salt.utils.dateutils.date_cast`` instead.
|
||||
- ``salt.utils.date_format``: use ``salt.utils.dateutils.strftime`` instead.
|
||||
- ``salt.utils.total_seconds``: use ``salt.utils.dateutils.total_seconds``
|
||||
instead.
|
||||
- ``salt.utils.find_json``: use ``salt.utils.json.find_json`` instead.
|
||||
- ``salt.utils.import_json``: use ``salt.utils.json.import_json`` instead.
|
||||
- ``salt.utils.namespaced_function``: use
|
||||
``salt.utils.functools.namespaced_function`` instead.
|
||||
- ``salt.utils.alias_function``: use ``salt.utils.functools.alias_function``
|
||||
instead.
|
||||
- ``salt.utils.profile_func``: use ``salt.utils.profile.profile_func`` instead.
|
||||
- ``salt.utils.activate_profile``: use ``salt.utils.profile.activate_profile``
|
||||
instead.
|
||||
- ``salt.utils.output_profile``: use ``salt.utils.profile.output_profile``
|
||||
instead.
|
||||
|
||||
Deprecations
|
||||
------------
|
||||
|
||||
|
@ -1646,10 +1680,7 @@ Profitbricks Cloud Updated Dependency
|
|||
The minimum version of the ``profitbrick`` python package for the ``profitbricks``
|
||||
cloud driver has changed from 3.0.0 to 3.1.0.
|
||||
|
||||
Azure Cloud Updated Dependency
|
||||
------------------------------
|
||||
|
||||
The azure sdk used for the ``azurearm`` cloud driver now depends on ``azure-cli>=2.0.12``
|
||||
|
||||
Module Deprecations
|
||||
===================
|
||||
|
|
|
@ -21,7 +21,7 @@ pycrypto==2.6.1
|
|||
python-dateutil==2.6.1
|
||||
python-gnupg==0.4.1
|
||||
PyYAML==3.12
|
||||
pyzmq==17.0.0b3
|
||||
pyzmq==17.0.0
|
||||
requests==2.18.4
|
||||
singledispatch==3.4.0.3
|
||||
six==1.11.0
|
||||
|
|
|
@ -37,8 +37,8 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def auth(username, sharedsecret, **kwargs):
|
||||
def auth(username, password):
|
||||
'''
|
||||
Shared secret authentication
|
||||
'''
|
||||
return sharedsecret == __opts__.get('sharedsecret')
|
||||
return password == __opts__.get('sharedsecret')
|
||||
|
|
110
salt/loader.py
110
salt/loader.py
|
@ -14,6 +14,7 @@ import logging
|
|||
import inspect
|
||||
import tempfile
|
||||
import functools
|
||||
import threading
|
||||
import types
|
||||
from collections import MutableMapping
|
||||
from zipimport import zipimporter
|
||||
|
@ -1124,7 +1125,8 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
)
|
||||
)
|
||||
|
||||
self.refresh_file_mapping()
|
||||
self._lock = threading.RLock()
|
||||
self._refresh_file_mapping()
|
||||
|
||||
super(LazyLoader, self).__init__() # late init the lazy loader
|
||||
# create all of the import namespaces
|
||||
|
@ -1191,7 +1193,7 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
else:
|
||||
return '\'{0}\' __virtual__ returned False'.format(mod_name)
|
||||
|
||||
def refresh_file_mapping(self):
|
||||
def _refresh_file_mapping(self):
|
||||
'''
|
||||
refresh the mapping of the FS on disk
|
||||
'''
|
||||
|
@ -1308,15 +1310,16 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
'''
|
||||
Clear the dict
|
||||
'''
|
||||
super(LazyLoader, self).clear() # clear the lazy loader
|
||||
self.loaded_files = set()
|
||||
self.missing_modules = {}
|
||||
self.loaded_modules = {}
|
||||
# if we have been loaded before, lets clear the file mapping since
|
||||
# we obviously want a re-do
|
||||
if hasattr(self, 'opts'):
|
||||
self.refresh_file_mapping()
|
||||
self.initial_load = False
|
||||
with self._lock:
|
||||
super(LazyLoader, self).clear() # clear the lazy loader
|
||||
self.loaded_files = set()
|
||||
self.missing_modules = {}
|
||||
self.loaded_modules = {}
|
||||
# if we have been loaded before, lets clear the file mapping since
|
||||
# we obviously want a re-do
|
||||
if hasattr(self, 'opts'):
|
||||
self._refresh_file_mapping()
|
||||
self.initial_load = False
|
||||
|
||||
def __prep_mod_opts(self, opts):
|
||||
'''
|
||||
|
@ -1520,14 +1523,14 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
virtual_funcs_to_process = ['__virtual__'] + self.virtual_funcs
|
||||
for virtual_func in virtual_funcs_to_process:
|
||||
virtual_ret, module_name, virtual_err, virtual_aliases = \
|
||||
self.process_virtual(mod, module_name, virtual_func)
|
||||
self._process_virtual(mod, module_name, virtual_func)
|
||||
if virtual_err is not None:
|
||||
log.trace(
|
||||
'Error loading %s.%s: %s',
|
||||
self.tag, module_name, virtual_err
|
||||
)
|
||||
|
||||
# if process_virtual returned a non-True value then we are
|
||||
# if _process_virtual returned a non-True value then we are
|
||||
# supposed to not process this module
|
||||
if virtual_ret is not True and module_name not in self.missing_modules:
|
||||
# If a module has information about why it could not be loaded, record it
|
||||
|
@ -1619,39 +1622,42 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
if '.' not in key:
|
||||
raise KeyError('The key \'%s\' should contain a \'.\'', key)
|
||||
mod_name, _ = key.split('.', 1)
|
||||
if mod_name in self.missing_modules:
|
||||
return True
|
||||
# if the modulename isn't in the whitelist, don't bother
|
||||
if self.whitelist and mod_name not in self.whitelist:
|
||||
raise KeyError
|
||||
with self._lock:
|
||||
# It is possible that the key is in the dictionary after
|
||||
# acquiring the lock due to another thread loading it.
|
||||
if mod_name in self.missing_modules or key in self._dict:
|
||||
return True
|
||||
# if the modulename isn't in the whitelist, don't bother
|
||||
if self.whitelist and mod_name not in self.whitelist:
|
||||
raise KeyError
|
||||
|
||||
def _inner_load(mod_name):
|
||||
for name in self._iter_files(mod_name):
|
||||
if name in self.loaded_files:
|
||||
continue
|
||||
# if we got what we wanted, we are done
|
||||
if self._load_module(name) and key in self._dict:
|
||||
return True
|
||||
return False
|
||||
def _inner_load(mod_name):
|
||||
for name in self._iter_files(mod_name):
|
||||
if name in self.loaded_files:
|
||||
continue
|
||||
# if we got what we wanted, we are done
|
||||
if self._load_module(name) and key in self._dict:
|
||||
return True
|
||||
return False
|
||||
|
||||
# try to load the module
|
||||
ret = None
|
||||
reloaded = False
|
||||
# re-scan up to once, IOErrors or a failed load cause re-scans of the
|
||||
# filesystem
|
||||
while True:
|
||||
try:
|
||||
ret = _inner_load(mod_name)
|
||||
if not reloaded and ret is not True:
|
||||
self.refresh_file_mapping()
|
||||
reloaded = True
|
||||
# try to load the module
|
||||
ret = None
|
||||
reloaded = False
|
||||
# re-scan up to once, IOErrors or a failed load cause re-scans of the
|
||||
# filesystem
|
||||
while True:
|
||||
try:
|
||||
ret = _inner_load(mod_name)
|
||||
if not reloaded and ret is not True:
|
||||
self._refresh_file_mapping()
|
||||
reloaded = True
|
||||
continue
|
||||
break
|
||||
except IOError:
|
||||
if not reloaded:
|
||||
self._refresh_file_mapping()
|
||||
reloaded = True
|
||||
continue
|
||||
break
|
||||
except IOError:
|
||||
if not reloaded:
|
||||
self.refresh_file_mapping()
|
||||
reloaded = True
|
||||
continue
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -1659,16 +1665,18 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
'''
|
||||
Load all of them
|
||||
'''
|
||||
for name in self.file_mapping:
|
||||
if name in self.loaded_files or name in self.missing_modules:
|
||||
continue
|
||||
self._load_module(name)
|
||||
with self._lock:
|
||||
for name in self.file_mapping:
|
||||
if name in self.loaded_files or name in self.missing_modules:
|
||||
continue
|
||||
self._load_module(name)
|
||||
|
||||
self.loaded = True
|
||||
self.loaded = True
|
||||
|
||||
def reload_modules(self):
|
||||
self.loaded_files = set()
|
||||
self._load_all()
|
||||
with self._lock:
|
||||
self.loaded_files = set()
|
||||
self._load_all()
|
||||
|
||||
def _apply_outputter(self, func, mod):
|
||||
'''
|
||||
|
@ -1679,7 +1687,7 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
if func.__name__ in outp:
|
||||
func.__outputter__ = outp[func.__name__]
|
||||
|
||||
def process_virtual(self, mod, module_name, virtual_func='__virtual__'):
|
||||
def _process_virtual(self, mod, module_name, virtual_func='__virtual__'):
|
||||
'''
|
||||
Given a loaded module and its default name determine its virtual name
|
||||
|
||||
|
|
|
@ -443,7 +443,7 @@ def _run(cmd,
|
|||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE
|
||||
).communicate(salt.utils.stringutils.to_bytes(py_code))[0]
|
||||
).communicate(salt.utils.stringutils.to_bytes(py_code))
|
||||
marker_count = env_bytes.count(marker_b)
|
||||
if marker_count == 0:
|
||||
# Possibly PAM prevented the login
|
||||
|
@ -482,10 +482,11 @@ def _run(cmd,
|
|||
if env_runas.get('USER') != runas:
|
||||
env_runas['USER'] = runas
|
||||
env = env_runas
|
||||
except ValueError:
|
||||
except ValueError as exc:
|
||||
log.exception('Error raised retrieving environment for user %s', runas)
|
||||
raise CommandExecutionError(
|
||||
'Environment could not be retrieved for User \'{0}\''.format(
|
||||
runas
|
||||
'Environment could not be retrieved for user \'{0}\': {1}'.format(
|
||||
runas, exc
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -609,7 +610,7 @@ def _run(cmd,
|
|||
ret['retcode'] = 1
|
||||
return ret
|
||||
|
||||
if output_encoding is not None:
|
||||
if output_loglevel != 'quiet' and output_encoding is not None:
|
||||
log.debug('Decoding output from command %s using %s encoding',
|
||||
cmd, output_encoding)
|
||||
|
||||
|
@ -625,10 +626,11 @@ def _run(cmd,
|
|||
proc.stdout,
|
||||
encoding=output_encoding,
|
||||
errors='replace')
|
||||
log.error(
|
||||
'Failed to decode stdout from command %s, non-decodable '
|
||||
'characters have been replaced', cmd
|
||||
)
|
||||
if output_loglevel != 'quiet':
|
||||
log.error(
|
||||
'Failed to decode stdout from command %s, non-decodable '
|
||||
'characters have been replaced', cmd
|
||||
)
|
||||
|
||||
try:
|
||||
err = salt.utils.stringutils.to_unicode(
|
||||
|
@ -642,10 +644,11 @@ def _run(cmd,
|
|||
proc.stderr,
|
||||
encoding=output_encoding,
|
||||
errors='replace')
|
||||
log.error(
|
||||
'Failed to decode stderr from command %s, non-decodable '
|
||||
'characters have been replaced', cmd
|
||||
)
|
||||
if output_loglevel != 'quiet':
|
||||
log.error(
|
||||
'Failed to decode stderr from command %s, non-decodable '
|
||||
'characters have been replaced', cmd
|
||||
)
|
||||
|
||||
if rstrip:
|
||||
if out is not None:
|
||||
|
|
|
@ -3800,6 +3800,7 @@ def rm_(name, force=False, volumes=False, **kwargs):
|
|||
kwargs = __utils__['args.clean_kwargs'](**kwargs)
|
||||
stop_ = kwargs.pop('stop', False)
|
||||
timeout = kwargs.pop('timeout', None)
|
||||
auto_remove = False
|
||||
if kwargs:
|
||||
__utils__['args.invalid_kwargs'](kwargs)
|
||||
|
||||
|
@ -3809,9 +3810,19 @@ def rm_(name, force=False, volumes=False, **kwargs):
|
|||
'remove this container'.format(name)
|
||||
)
|
||||
if stop_ and not force:
|
||||
inspect_results = inspect_container(name)
|
||||
try:
|
||||
auto_remove = inspect_results['HostConfig']['AutoRemove']
|
||||
except KeyError:
|
||||
log.error(
|
||||
'Failed to find AutoRemove in inspect results, Docker API may '
|
||||
'have changed. Full results: %s', inspect_results
|
||||
)
|
||||
stop(name, timeout=timeout)
|
||||
pre = ps_(all=True)
|
||||
_client_wrapper('remove_container', name, v=volumes, force=force)
|
||||
|
||||
if not auto_remove:
|
||||
_client_wrapper('remove_container', name, v=volumes, force=force)
|
||||
_clear_context()
|
||||
return [x for x in pre if x not in ps_(all=True)]
|
||||
|
||||
|
|
|
@ -221,9 +221,6 @@ def _git_run(command, cwd=None, user=None, password=None, identity=None,
|
|||
'cmd.run_all', and used as an alternative to 'cmd.run_all'. Some
|
||||
commands don't return proper retcodes, so this can't replace 'cmd.run_all'.
|
||||
'''
|
||||
if salt.utils.platform.is_windows() and output_encoding is None:
|
||||
output_encoding = 'utf-8'
|
||||
|
||||
env = {}
|
||||
|
||||
if identity:
|
||||
|
@ -516,21 +513,9 @@ def add(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -664,21 +649,9 @@ def archive(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -790,21 +763,9 @@ def branch(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -903,21 +864,9 @@ def checkout(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1069,21 +1018,9 @@ def clone(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1210,21 +1147,9 @@ def commit(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1309,21 +1234,9 @@ def config_get(key,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1420,21 +1333,9 @@ def config_get_regexp(key,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1545,21 +1446,9 @@ def config_set(key,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1696,21 +1585,9 @@ def config_unset(key,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1819,21 +1696,9 @@ def current_branch(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -1891,21 +1756,9 @@ def describe(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2015,21 +1868,9 @@ def diff(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2222,21 +2063,9 @@ def fetch(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2382,21 +2211,9 @@ def init(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2471,21 +2288,9 @@ def is_worktree(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2571,21 +2376,9 @@ def list_branches(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2642,21 +2435,9 @@ def list_tags(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2730,21 +2511,9 @@ def list_worktrees(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3116,21 +2885,9 @@ def ls_remote(cwd=None,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3237,21 +2994,9 @@ def merge(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3390,21 +3135,9 @@ def merge_base(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3559,21 +3292,9 @@ def merge_tree(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3689,21 +3410,9 @@ def pull(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3827,21 +3536,9 @@ def push(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3935,21 +3632,9 @@ def rebase(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4032,21 +3717,9 @@ def remote_get(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4151,21 +3824,9 @@ def remote_refs(url,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4275,21 +3936,9 @@ def remote_set(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4402,21 +4051,9 @@ def remotes(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4511,21 +4148,9 @@ def reset(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4609,21 +4234,9 @@ def rev_parse(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4701,21 +4314,9 @@ def revision(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4799,21 +4400,9 @@ def rm_(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4893,21 +4482,9 @@ def stash(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -4970,21 +4547,9 @@ def status(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -5125,21 +4690,9 @@ def submodule(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -5252,21 +4805,9 @@ def symbolic_ref(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -5447,21 +4988,9 @@ def worktree_add(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -5593,21 +5122,9 @@ def worktree_prune(cwd,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -5672,21 +5189,9 @@ def worktree_rm(cwd, user=None, output_encoding=None):
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ def _localectl_status():
|
|||
ret[ctl_key] = {}
|
||||
ret[ctl_key][loc_set[0]] = loc_set[1]
|
||||
else:
|
||||
ret[ctl_key] = ctl_data
|
||||
ret[ctl_key] = {'data': ctl_data}
|
||||
if not ret:
|
||||
log.debug("Unable to find any locale information inside the following data:\n%s", locale_ctl_out)
|
||||
raise CommandExecutionError('Unable to parse result of "localectl"')
|
||||
|
|
|
@ -25,7 +25,6 @@ import logging
|
|||
|
||||
try:
|
||||
from sense_hat import SenseHat
|
||||
_sensehat = SenseHat()
|
||||
has_sense_hat = True
|
||||
except (ImportError, NameError):
|
||||
_sensehat = None
|
||||
|
@ -39,15 +38,20 @@ def __virtual__():
|
|||
Only load the module if SenseHat is available
|
||||
'''
|
||||
if has_sense_hat:
|
||||
try:
|
||||
_sensehat = SenseHat()
|
||||
except OSError:
|
||||
return False, 'This module can only be used on a Raspberry Pi with a SenseHat.'
|
||||
|
||||
rotation = __salt__['pillar.get']('sensehat:rotation', 0)
|
||||
if rotation in [0, 90, 180, 270]:
|
||||
_sensehat.set_rotation(rotation, False)
|
||||
else:
|
||||
log.error("%s is not a valid rotation. Using default rotation.",
|
||||
log.error('%s is not a valid rotation. Using default rotation.',
|
||||
rotation)
|
||||
return True
|
||||
else:
|
||||
return False, "The SenseHat excecution module can not be loaded: SenseHat unavailable.\nThis module can only be used on a Raspberry Pi with a SenseHat. Also make sure that the sense_hat python library is installed!"
|
||||
|
||||
return False, 'The SenseHat execution module cannot be loaded: \'sense_hat\' python library unavailable.'
|
||||
|
||||
|
||||
def set_pixels(pixels):
|
||||
|
|
|
@ -11,7 +11,6 @@ import logging
|
|||
import salt.utils.json
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
import salt.utils.decorators as decorators
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -26,14 +25,6 @@ __func_alias__ = {
|
|||
__virtualname__ = 'imgadm'
|
||||
|
||||
|
||||
@decorators.memoize
|
||||
def _check_imgadm():
|
||||
'''
|
||||
Looks to see if imgadm is present on the system
|
||||
'''
|
||||
return salt.utils.path.which('imgadm')
|
||||
|
||||
|
||||
def _exit_status(retcode):
|
||||
'''
|
||||
Translate exit status of imgadm
|
||||
|
@ -70,11 +61,12 @@ def __virtual__():
|
|||
'''
|
||||
Provides imgadm only on SmartOS
|
||||
'''
|
||||
if salt.utils.platform.is_smartos_globalzone() and _check_imgadm():
|
||||
if salt.utils.platform.is_smartos_globalzone() and \
|
||||
salt.utils.path.which('imgadm'):
|
||||
return __virtualname__
|
||||
return (
|
||||
False,
|
||||
'{0} module can only be loaded on SmartOS computed nodes'.format(
|
||||
'{0} module can only be loaded on SmartOS compute nodes'.format(
|
||||
__virtualname__
|
||||
)
|
||||
)
|
||||
|
@ -91,8 +83,7 @@ def version():
|
|||
salt '*' imgadm.version
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} --version'.format(imgadm)
|
||||
cmd = 'imgadm --version'
|
||||
res = __salt__['cmd.run'](cmd).splitlines()
|
||||
ret = res[0].split()
|
||||
return ret[-1]
|
||||
|
@ -111,10 +102,8 @@ def update_installed(uuid=''):
|
|||
|
||||
salt '*' imgadm.update [uuid]
|
||||
'''
|
||||
imgadm = _check_imgadm()
|
||||
if imgadm:
|
||||
cmd = '{0} update {1}'.format(imgadm, uuid).rstrip()
|
||||
__salt__['cmd.run'](cmd)
|
||||
cmd = 'imgadm update {0}'.format(uuid).rstrip()
|
||||
__salt__['cmd.run'](cmd)
|
||||
return {}
|
||||
|
||||
|
||||
|
@ -135,8 +124,7 @@ def avail(search=None, verbose=False):
|
|||
salt '*' imgadm.avail verbose=True
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} avail -j'.format(imgadm)
|
||||
cmd = 'imgadm avail -j'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
result = {}
|
||||
|
@ -169,8 +157,7 @@ def list_installed(verbose=False):
|
|||
salt '*' imgadm.list [verbose=True]
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} list -j'.format(imgadm)
|
||||
cmd = 'imgadm list -j'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
result = {}
|
||||
|
@ -198,8 +185,7 @@ def show(uuid):
|
|||
salt '*' imgadm.show e42f8c84-bbea-11e2-b920-078fab2aab1f
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} show {1}'.format(imgadm, uuid)
|
||||
cmd = 'imgadm show {0}'.format(uuid)
|
||||
res = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -223,8 +209,7 @@ def get(uuid):
|
|||
salt '*' imgadm.get e42f8c84-bbea-11e2-b920-078fab2aab1f
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} get {1}'.format(imgadm, uuid)
|
||||
cmd = 'imgadm get {0}'.format(uuid)
|
||||
res = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -250,8 +235,7 @@ def import_image(uuid, verbose=False):
|
|||
salt '*' imgadm.import e42f8c84-bbea-11e2-b920-078fab2aab1f [verbose=True]
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} import {1}'.format(imgadm, uuid)
|
||||
cmd = 'imgadm import {0}'.format(uuid)
|
||||
res = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -275,8 +259,7 @@ def delete(uuid):
|
|||
salt '*' imgadm.delete e42f8c84-bbea-11e2-b920-078fab2aab1f
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} delete {1}'.format(imgadm, uuid)
|
||||
cmd = 'imgadm delete {0}'.format(uuid)
|
||||
res = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -305,8 +288,7 @@ def vacuum(verbose=False):
|
|||
salt '*' imgadm.vacuum [verbose=True]
|
||||
'''
|
||||
ret = {}
|
||||
imgadm = _check_imgadm()
|
||||
cmd = '{0} vacuum -f'.format(imgadm)
|
||||
cmd = 'imgadm vacuum -f'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
|
|
@ -17,7 +17,6 @@ import logging
|
|||
# Import Salt libs
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
import salt.utils.decorators as decorators
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -30,31 +29,17 @@ __func_alias__ = {
|
|||
__virtualname__ = 'nictagadm'
|
||||
|
||||
|
||||
@decorators.memoize
|
||||
def _check_nictagadm():
|
||||
'''
|
||||
Looks to see if nictagadm is present on the system
|
||||
'''
|
||||
return salt.utils.path.which('nictagadm')
|
||||
|
||||
|
||||
def _check_dladm():
|
||||
'''
|
||||
Looks to see if dladm is present on the system
|
||||
'''
|
||||
return salt.utils.path.which('dladm')
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Provides nictagadm on SmartOS
|
||||
'''
|
||||
if salt.utils.platform.is_smartos_globalzone() \
|
||||
and _check_nictagadm() and _check_dladm():
|
||||
if salt.utils.platform.is_smartos_globalzone() and \
|
||||
salt.utils.path.which('dladm') and \
|
||||
salt.utils.path.which('nictagadm'):
|
||||
return __virtualname__
|
||||
return (
|
||||
False,
|
||||
'{0} module can only be loaded on SmartOS computed nodes'.format(
|
||||
'{0} module can only be loaded on SmartOS compute nodes'.format(
|
||||
__virtualname__
|
||||
)
|
||||
)
|
||||
|
@ -74,10 +59,8 @@ def list_nictags(include_etherstubs=True):
|
|||
salt '*' nictagadm.list
|
||||
'''
|
||||
ret = {}
|
||||
nictagadm = _check_nictagadm()
|
||||
cmd = '{nictagadm} list -d "|" -p{estubs}'.format(
|
||||
nictagadm=nictagadm,
|
||||
estubs=' -L' if not include_etherstubs else ''
|
||||
cmd = 'nictagadm list -d "|" -p{0}'.format(
|
||||
' -L' if not include_etherstubs else ''
|
||||
)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
|
@ -109,11 +92,7 @@ def vms(nictag):
|
|||
salt '*' nictagadm.vms admin
|
||||
'''
|
||||
ret = {}
|
||||
nictagadm = _check_nictagadm()
|
||||
cmd = '{nictagadm} vms {nictag}'.format(
|
||||
nictagadm=nictagadm,
|
||||
nictag=nictag
|
||||
)
|
||||
cmd = 'nictagadm vms {0}'.format(nictag)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -139,14 +118,10 @@ def exists(*nictag, **kwargs):
|
|||
salt '*' nictagadm.exists admin
|
||||
'''
|
||||
ret = {}
|
||||
nictagadm = _check_nictagadm()
|
||||
if len(nictag) == 0:
|
||||
if not nictag:
|
||||
return {'Error': 'Please provide at least one nictag to check.'}
|
||||
|
||||
cmd = '{nictagadm} exists -l {nictags}'.format(
|
||||
nictagadm=nictagadm,
|
||||
nictags=' '.join(nictag)
|
||||
)
|
||||
cmd = 'nictagadm exists -l {0}'.format(' '.join(nictag))
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
|
||||
if not kwargs.get('verbose', False):
|
||||
|
@ -168,43 +143,31 @@ def add(name, mac, mtu=1500):
|
|||
mac : string
|
||||
mac of parent interface or 'etherstub' to create a ether stub
|
||||
mtu : int
|
||||
MTU
|
||||
MTU (ignored for etherstubs)
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' nictagadm.add storage etherstub
|
||||
salt '*' nictagadm.add trunk 'DE:AD:OO:OO:BE:EF' 9000
|
||||
salt '*' nictagadm.add storage0 etherstub
|
||||
salt '*' nictagadm.add trunk0 'DE:AD:OO:OO:BE:EF' 9000
|
||||
'''
|
||||
ret = {}
|
||||
nictagadm = _check_nictagadm()
|
||||
dladm = _check_dladm()
|
||||
|
||||
if mtu > 9000 or mtu < 1500:
|
||||
return {'Error': 'mtu must be a value between 1500 and 9000.'}
|
||||
if mac != 'etherstub':
|
||||
cmd = '{dladm} show-phys -m -p -o address'.format(
|
||||
dladm=dladm
|
||||
)
|
||||
cmd = 'dladm show-phys -m -p -o address'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
if mac not in res['stdout'].splitlines():
|
||||
# dladm prints '00' as '0', so account for that.
|
||||
if mac.replace('00', '0') not in res['stdout'].splitlines():
|
||||
return {'Error': '{0} is not present on this system.'.format(mac)}
|
||||
|
||||
if mac == 'etherstub':
|
||||
cmd = '{nictagadm} add -l -p mtu={mtu} {name}'.format(
|
||||
nictagadm=nictagadm,
|
||||
mtu=mtu,
|
||||
name=name
|
||||
)
|
||||
cmd = 'nictagadm add -l {0}'.format(name)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
else:
|
||||
cmd = '{nictagadm} add -p mtu={mtu},mac={mac} {name}'.format(
|
||||
nictagadm=nictagadm,
|
||||
mtu=mtu,
|
||||
mac=mac,
|
||||
name=name
|
||||
)
|
||||
cmd = 'nictagadm add -p mtu={0},mac={1} {2}'.format(mtu, mac, name)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
|
||||
if res['retcode'] == 0:
|
||||
|
@ -231,8 +194,6 @@ def update(name, mac=None, mtu=None):
|
|||
salt '*' nictagadm.update trunk mtu=9000
|
||||
'''
|
||||
ret = {}
|
||||
nictagadm = _check_nictagadm()
|
||||
dladm = _check_dladm()
|
||||
|
||||
if name not in list_nictags():
|
||||
return {'Error': 'nictag {0} does not exists.'.format(name)}
|
||||
|
@ -245,11 +206,10 @@ def update(name, mac=None, mtu=None):
|
|||
if mac == 'etherstub':
|
||||
return {'Error': 'cannot update a nic with "etherstub".'}
|
||||
else:
|
||||
cmd = '{dladm} show-phys -m -p -o address'.format(
|
||||
dladm=dladm
|
||||
)
|
||||
cmd = 'dladm show-phys -m -p -o address'
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
if mac not in res['stdout'].splitlines():
|
||||
# dladm prints '00' as '0', so account for that.
|
||||
if mac.replace('00', '0') not in res['stdout'].splitlines():
|
||||
return {'Error': '{0} is not present on this system.'.format(mac)}
|
||||
|
||||
if mac and mtu:
|
||||
|
@ -259,11 +219,7 @@ def update(name, mac=None, mtu=None):
|
|||
elif mtu:
|
||||
properties = "mtu={0}".format(mtu) if mtu else ""
|
||||
|
||||
cmd = '{nictagadm} update -p {properties} {name}'.format(
|
||||
nictagadm=nictagadm,
|
||||
properties=properties,
|
||||
name=name
|
||||
)
|
||||
cmd = 'nictagadm update -p {0} {1}'.format(properties, name)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
|
||||
if res['retcode'] == 0:
|
||||
|
@ -288,16 +244,11 @@ def delete(name, force=False):
|
|||
salt '*' nictagadm.exists admin
|
||||
'''
|
||||
ret = {}
|
||||
nictagadm = _check_nictagadm()
|
||||
|
||||
if name not in list_nictags():
|
||||
return True
|
||||
|
||||
cmd = '{nictagadm} delete {force}{name}'.format(
|
||||
nictagadm=nictagadm,
|
||||
force="-f " if force else "",
|
||||
name=name
|
||||
)
|
||||
cmd = 'nictagadm delete {0}{1}'.format("-f " if force else "", name)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
|
||||
if res['retcode'] == 0:
|
||||
|
|
|
@ -27,7 +27,7 @@ def __virtual__():
|
|||
return __virtualname__
|
||||
return (
|
||||
False,
|
||||
'{0} module can only be loaded on SmartOS computed nodes'.format(
|
||||
'{0} module can only be loaded on SmartOS compute nodes'.format(
|
||||
__virtualname__
|
||||
)
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ except ImportError:
|
|||
|
||||
# Import Salt libs
|
||||
import salt.utils.args
|
||||
import salt.utils.decorators as decorators
|
||||
import salt.utils.files
|
||||
import salt.utils.json
|
||||
import salt.utils.path
|
||||
|
@ -36,30 +35,17 @@ __func_alias__ = {
|
|||
__virtualname__ = 'vmadm'
|
||||
|
||||
|
||||
@decorators.memoize
|
||||
def _check_vmadm():
|
||||
'''
|
||||
Looks to see if vmadm is present on the system
|
||||
'''
|
||||
return salt.utils.path.which('vmadm')
|
||||
|
||||
|
||||
def _check_zfs():
|
||||
'''
|
||||
Looks to see if zfs is present on the system
|
||||
'''
|
||||
return salt.utils.path.which('zfs')
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Provides vmadm on SmartOS
|
||||
'''
|
||||
if salt.utils.platform.is_smartos_globalzone() and _check_vmadm():
|
||||
if salt.utils.platform.is_smartos_globalzone() and \
|
||||
salt.utils.path.which('vmadm') and \
|
||||
salt.utils.path.which('zfs'):
|
||||
return __virtualname__
|
||||
return (
|
||||
False,
|
||||
'{0} module can only be loaded on SmartOS computed nodes'.format(
|
||||
'{0} module can only be loaded on SmartOS compute nodes'.format(
|
||||
__virtualname__
|
||||
)
|
||||
)
|
||||
|
@ -80,13 +66,11 @@ def _create_update_from_file(mode='create', uuid=None, path=None):
|
|||
Create vm from file
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if not os.path.isfile(path) or path is None:
|
||||
ret['Error'] = 'File ({0}) does not exists!'.format(path)
|
||||
return ret
|
||||
# vmadm validate create|update [-f <filename>]
|
||||
cmd = '{vmadm} validate {mode} {brand} -f {path}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm validate {mode} {brand} -f {path}'.format(
|
||||
mode=mode,
|
||||
brand=get(uuid)['brand'] if uuid is not None else '',
|
||||
path=path
|
||||
|
@ -102,8 +86,7 @@ def _create_update_from_file(mode='create', uuid=None, path=None):
|
|||
ret['Error'] = res['stderr']
|
||||
return ret
|
||||
# vmadm create|update [-f <filename>]
|
||||
cmd = '{vmadm} {mode} {uuid} -f {path}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm {mode} {uuid} -f {path}'.format(
|
||||
mode=mode,
|
||||
uuid=uuid if uuid is not None else '',
|
||||
path=path
|
||||
|
@ -129,7 +112,6 @@ def _create_update_from_cfg(mode='create', uuid=None, vmcfg=None):
|
|||
Create vm from configuration
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
|
||||
# write json file
|
||||
vmadm_json_file = __salt__['temp.file'](prefix='vmadm-')
|
||||
|
@ -137,8 +119,7 @@ def _create_update_from_cfg(mode='create', uuid=None, vmcfg=None):
|
|||
salt.utils.json.dump(vmcfg, vmadm_json)
|
||||
|
||||
# vmadm validate create|update [-f <filename>]
|
||||
cmd = '{vmadm} validate {mode} {brand} -f {vmadm_json_file}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm validate {mode} {brand} -f {vmadm_json_file}'.format(
|
||||
mode=mode,
|
||||
brand=get(uuid)['brand'] if uuid is not None else '',
|
||||
vmadm_json_file=vmadm_json_file
|
||||
|
@ -154,8 +135,7 @@ def _create_update_from_cfg(mode='create', uuid=None, vmcfg=None):
|
|||
ret['Error'] = res['stderr']
|
||||
return ret
|
||||
# vmadm create|update [-f <filename>]
|
||||
cmd = '{vmadm} {mode} {uuid} -f {vmadm_json_file}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm {mode} {uuid} -f {vmadm_json_file}'.format(
|
||||
mode=mode,
|
||||
uuid=uuid if uuid is not None else '',
|
||||
vmadm_json_file=vmadm_json_file
|
||||
|
@ -202,7 +182,6 @@ def start(vm, options=None, key='uuid'):
|
|||
salt '*' vmadm.start vm=nina.example.org key=hostname
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -210,8 +189,7 @@ def start(vm, options=None, key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm start <uuid> [option=value ...]
|
||||
cmd = '{vmadm} start {uuid} {options}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm start {uuid} {options}'.format(
|
||||
uuid=vm,
|
||||
options=options if options else ''
|
||||
)
|
||||
|
@ -244,7 +222,6 @@ def stop(vm, force=False, key='uuid'):
|
|||
salt '*' vmadm.stop vm=nina.example.org key=hostname
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -252,8 +229,7 @@ def stop(vm, force=False, key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm stop <uuid> [-F]
|
||||
cmd = '{vmadm} stop {force} {uuid}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm stop {force} {uuid}'.format(
|
||||
force='-F' if force else '',
|
||||
uuid=vm
|
||||
)
|
||||
|
@ -286,7 +262,6 @@ def reboot(vm, force=False, key='uuid'):
|
|||
salt '*' vmadm.reboot vm=nina.example.org key=hostname
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -294,8 +269,7 @@ def reboot(vm, force=False, key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm reboot <uuid> [-F]
|
||||
cmd = '{vmadm} reboot {force} {uuid}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm reboot {force} {uuid}'.format(
|
||||
force='-F' if force else '',
|
||||
uuid=vm
|
||||
)
|
||||
|
@ -331,10 +305,8 @@ def list_vms(search=None, sort=None, order='uuid,type,ram,state,alias', keyed=Tr
|
|||
salt '*' vmadm.list search='type=KVM'
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
# vmadm list [-p] [-H] [-o field,...] [-s field,...] [field=value ...]
|
||||
cmd = '{vmadm} list -p -H {order} {sort} {search}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm list -p -H {order} {sort} {search}'.format(
|
||||
order='-o {0}'.format(order) if order else '',
|
||||
sort='-s {0}'.format(sort) if sort else '',
|
||||
search=search if search else ''
|
||||
|
@ -387,10 +359,8 @@ def lookup(search=None, order=None, one=False):
|
|||
salt '*' vmadm.lookup search='alias=nacl' one=True
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
# vmadm lookup [-j|-1] [-o field,...] [field=value ...]
|
||||
cmd = '{vmadm} lookup {one} {order} {search}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm lookup {one} {order} {search}'.format(
|
||||
one='-1' if one else '-j',
|
||||
order='-o {0}'.format(order) if order else '',
|
||||
search=search if search else ''
|
||||
|
@ -431,7 +401,6 @@ def sysrq(vm, action='nmi', key='uuid'):
|
|||
salt '*' vmadm.sysrq nacl nmi key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -442,8 +411,7 @@ def sysrq(vm, action='nmi', key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm sysrq <uuid> <nmi|screenshot>
|
||||
cmd = '{vmadm} sysrq {uuid} {action}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm sysrq {uuid} {action}'.format(
|
||||
uuid=vm,
|
||||
action=action
|
||||
)
|
||||
|
@ -472,7 +440,6 @@ def delete(vm, key='uuid'):
|
|||
salt '*' vmadm.delete nacl key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -480,10 +447,7 @@ def delete(vm, key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm delete <uuid>
|
||||
cmd = '{vmadm} delete {uuid}'.format(
|
||||
vmadm=vmadm,
|
||||
uuid=vm
|
||||
)
|
||||
cmd = 'vmadm delete {0}'.format(vm)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -509,7 +473,6 @@ def get(vm, key='uuid'):
|
|||
salt '*' vmadm.get nacl key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -517,10 +480,7 @@ def get(vm, key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm get <uuid>
|
||||
cmd = '{vmadm} get {uuid}'.format(
|
||||
vmadm=vmadm,
|
||||
uuid=vm
|
||||
)
|
||||
cmd = 'vmadm get {0}'.format(vm)
|
||||
res = __salt__['cmd.run_all'](cmd)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0:
|
||||
|
@ -550,7 +510,6 @@ def info(vm, info_type='all', key='uuid'):
|
|||
salt '*' vmadm.info nacl vnc key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if info_type not in ['all', 'block', 'blockstats', 'chardev', 'cpus', 'kvm', 'pci', 'spice', 'version', 'vnc']:
|
||||
ret['Error'] = 'Requested info_type is not available'
|
||||
return ret
|
||||
|
@ -561,8 +520,7 @@ def info(vm, info_type='all', key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm info <uuid> [type,...]
|
||||
cmd = '{vmadm} info {uuid} {type}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm info {uuid} {type}'.format(
|
||||
uuid=vm,
|
||||
type=info_type
|
||||
)
|
||||
|
@ -596,7 +554,6 @@ def create_snapshot(vm, name, key='uuid'):
|
|||
salt '*' vmadm.create_snapshot nacl baseline key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -614,8 +571,7 @@ def create_snapshot(vm, name, key='uuid'):
|
|||
ret['Error'] = 'VM must be running to take a snapshot'
|
||||
return ret
|
||||
# vmadm create-snapshot <uuid> <snapname>
|
||||
cmd = '{vmadm} create-snapshot {uuid} {snapshot}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm create-snapshot {uuid} {snapshot}'.format(
|
||||
snapshot=name,
|
||||
uuid=vm
|
||||
)
|
||||
|
@ -649,7 +605,6 @@ def delete_snapshot(vm, name, key='uuid'):
|
|||
salt '*' vmadm.delete_snapshot nacl baseline key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -664,8 +619,7 @@ def delete_snapshot(vm, name, key='uuid'):
|
|||
ret['Error'] = 'VM must be of type OS'
|
||||
return ret
|
||||
# vmadm delete-snapshot <uuid> <snapname>
|
||||
cmd = '{vmadm} delete-snapshot {uuid} {snapshot}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm delete-snapshot {uuid} {snapshot}'.format(
|
||||
snapshot=name,
|
||||
uuid=vm
|
||||
)
|
||||
|
@ -699,7 +653,6 @@ def rollback_snapshot(vm, name, key='uuid'):
|
|||
salt '*' vmadm.rollback_snapshot nacl baseline key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -714,8 +667,7 @@ def rollback_snapshot(vm, name, key='uuid'):
|
|||
ret['Error'] = 'VM must be of type OS'
|
||||
return ret
|
||||
# vmadm rollback-snapshot <uuid> <snapname>
|
||||
cmd = '{vmadm} rollback-snapshot {uuid} {snapshot}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm rollback-snapshot {uuid} {snapshot}'.format(
|
||||
snapshot=name,
|
||||
uuid=vm
|
||||
)
|
||||
|
@ -746,7 +698,6 @@ def reprovision(vm, image, key='uuid'):
|
|||
salt '*' vmadm.reprovision nacl c02a2044-c1bd-11e4-bd8c-dfc1db8b0182 key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -757,8 +708,7 @@ def reprovision(vm, image, key='uuid'):
|
|||
ret['Error'] = 'Image ({0}) is not present on this host'.format(image)
|
||||
return ret
|
||||
# vmadm reprovision <uuid> [-f <filename>]
|
||||
cmd = six.text_type('echo {image} | {vmadm} reprovision {uuid}').format(
|
||||
vmadm=salt.utils.stringutils.to_unicode(vmadm),
|
||||
cmd = six.text_type('echo {image} | vmadm reprovision {uuid}').format(
|
||||
uuid=salt.utils.stringutils.to_unicode(vm),
|
||||
image=_quote_args(salt.utils.json.dumps({'image_uuid': image}))
|
||||
)
|
||||
|
@ -821,7 +771,6 @@ def update(vm, from_file=None, key='uuid', **kwargs):
|
|||
salt '*' vmadm.update vm=186da9ab-7392-4f55-91a5-b8f1fe770543 max_physical_memory=1024
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
# prepare vmcfg
|
||||
vmcfg = {}
|
||||
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||
|
@ -860,8 +809,6 @@ def send(vm, target, key='uuid'):
|
|||
salt '*' vmadm.send vm=nacl target=/opt/backups key=alias
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
zfs = _check_zfs()
|
||||
if key not in ['uuid', 'alias', 'hostname']:
|
||||
ret['Error'] = 'Key must be either uuid, alias or hostname'
|
||||
return ret
|
||||
|
@ -872,8 +819,7 @@ def send(vm, target, key='uuid'):
|
|||
if 'Error' in vm:
|
||||
return vm
|
||||
# vmadm send <uuid> [target]
|
||||
cmd = '{vmadm} send {uuid} > {target}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm send {uuid} > {target}'.format(
|
||||
uuid=vm,
|
||||
target=os.path.join(target, '{0}.vmdata'.format(vm))
|
||||
)
|
||||
|
@ -890,8 +836,7 @@ def send(vm, target, key='uuid'):
|
|||
for dataset in vmobj['datasets']:
|
||||
name = dataset.split('/')
|
||||
name = name[-1]
|
||||
cmd = '{zfs} send {dataset} > {target}'.format(
|
||||
zfs=zfs,
|
||||
cmd = 'zfs send {dataset} > {target}'.format(
|
||||
dataset=dataset,
|
||||
target=os.path.join(target, '{0}-{1}.zfsds'.format(vm, name))
|
||||
)
|
||||
|
@ -919,8 +864,6 @@ def receive(uuid, source):
|
|||
salt '*' vmadm.receive 186da9ab-7392-4f55-91a5-b8f1fe770543 /opt/backups
|
||||
'''
|
||||
ret = {}
|
||||
vmadm = _check_vmadm()
|
||||
zfs = _check_zfs()
|
||||
if not os.path.isdir(source):
|
||||
ret['Error'] = 'Source must be a directory or host'
|
||||
return ret
|
||||
|
@ -928,8 +871,7 @@ def receive(uuid, source):
|
|||
ret['Error'] = 'Unknow vm with uuid in {0}'.format(source)
|
||||
return ret
|
||||
# vmadm receive
|
||||
cmd = '{vmadm} receive < {source}'.format(
|
||||
vmadm=vmadm,
|
||||
cmd = 'vmadm receive < {source}'.format(
|
||||
source=os.path.join(source, '{0}.vmdata'.format(uuid))
|
||||
)
|
||||
res = __salt__['cmd.run_all'](cmd, python_shell=True)
|
||||
|
@ -945,8 +887,7 @@ def receive(uuid, source):
|
|||
for dataset in vmobj['datasets']:
|
||||
name = dataset.split('/')
|
||||
name = name[-1]
|
||||
cmd = '{zfs} receive {dataset} < {source}'.format(
|
||||
zfs=zfs,
|
||||
cmd = 'zfs receive {dataset} < {source}'.format(
|
||||
dataset=dataset,
|
||||
source=os.path.join(source, '{0}-{1}.zfsds'.format(uuid, name))
|
||||
)
|
||||
|
@ -955,10 +896,7 @@ def receive(uuid, source):
|
|||
if retcode != 0:
|
||||
ret['Error'] = res['stderr'] if 'stderr' in res else _exit_status(retcode)
|
||||
return ret
|
||||
cmd = '{vmadm} install {uuid}'.format(
|
||||
vmadm=vmadm,
|
||||
uuid=uuid
|
||||
)
|
||||
cmd = 'vmadm install {0}'.format(uuid)
|
||||
res = __salt__['cmd.run_all'](cmd, python_shell=True)
|
||||
retcode = res['retcode']
|
||||
if retcode != 0 and not res['stderr'].endswith('datasets'):
|
||||
|
|
|
@ -2251,8 +2251,9 @@ def event(tagmatch='*',
|
|||
)
|
||||
sys.stdout.flush()
|
||||
|
||||
count -= 1
|
||||
log.debug('Remaining event matches: %s', count)
|
||||
if count > 0:
|
||||
count -= 1
|
||||
log.debug('Remaining event matches: %s', count)
|
||||
|
||||
if count == 0:
|
||||
break
|
||||
|
|
|
@ -3449,7 +3449,7 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
|
|||
element_valuenames = []
|
||||
element_values = this_element_value
|
||||
if this_element_value is not None:
|
||||
element_valuenames = list(range(1, len(this_element_value) + 1))
|
||||
element_valuenames = list([str(z) for z in range(1, len(this_element_value) + 1)])
|
||||
if 'additive' in element.attrib:
|
||||
if element.attrib['additive'].lower() == 'false':
|
||||
# a delete values will be added before all the other
|
||||
|
@ -3474,11 +3474,18 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
|
|||
if this_element_value is not None:
|
||||
element_valuenames = this_element_value.keys()
|
||||
element_values = this_element_value.values()
|
||||
|
||||
if 'valuePrefix' in element.attrib and element.attrib['valuePrefix'] != '':
|
||||
if this_element_value is not None:
|
||||
element_valuenames = ['{0}{1}'.format(element.attrib['valuePrefix'],
|
||||
k) for k in element_valuenames]
|
||||
if 'valuePrefix' in element.attrib:
|
||||
# if the valuePrefix attribute exists, the valuenames are <prefix><number>
|
||||
# most prefixes attributes are empty in the admx files, so the valuenames
|
||||
# end up being just numbers
|
||||
if element.attrib['valuePrefix'] != '':
|
||||
if this_element_value is not None:
|
||||
element_valuenames = ['{0}{1}'.format(element.attrib['valuePrefix'],
|
||||
k) for k in element_valuenames]
|
||||
else:
|
||||
# if there is no valuePrefix attribute, the valuename is the value
|
||||
if element_values is not None:
|
||||
element_valuenames = [str(z) for z in element_values]
|
||||
if not check_deleted:
|
||||
if this_element_value is not None:
|
||||
log.debug('_processValueItem has an explicit '
|
||||
|
|
|
@ -1882,7 +1882,7 @@ def get_repo_data(saltenv='base'):
|
|||
serial = salt.payload.Serial(__opts__)
|
||||
with salt.utils.files.fopen(repo_details.winrepo_file, 'rb') as repofile:
|
||||
try:
|
||||
repodata = salt.utils.data.decode(serial.loads(repofile.read(), encoding='utf-8') or {})
|
||||
repodata = salt.utils.data.decode(serial.loads(repofile.read()) or {})
|
||||
__context__['winrepo.data'] = repodata
|
||||
return repodata
|
||||
except Exception as exc:
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Proxy Minion interface module for managing Cisco Integrated Management Controller devices
|
||||
=========================================================================================
|
||||
|
||||
Proxy Minion interface module for managing Cisco Integrated Management Controller devices.
|
||||
.. versionadded:: 2018.3.0
|
||||
|
||||
:codeauthor: :email:`Spencer Ervin <spencer_ervin@hotmail.com>`
|
||||
:maturity: new
|
||||
|
@ -21,6 +23,7 @@ documentation.
|
|||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To use this integration proxy module, please configure the following:
|
||||
|
||||
Pillar
|
||||
|
@ -40,6 +43,7 @@ the ID.
|
|||
|
||||
proxytype
|
||||
^^^^^^^^^
|
||||
|
||||
The ``proxytype`` key and value pair is critical, as it tells Salt which
|
||||
interface to load from the ``proxy`` directory in Salt's install hierarchy,
|
||||
or from ``/srv/salt/_proxy`` on the Salt Master (if you have created your
|
||||
|
@ -48,16 +52,18 @@ own proxy module, for example). To use this cimc Proxy Module, set this to
|
|||
|
||||
host
|
||||
^^^^
|
||||
|
||||
The location, or ip/dns, of the cimc host. Required.
|
||||
|
||||
username
|
||||
^^^^^^^^
|
||||
|
||||
The username used to login to the cimc host. Required.
|
||||
|
||||
password
|
||||
^^^^^^^^
|
||||
The password used to login to the cimc host. Required.
|
||||
|
||||
The password used to login to the cimc host. Required.
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Proxy Minion interface module for managing Palo Alto firewall devices
|
||||
=====================================================================
|
||||
|
||||
Proxy Minion interface module for managing Palo Alto firewall devices.
|
||||
.. versionadded:: 2018.3.0
|
||||
|
||||
:codeauthor: :email:`Spencer Ervin <spencer_ervin@hotmail.com>`
|
||||
:maturity: new
|
||||
|
@ -22,6 +24,7 @@ documentation.
|
|||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To use this integration proxy module, please configure the following:
|
||||
|
||||
Pillar
|
||||
|
@ -53,6 +56,7 @@ the device with username and password.
|
|||
|
||||
proxytype
|
||||
^^^^^^^^^
|
||||
|
||||
The ``proxytype`` key and value pair is critical, as it tells Salt which
|
||||
interface to load from the ``proxy`` directory in Salt's install hierarchy,
|
||||
or from ``/srv/salt/_proxy`` on the Salt Master (if you have created your
|
||||
|
@ -61,14 +65,17 @@ own proxy module, for example). To use this panos Proxy Module, set this to
|
|||
|
||||
host
|
||||
^^^^
|
||||
|
||||
The location, or ip/dns, of the panos host. Required.
|
||||
|
||||
username
|
||||
^^^^^^^^
|
||||
|
||||
The username used to login to the panos host. Required.
|
||||
|
||||
password
|
||||
^^^^^^^^
|
||||
|
||||
The password used to login to the panos host. Required.
|
||||
|
||||
Direct Device (API Key)
|
||||
|
@ -88,6 +95,7 @@ instead of username and password.
|
|||
|
||||
proxytype
|
||||
^^^^^^^^^
|
||||
|
||||
The ``proxytype`` key and value pair is critical, as it tells Salt which
|
||||
interface to load from the ``proxy`` directory in Salt's install hierarchy,
|
||||
or from ``/srv/salt/_proxy`` on the Salt Master (if you have created your
|
||||
|
@ -96,14 +104,16 @@ own proxy module, for example). To use this panos Proxy Module, set this to
|
|||
|
||||
host
|
||||
^^^^
|
||||
|
||||
The location, or ip/dns, of the panos host. Required.
|
||||
|
||||
apikey
|
||||
^^^^^^^^
|
||||
^^^^^^
|
||||
|
||||
The generated XML API key for the panos host. Required.
|
||||
|
||||
Panorama Pass-Through (Password)
|
||||
------------------------
|
||||
--------------------------------
|
||||
|
||||
The Panorama pass-through method sends all connections through the Panorama
|
||||
management system. It passes the connections to the appropriate device using
|
||||
|
@ -126,6 +136,7 @@ not the panos device.
|
|||
|
||||
proxytype
|
||||
^^^^^^^^^
|
||||
|
||||
The ``proxytype`` key and value pair is critical, as it tells Salt which
|
||||
interface to load from the ``proxy`` directory in Salt's install hierarchy,
|
||||
or from ``/srv/salt/_proxy`` on the Salt Master (if you have created your
|
||||
|
@ -134,22 +145,26 @@ own proxy module, for example). To use this panos Proxy Module, set this to
|
|||
|
||||
serial
|
||||
^^^^^^
|
||||
|
||||
The serial number of the panos host. Required.
|
||||
|
||||
host
|
||||
^^^^
|
||||
|
||||
The location, or ip/dns, of the Panorama server. Required.
|
||||
|
||||
username
|
||||
^^^^^^^^
|
||||
|
||||
The username used to login to the Panorama server. Required.
|
||||
|
||||
password
|
||||
^^^^^^^^
|
||||
|
||||
The password used to login to the Panorama server. Required.
|
||||
|
||||
Panorama Pass-Through (API Key)
|
||||
------------------------
|
||||
-------------------------------
|
||||
|
||||
The Panorama server can also utilize a generated 'API key'_ for authentication.
|
||||
|
||||
|
@ -165,6 +180,7 @@ The Panorama server can also utilize a generated 'API key'_ for authentication.
|
|||
|
||||
proxytype
|
||||
^^^^^^^^^
|
||||
|
||||
The ``proxytype`` key and value pair is critical, as it tells Salt which
|
||||
interface to load from the ``proxy`` directory in Salt's install hierarchy,
|
||||
or from ``/srv/salt/_proxy`` on the Salt Master (if you have created your
|
||||
|
@ -173,16 +189,18 @@ own proxy module, for example). To use this panos Proxy Module, set this to
|
|||
|
||||
serial
|
||||
^^^^^^
|
||||
|
||||
The serial number of the panos host. Required.
|
||||
|
||||
host
|
||||
^^^^
|
||||
|
||||
The location, or ip/dns, of the Panorama server. Required.
|
||||
|
||||
apikey
|
||||
^^^^^^^^
|
||||
The generated XML API key for the Panorama server. Required.
|
||||
|
||||
The generated XML API key for the Panorama server. Required.
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
|
|
@ -40,7 +40,7 @@ def generate_token(minion_id, signature, impersonated_by_master=False):
|
|||
True. This happens when the master generates minion pillars.
|
||||
'''
|
||||
log.debug(
|
||||
'Token generation request for %s (impersonated by master: %s)'.
|
||||
'Token generation request for %s (impersonated by master: %s)',
|
||||
minion_id, impersonated_by_master
|
||||
)
|
||||
_validate_signature(minion_id, signature, impersonated_by_master)
|
||||
|
|
|
@ -2592,6 +2592,7 @@ class State(object):
|
|||
'__run_num__': self.__run_num,
|
||||
'__sls__': low['__sls__']
|
||||
}
|
||||
self.pre[tag] = running[tag]
|
||||
self.__run_num += 1
|
||||
elif status == 'change' and not low.get('__prereq__'):
|
||||
ret = self.call(low, chunks, running)
|
||||
|
@ -2988,6 +2989,7 @@ class BaseHighState(object):
|
|||
'top_file_merging_strategy set to \'same\', but no '
|
||||
'default_top configuration option was set'
|
||||
)
|
||||
self.opts['environment'] = self.opts['default_top']
|
||||
|
||||
if self.opts['saltenv']:
|
||||
contents = self.client.cache_file(
|
||||
|
|
|
@ -22,6 +22,15 @@ def __virtual__():
|
|||
return True
|
||||
|
||||
|
||||
def _norm_key(key):
|
||||
'''
|
||||
Normalize windows environment keys
|
||||
'''
|
||||
if salt.utils.platform.is_windows():
|
||||
return key.upper()
|
||||
return key
|
||||
|
||||
|
||||
def setenv(name,
|
||||
value,
|
||||
false_unsets=False,
|
||||
|
@ -126,12 +135,11 @@ def setenv(name,
|
|||
permanent_hive = 'HKLM'
|
||||
permanent_key = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
|
||||
|
||||
out = __salt__['reg.read_value'](permanent_hive, permanent_key, key)
|
||||
out = __salt__['reg.read_value'](permanent_hive, permanent_key, _norm_key(key))
|
||||
return out['success'] is True
|
||||
else:
|
||||
return False
|
||||
|
||||
if current_environ.get(key, None) is None and not key_exists():
|
||||
if current_environ.get(_norm_key(key), None) is None and not key_exists():
|
||||
# The key does not exist in environment
|
||||
if false_unsets is not True:
|
||||
# This key will be added with value ''
|
||||
|
@ -140,13 +148,13 @@ def setenv(name,
|
|||
# The key exists.
|
||||
if false_unsets is not True:
|
||||
# Check to see if the value will change
|
||||
if current_environ.get(key, None) != '':
|
||||
if current_environ.get(_norm_key(key), None) != '':
|
||||
# This key value will change to ''
|
||||
ret['changes'].update({key: ''})
|
||||
else:
|
||||
# We're going to delete the key
|
||||
ret['changes'].update({key: None})
|
||||
elif current_environ.get(key, '') == val:
|
||||
elif current_environ.get(_norm_key(key), '') == val:
|
||||
already_set.append(key)
|
||||
else:
|
||||
ret['changes'].update({key: val})
|
||||
|
|
|
@ -618,28 +618,34 @@ def _check_file(name):
|
|||
return ret, msg
|
||||
|
||||
|
||||
def _clean_dir(root, keep, exclude_pat):
|
||||
def _find_keep_files(root, keep):
|
||||
'''
|
||||
Clean out all of the files and directories in a directory (root) while
|
||||
preserving the files in a list (keep) and part of exclude_pat
|
||||
Compile a list of valid keep files (and directories).
|
||||
'''
|
||||
removed = set()
|
||||
real_keep = set()
|
||||
real_keep.add(root)
|
||||
if isinstance(keep, list):
|
||||
for fn_ in keep:
|
||||
if not os.path.isabs(fn_):
|
||||
continue
|
||||
fn_ = os.path.normcase(os.path.abspath(fn_))
|
||||
real_keep.add(fn_)
|
||||
while True:
|
||||
fn_ = os.path.dirname(fn_)
|
||||
fn_ = os.path.abspath(os.path.dirname(fn_))
|
||||
real_keep.add(fn_)
|
||||
if fn_ in [
|
||||
os.sep,
|
||||
''.join([os.path.splitdrive(fn_)[0], os.sep]),
|
||||
''.join([os.path.splitdrive(fn_)[0], os.sep, os.sep])
|
||||
]:
|
||||
drive, path = os.path.splitdrive(fn_)
|
||||
if not path.lstrip(os.sep):
|
||||
break
|
||||
return real_keep
|
||||
|
||||
|
||||
def _clean_dir(root, keep, exclude_pat):
|
||||
'''
|
||||
Clean out all of the files and directories in a directory (root) while
|
||||
preserving the files in a list (keep) and part of exclude_pat
|
||||
'''
|
||||
real_keep = _find_keep_files(root, keep)
|
||||
removed = set()
|
||||
|
||||
def _delete_not_kept(nfn):
|
||||
if nfn not in real_keep:
|
||||
|
|
|
@ -532,21 +532,9 @@ def latest(name,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2032,21 +2020,9 @@ def present(name,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -2250,21 +2226,9 @@ def detached(name,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
'''
|
||||
|
@ -2750,21 +2714,9 @@ def config_unset(name,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
@ -3023,21 +2975,9 @@ def config_set(name,
|
|||
cases.
|
||||
|
||||
.. note::
|
||||
|
||||
On Windows, this option works slightly differently in the git state
|
||||
and execution module than it does in the :mod:`"cmd" execution
|
||||
module <salt.modules.cmdmod>`. The filenames in most git
|
||||
repositories are created using a UTF-8 locale, and the system
|
||||
encoding on Windows (CP1252) will successfully (but incorrectly)
|
||||
decode many UTF-8 characters. This makes interacting with
|
||||
repositories containing UTF-8 filenames on Windows unreliable.
|
||||
Therefore, Windows will default to decoding the output from git
|
||||
commands using UTF-8 unless this option is explicitly used to
|
||||
specify the encoding.
|
||||
|
||||
On non-Windows platforms, the default output decoding behavior will
|
||||
be observed (i.e. the encoding specified by the locale will be
|
||||
tried first, and if that fails, UTF-8 will be used as a fallback).
|
||||
This should only be needed if the files in the repository were
|
||||
created with filenames using an encoding other than UTF-8 to handle
|
||||
Unicode characters.
|
||||
|
||||
.. versionadded:: 2018.3.1
|
||||
|
||||
|
|
|
@ -267,8 +267,13 @@ def managed(name,
|
|||
ret['comment'] = ' '.join(errors)
|
||||
return ret
|
||||
|
||||
try:
|
||||
currently_enabled = __salt__['ip.is_enabled'](name)
|
||||
except CommandExecutionError:
|
||||
currently_enabled = False
|
||||
|
||||
if not enabled:
|
||||
if __salt__['ip.is_enabled'](name):
|
||||
if currently_enabled:
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = ('Interface \'{0}\' will be disabled'
|
||||
|
@ -282,18 +287,13 @@ def managed(name,
|
|||
ret['comment'] += ' (already disabled)'
|
||||
return ret
|
||||
else:
|
||||
try:
|
||||
currently_enabled = __salt__['ip.is_disabled'](name)
|
||||
except CommandExecutionError:
|
||||
currently_enabled = False
|
||||
if not currently_enabled:
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = ('Interface \'{0}\' will be enabled'
|
||||
.format(name))
|
||||
else:
|
||||
result = __salt__['ip.enable'](name)
|
||||
if not result:
|
||||
if not __salt__['ip.enable'](name):
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('Failed to enable interface \'{0}\' to '
|
||||
'make changes'.format(name))
|
||||
|
|
|
@ -80,7 +80,7 @@ def top(**kwargs):
|
|||
subprocess.Popen(
|
||||
cmd,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE.communicate()[0])
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
)
|
||||
if not ndata:
|
||||
log.info('master_tops ext_nodes call did not return any data')
|
||||
|
|
|
@ -172,9 +172,9 @@ def fire_args(opts, jid, tag_data, prefix=''):
|
|||
except NameError:
|
||||
pass
|
||||
else:
|
||||
tag = tagify(tag_suffix, prefix)
|
||||
try:
|
||||
_event = get_master_event(opts, opts['sock_dir'], listen=False)
|
||||
tag = tagify(tag_suffix, prefix)
|
||||
_event.fire_event(tag_data, tag=tag)
|
||||
except Exception as exc:
|
||||
# Don't let a problem here hold up the rest of the orchestration
|
||||
|
@ -201,6 +201,12 @@ def tagify(suffix='', prefix='', base=SALT):
|
|||
parts.extend(suffix)
|
||||
else: # string so append
|
||||
parts.append(suffix)
|
||||
|
||||
for index, _ in enumerate(parts):
|
||||
try:
|
||||
parts[index] = salt.utils.stringutils.to_str(parts[index])
|
||||
except TypeError:
|
||||
parts[index] = str(parts[index])
|
||||
return TAGPARTER.join([part for part in parts if part])
|
||||
|
||||
|
||||
|
|
|
@ -566,13 +566,13 @@ class ConnectedCache(MultiprocessingProcess):
|
|||
|
||||
# the socket for incoming cache-updates from workers
|
||||
cupd_in = context.socket(zmq.SUB)
|
||||
cupd_in.setsockopt(zmq.SUBSCRIBE, '')
|
||||
cupd_in.setsockopt(zmq.SUBSCRIBE, b'')
|
||||
cupd_in.setsockopt(zmq.LINGER, 100)
|
||||
cupd_in.bind('ipc://' + self.update_sock)
|
||||
|
||||
# the socket for the timer-event
|
||||
timer_in = context.socket(zmq.SUB)
|
||||
timer_in.setsockopt(zmq.SUBSCRIBE, '')
|
||||
timer_in.setsockopt(zmq.SUBSCRIBE, b'')
|
||||
timer_in.setsockopt(zmq.LINGER, 100)
|
||||
timer_in.connect('ipc://' + self.upd_t_sock)
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import salt.utils.platform
|
|||
import salt.utils.process
|
||||
import salt.utils.stringutils
|
||||
import salt.utils.user
|
||||
import salt.utils.win_functions
|
||||
import salt.utils.xdg
|
||||
import salt.utils.yaml
|
||||
from salt.defaults import DEFAULT_TARGET_DELIM
|
||||
|
@ -1011,11 +1012,11 @@ class DaemonMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
if self.check_pidfile():
|
||||
pid = self.get_pidfile()
|
||||
if not salt.utils.platform.is_windows():
|
||||
if self.check_pidfile() and self.is_daemonized(pid) and not os.getppid() == pid:
|
||||
if self.check_pidfile() and self.is_daemonized(pid) and os.getppid() != pid:
|
||||
return True
|
||||
else:
|
||||
# We have no os.getppid() on Windows. Best effort.
|
||||
if self.check_pidfile() and self.is_daemonized(pid):
|
||||
# We have no os.getppid() on Windows. Use salt.utils.win_functions.get_parent_pid
|
||||
if self.check_pidfile() and self.is_daemonized(pid) and salt.utils.win_functions.get_parent_pid() != pid:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ def get_pidfile(pidfile):
|
|||
pid = pdf.read().strip()
|
||||
return int(pid)
|
||||
except (OSError, IOError, TypeError, ValueError):
|
||||
return None
|
||||
return -1
|
||||
|
||||
|
||||
def clean_proc(proc, wait_for_kill=10):
|
||||
|
|
|
@ -41,10 +41,11 @@ def to_bytes(s, encoding=None, errors='strict'):
|
|||
return s.encode(encoding, errors)
|
||||
else:
|
||||
try:
|
||||
return s.encode(__salt_system_encoding__, errors)
|
||||
except UnicodeEncodeError:
|
||||
# Fall back to UTF-8
|
||||
# Try UTF-8 first
|
||||
return s.encode('utf-8', errors)
|
||||
except UnicodeEncodeError:
|
||||
# Fall back to detected encoding
|
||||
return s.encode(__salt_system_encoding__, errors)
|
||||
raise TypeError('expected bytes, bytearray, or str')
|
||||
else:
|
||||
return to_str(s, encoding, errors)
|
||||
|
@ -64,10 +65,11 @@ def to_str(s, encoding=None, errors='strict'):
|
|||
return s.decode(encoding, errors)
|
||||
else:
|
||||
try:
|
||||
return s.decode(__salt_system_encoding__, errors)
|
||||
except UnicodeDecodeError:
|
||||
# Fall back to UTF-8
|
||||
# Try UTF-8 first
|
||||
return s.decode('utf-8', errors)
|
||||
except UnicodeDecodeError:
|
||||
# Fall back to detected encoding
|
||||
return s.decode(__salt_system_encoding__, errors)
|
||||
raise TypeError('expected str, bytes, or bytearray not {}'.format(type(s)))
|
||||
else:
|
||||
if isinstance(s, bytearray):
|
||||
|
@ -77,10 +79,11 @@ def to_str(s, encoding=None, errors='strict'):
|
|||
return s.encode(encoding, errors)
|
||||
else:
|
||||
try:
|
||||
return s.encode(__salt_system_encoding__, errors)
|
||||
except UnicodeEncodeError:
|
||||
# Fall back to UTF-8
|
||||
# Try UTF-8 first
|
||||
return s.encode('utf-8', errors)
|
||||
except UnicodeEncodeError:
|
||||
# Fall back to detected encoding
|
||||
return s.encode(__salt_system_encoding__, errors)
|
||||
raise TypeError('expected str, bytearray, or unicode')
|
||||
|
||||
|
||||
|
@ -108,10 +111,11 @@ def to_unicode(s, encoding=None, errors='strict', normalize=False):
|
|||
return _normalize(s.decode(encoding, errors))
|
||||
else:
|
||||
try:
|
||||
return _normalize(s.decode(__salt_system_encoding__, errors))
|
||||
except UnicodeDecodeError:
|
||||
# Fall back to UTF-8
|
||||
# Try UTF-8 first
|
||||
return _normalize(s.decode('utf-8', errors))
|
||||
except UnicodeDecodeError:
|
||||
# Fall back to detected encoding
|
||||
return _normalize(s.decode(__salt_system_encoding__, errors))
|
||||
raise TypeError('expected str or bytearray')
|
||||
|
||||
|
||||
|
@ -294,20 +298,29 @@ def build_whitespace_split_regex(text):
|
|||
|
||||
def expr_match(line, expr):
|
||||
'''
|
||||
Evaluate a line of text against an expression. First try a full-string
|
||||
match, next try globbing, and then try to match assuming expr is a regular
|
||||
expression. Originally designed to match minion IDs for
|
||||
whitelists/blacklists.
|
||||
Checks whether or not the passed value matches the specified expression.
|
||||
Tries to match expr first as a glob using fnmatch.fnmatch(), and then tries
|
||||
to match expr as a regular expression. Originally designed to match minion
|
||||
IDs for whitelists/blacklists.
|
||||
|
||||
Note that this also does exact matches, as fnmatch.fnmatch() will return
|
||||
``True`` when no glob characters are used and the string is an exact match:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> fnmatch.fnmatch('foo', 'foo')
|
||||
True
|
||||
'''
|
||||
if line == expr:
|
||||
return True
|
||||
if fnmatch.fnmatch(line, expr):
|
||||
return True
|
||||
try:
|
||||
if re.match(r'\A{0}\Z'.format(expr), line):
|
||||
if fnmatch.fnmatch(line, expr):
|
||||
return True
|
||||
except re.error:
|
||||
pass
|
||||
try:
|
||||
if re.match(r'\A{0}\Z'.format(expr), line):
|
||||
return True
|
||||
except re.error:
|
||||
pass
|
||||
except TypeError:
|
||||
log.exception('Value %r or expression %r is not a string', line, expr)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -337,22 +350,16 @@ def check_whitelist_blacklist(value, whitelist=None, blacklist=None):
|
|||
if blacklist is not None:
|
||||
if not hasattr(blacklist, '__iter__'):
|
||||
blacklist = [blacklist]
|
||||
try:
|
||||
for expr in blacklist:
|
||||
if expr_match(value, expr):
|
||||
return False
|
||||
except TypeError:
|
||||
log.error('Non-iterable blacklist %s', blacklist)
|
||||
for expr in blacklist:
|
||||
if expr_match(value, expr):
|
||||
return False
|
||||
|
||||
if whitelist:
|
||||
if not hasattr(whitelist, '__iter__'):
|
||||
whitelist = [whitelist]
|
||||
try:
|
||||
for expr in whitelist:
|
||||
if expr_match(value, expr):
|
||||
return True
|
||||
except TypeError:
|
||||
log.error('Non-iterable whitelist %s', whitelist)
|
||||
for expr in whitelist:
|
||||
if expr_match(value, expr):
|
||||
return True
|
||||
else:
|
||||
return True
|
||||
|
||||
|
|
|
@ -6,14 +6,18 @@
|
|||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import yaml
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
import salt.utils.files
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.unit import expectedFailure
|
||||
from tests.support import win_installer
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('CLOUD-TEST-')
|
||||
|
@ -26,6 +30,38 @@ class EC2Test(ShellCase):
|
|||
'''
|
||||
Integration tests for the EC2 cloud provider in Salt-Cloud
|
||||
'''
|
||||
TIMEOUT = 1000
|
||||
|
||||
def _installer_name(self):
|
||||
'''
|
||||
Determine the downloaded installer name by searching the files
|
||||
directory for the firt file that loosk like an installer.
|
||||
'''
|
||||
for path, dirs, files in os.walk(FILES):
|
||||
for file in files:
|
||||
if file.startswith(win_installer.PREFIX):
|
||||
return file
|
||||
break
|
||||
return
|
||||
|
||||
def _fetch_latest_installer(self):
|
||||
'''
|
||||
Download the latest Windows installer executable
|
||||
'''
|
||||
name = win_installer.latest_installer_name()
|
||||
path = os.path.join(FILES, name)
|
||||
with salt.utils.files.fopen(path, 'wb') as fp:
|
||||
win_installer.download_and_verify(fp, name)
|
||||
return name
|
||||
|
||||
def _ensure_installer(self):
|
||||
'''
|
||||
Make sure the testing environment has a Windows installer executbale.
|
||||
'''
|
||||
name = self._installer_name()
|
||||
if name:
|
||||
return name
|
||||
return self._fetch_latest_installer()
|
||||
|
||||
@expensiveTest
|
||||
def setUp(self):
|
||||
|
@ -77,27 +113,51 @@ class EC2Test(ShellCase):
|
|||
'missing. Check tests/integration/files/conf/cloud.providers.d/{0}.conf'
|
||||
.format(PROVIDER_NAME)
|
||||
)
|
||||
self.INSTALLER = self._ensure_installer()
|
||||
|
||||
def test_instance(self):
|
||||
def override_profile_config(self, name, data):
|
||||
conf_path = os.path.join(self.get_config_dir(), 'cloud.profiles.d', 'ec2.conf')
|
||||
with salt.utils.files.fopen(conf_path, 'r') as fp:
|
||||
conf = yaml.safe_load(fp)
|
||||
conf[name].update(data)
|
||||
with salt.utils.files.fopen(conf_path, 'w') as fp:
|
||||
yaml.dump(conf, fp)
|
||||
|
||||
def copy_file(self, name):
|
||||
'''
|
||||
Copy a file from tests/integration/files to a test's temporary
|
||||
configuration directory. The path to the file which is created will be
|
||||
returned.
|
||||
'''
|
||||
src = os.path.join(FILES, name)
|
||||
dst = os.path.join(self.get_config_dir(), name)
|
||||
with salt.utils.files.fopen(src, 'rb') as sfp:
|
||||
with salt.utils.files.fopen(dst, 'wb') as dfp:
|
||||
dfp.write(sfp.read())
|
||||
return dst
|
||||
|
||||
def _test_instance(self, profile='ec2-test', debug=False, timeout=TIMEOUT):
|
||||
'''
|
||||
Tests creating and deleting an instance on EC2 (classic)
|
||||
'''
|
||||
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p ec2-test {0}'.format(INSTANCE_NAME),
|
||||
timeout=EC2_TIMEOUT)
|
||||
cmd = '-p {0}'.format(profile)
|
||||
if debug:
|
||||
cmd += ' -l debug'
|
||||
cmd += ' {0}'.format(INSTANCE_NAME)
|
||||
instance = self.run_cloud(cmd, timeout=timeout)
|
||||
ret_str = '{0}:'.format(INSTANCE_NAME)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
try:
|
||||
self.assertIn(ret_str, instance)
|
||||
except AssertionError:
|
||||
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME),
|
||||
timeout=EC2_TIMEOUT)
|
||||
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=timeout)
|
||||
raise
|
||||
|
||||
# delete the instance
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME),
|
||||
timeout=EC2_TIMEOUT)
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=timeout)
|
||||
ret_str = ' shutting-down'
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
|
@ -145,6 +205,80 @@ class EC2Test(ShellCase):
|
|||
# check if deletion was performed appropriately
|
||||
self.assertIn(ret_str, delete)
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Tests creating and deleting an instance on EC2 (classic)
|
||||
'''
|
||||
self._test_instance('ec2-test')
|
||||
|
||||
@expectedFailure
|
||||
def test_win2012r2_winexe(self):
|
||||
'''
|
||||
Tests creating and deleting a Windows 2012r2instance on EC2 using
|
||||
winexe (classic)
|
||||
'''
|
||||
# TODO: winexe calls hang and the test fails by timing out. The same
|
||||
# same calls succeed when run outside of the test environment.
|
||||
self.override_profile_config(
|
||||
'ec2-win2012-test',
|
||||
{
|
||||
'use_winrm': False,
|
||||
'user_data': self.copy_file('windows-firewall-winexe.ps1'),
|
||||
'win_installer': self.copy_file(self.INSTALLER),
|
||||
},
|
||||
)
|
||||
self._test_instance('ec2-win2012r2-test', debug=True, timeout=500)
|
||||
|
||||
def test_win2012r2_winrm(self):
|
||||
'''
|
||||
Tests creating and deleting a Windows 2012r2 instance on EC2 using
|
||||
winrm (classic)
|
||||
'''
|
||||
self.override_profile_config(
|
||||
'ec2-win2016-test',
|
||||
{
|
||||
'user_data': self.copy_file('windows-firewall.ps1'),
|
||||
'win_installer': self.copy_file(self.INSTALLER),
|
||||
'winrm_ssl_verify': False,
|
||||
}
|
||||
|
||||
)
|
||||
self._test_instance('ec2-win2012r2-test', debug=True, timeout=500)
|
||||
|
||||
@expectedFailure
|
||||
def test_win2016_winexe(self):
|
||||
'''
|
||||
Tests creating and deleting a Windows 2016 instance on EC2 using winrm
|
||||
(classic)
|
||||
'''
|
||||
# TODO: winexe calls hang and the test fails by timing out. The same
|
||||
# same calls succeed when run outside of the test environment.
|
||||
self.override_profile_config(
|
||||
'ec2-win2016-test',
|
||||
{
|
||||
'use_winrm': False,
|
||||
'user_data': self.copy_file('windows-firewall-winexe.ps1'),
|
||||
'win_installer': self.copy_file(self.INSTALLER),
|
||||
},
|
||||
)
|
||||
self._test_instance('ec2-win2016-test', debug=True, timeout=500)
|
||||
|
||||
def test_win2016_winrm(self):
|
||||
'''
|
||||
Tests creating and deleting a Windows 2016 instance on EC2 using winrm
|
||||
(classic)
|
||||
'''
|
||||
self.override_profile_config(
|
||||
'ec2-win2016-test',
|
||||
{
|
||||
'user_data': self.copy_file('windows-firewall.ps1'),
|
||||
'win_installer': self.copy_file(self.INSTALLER),
|
||||
'winrm_ssl_verify': False,
|
||||
}
|
||||
|
||||
)
|
||||
self._test_instance('ec2-win2016-test', debug=True, timeout=500)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
|
@ -154,5 +288,4 @@ class EC2Test(ShellCase):
|
|||
|
||||
# if test instance is still present, delete it
|
||||
if ret_str in query:
|
||||
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME),
|
||||
timeout=EC2_TIMEOUT)
|
||||
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=self.TIMEOUT)
|
||||
|
|
1
tests/integration/doc/__init__.py
Normal file
1
tests/integration/doc/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
# -*- coding: utf-8 -*-
|
104
tests/integration/doc/test_man.py
Normal file
104
tests/integration/doc/test_man.py
Normal file
|
@ -0,0 +1,104 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Tests for existence of manpages
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.platform
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.paths import TMP
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'minion is windows')
|
||||
class ManTest(ModuleCase):
|
||||
rootdir = os.path.join(TMP, 'mantest')
|
||||
# Map filenames to search strings which should be in the manpage
|
||||
manpages = {
|
||||
'salt-cp.1': [
|
||||
'salt-cp Documentation',
|
||||
'copies files from the master',
|
||||
],
|
||||
'salt-cloud.1': [
|
||||
'Salt Cloud Command',
|
||||
'Provision virtual machines in the cloud',
|
||||
],
|
||||
'salt-call.1': [
|
||||
'salt-call Documentation',
|
||||
'run module functions locally',
|
||||
],
|
||||
'salt-api.1': [
|
||||
'salt-api Command',
|
||||
'Start interfaces used to remotely connect',
|
||||
],
|
||||
'salt-unity.1': [
|
||||
'salt-unity Command',
|
||||
'unified invocation wrapper',
|
||||
],
|
||||
'salt-syndic.1': [
|
||||
'salt-syndic Documentation',
|
||||
'Salt syndic daemon',
|
||||
],
|
||||
'salt-ssh.1': [
|
||||
'salt-ssh Documentation',
|
||||
'executed using only SSH',
|
||||
],
|
||||
'salt-run.1': [
|
||||
'salt-run Documentation',
|
||||
'frontend command for executing',
|
||||
],
|
||||
'salt-proxy.1': [
|
||||
'salt-proxy Documentation',
|
||||
'proxies these commands',
|
||||
],
|
||||
'salt-minion.1': [
|
||||
'salt-minion Documentation',
|
||||
'Salt minion daemon',
|
||||
],
|
||||
'salt-master.1': [
|
||||
'salt-master Documentation',
|
||||
'Salt master daemon',
|
||||
],
|
||||
'salt-key.1': [
|
||||
'salt-key Documentation',
|
||||
'management of Salt server public keys',
|
||||
],
|
||||
'salt.1': [
|
||||
'allows for commands to be executed',
|
||||
],
|
||||
'salt.7': [
|
||||
'Salt Documentation',
|
||||
],
|
||||
'spm.1': [
|
||||
'Salt Package Manager Command',
|
||||
'command for managing Salt packages',
|
||||
],
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
if not self.run_function('mantest.install', [self.rootdir]):
|
||||
self.fail('Failed to install salt to {0}'.format(self.rootdir))
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
shutil.rmtree(cls.rootdir)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def test_man(self):
|
||||
'''
|
||||
Make sure that man pages are installed
|
||||
'''
|
||||
ret = self.run_function('mantest.search', [self.manpages, self.rootdir])
|
||||
# The above function returns True if successful and an exception (which
|
||||
# will manifest in the return as a stringified exception) if
|
||||
# unsuccessful. Therefore, a simple assertTrue is not sufficient.
|
||||
if ret is not True:
|
||||
self.fail(ret)
|
|
@ -4,3 +4,31 @@ ec2-test:
|
|||
size: t1.micro
|
||||
sh_username: ec2-user
|
||||
script_args: '-P -Z'
|
||||
ec2-win2012r2-test:
|
||||
provider: ec2-config
|
||||
size: t2.micro
|
||||
image: ami-eb1ecd96
|
||||
smb_port: 445
|
||||
win_installer: ''
|
||||
win_username: Administrator
|
||||
win_password: auto
|
||||
userdata_file: ''
|
||||
userdata_template: False
|
||||
use_winrm: True
|
||||
winrm_verify_ssl: False
|
||||
ssh_interface: private_ips
|
||||
deploy: True
|
||||
ec2-win2016-test:
|
||||
provider: ec2-config
|
||||
size: t2.micro
|
||||
image: ami-ed14c790
|
||||
smb_port: 445
|
||||
win_installer: ''
|
||||
win_username: Administrator
|
||||
win_password: auto
|
||||
userdata_file: ''
|
||||
userdata_template: False
|
||||
use_winrm: True
|
||||
winrm_verify_ssl: False
|
||||
ssh_interface: private_ips
|
||||
deploy: True
|
||||
|
|
76
tests/integration/files/file/base/_modules/mantest.py
Normal file
76
tests/integration/files/file/base/_modules/mantest.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Helpers for testing man pages
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
# Import Salt Tesing libs
|
||||
from tests.support.paths import CODE_DIR
|
||||
|
||||
|
||||
def install(rootdir):
|
||||
if not os.path.exists(rootdir):
|
||||
os.makedirs(rootdir)
|
||||
return __salt__['cmd.retcode'](
|
||||
[sys.executable,
|
||||
os.path.join(CODE_DIR, 'setup.py'),
|
||||
'install', '--root={0}'.format(rootdir)]) == 0
|
||||
return True
|
||||
|
||||
|
||||
def search(manpages, rootdir):
|
||||
manpage_fns = set(manpages)
|
||||
manpage_paths = {}
|
||||
for root, _, files in os.walk(rootdir):
|
||||
if not manpage_fns:
|
||||
# All manpages found, no need to keep walking
|
||||
break
|
||||
# Using list because we will be modifying the set during iteration
|
||||
for manpage_fn in list(manpage_fns):
|
||||
if manpage_fn in files:
|
||||
manpage_path = salt.utils.path.join(root, manpage_fn)
|
||||
manpage_paths[manpage_fn] = manpage_path
|
||||
manpage_fns.remove(manpage_fn)
|
||||
|
||||
if manpage_fns:
|
||||
raise CommandExecutionError(
|
||||
'The following manpages were not found under {0}: {1}'.format(
|
||||
rootdir,
|
||||
', '.join(sorted(manpage_fns))
|
||||
)
|
||||
)
|
||||
|
||||
failed = {}
|
||||
for manpage in sorted(manpages):
|
||||
with salt.utils.files.fopen(manpage_paths[manpage]) as fp_:
|
||||
contents = salt.utils.stringutils.to_unicode(fp_.read())
|
||||
# Check for search string in contents
|
||||
for search_string in manpages[manpage]:
|
||||
if search_string not in contents:
|
||||
failed.setdefault(manpage, []).append(
|
||||
'No match for search string \'{0}\' found in {1}'.format(
|
||||
search_string, manpage_paths[manpage]
|
||||
)
|
||||
)
|
||||
# Check for correct install dir
|
||||
path = '/man{0}/'.format(manpage.rsplit('.', 1)[-1])
|
||||
if path not in manpage_paths[manpage]:
|
||||
failed.setdefault(manpage, []).append(
|
||||
'{0} not found in manpage path {1}'.format(
|
||||
path, manpage_paths[manpage]
|
||||
)
|
||||
)
|
||||
|
||||
if failed:
|
||||
raise CommandExecutionError('One or more manpages failed', info=failed)
|
||||
|
||||
return True
|
|
@ -66,6 +66,8 @@ def get_invalid_docs():
|
|||
'log.warning',
|
||||
'lowpkg.bin_pkg_info',
|
||||
'lxc.run_cmd',
|
||||
'mantest.install',
|
||||
'mantest.search',
|
||||
'nspawn.restart',
|
||||
'nspawn.stop',
|
||||
'pkg.expand_repo_def',
|
||||
|
|
5
tests/integration/files/windows-firewall-winexe.ps1
Normal file
5
tests/integration/files/windows-firewall-winexe.ps1
Normal file
|
@ -0,0 +1,5 @@
|
|||
<powershell>
|
||||
New-NetFirewallRule -Name "SMB445" -DisplayName "SMB445" -Protocol TCP -LocalPort 445
|
||||
Set-Item (dir wsman:\localhost\Listener\*\Port -Recurse).pspath 445 -Force
|
||||
Restart-Service winrm
|
||||
</powershell>
|
33
tests/integration/files/windows-firewall.ps1
Normal file
33
tests/integration/files/windows-firewall.ps1
Normal file
|
@ -0,0 +1,33 @@
|
|||
<powershell>
|
||||
New-NetFirewallRule -Name "SMB445" -DisplayName "SMB445" -Protocol TCP -LocalPort 445
|
||||
New-NetFirewallRule -Name "WINRM5986" -DisplayName "WINRM5986" -Protocol TCP -LocalPort 5986
|
||||
|
||||
winrm quickconfig -q
|
||||
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
|
||||
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
|
||||
winrm set winrm/config/service/auth '@{Basic="true"}'
|
||||
|
||||
$SourceStoreScope = 'LocalMachine'
|
||||
$SourceStorename = 'Remote Desktop'
|
||||
|
||||
$SourceStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $SourceStorename, $SourceStoreScope
|
||||
$SourceStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly)
|
||||
|
||||
$cert = $SourceStore.Certificates | Where-Object -FilterScript {
|
||||
$_.subject -like '*'
|
||||
}
|
||||
|
||||
$DestStoreScope = 'LocalMachine'
|
||||
$DestStoreName = 'My'
|
||||
|
||||
$DestStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $DestStoreName, $DestStoreScope
|
||||
$DestStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
||||
$DestStore.Add($cert)
|
||||
|
||||
$SourceStore.Close()
|
||||
$DestStore.Close()
|
||||
|
||||
winrm create winrm/config/listener?Address=*+Transport=HTTPS `@`{Hostname=`"($certId)`"`;CertificateThumbprint=`"($cert.Thumbprint)`"`}
|
||||
|
||||
Restart-Service winrm
|
||||
</powershell>
|
|
@ -15,9 +15,11 @@ from tests.support.helpers import (
|
|||
skip_if_not_root
|
||||
)
|
||||
from tests.support.paths import TMP
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
|
@ -266,6 +268,15 @@ class CMDModuleTest(ModuleCase):
|
|||
runas=runas).strip()
|
||||
self.assertEqual(result, expected_result)
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'minion is windows')
|
||||
@skip_if_not_root
|
||||
def test_runas(self):
|
||||
'''
|
||||
Ensure that the env is the runas user's
|
||||
'''
|
||||
out = self.run_function('cmd.run', ['env'], runas='nobody').splitlines()
|
||||
self.assertIn('USER=nobody', out)
|
||||
|
||||
def test_timeout(self):
|
||||
'''
|
||||
cmd.run trigger timeout
|
||||
|
|
|
@ -14,7 +14,10 @@ import textwrap
|
|||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import get_unused_localhost_port, skip_if_not_root
|
||||
from tests.support.helpers import (
|
||||
get_unused_localhost_port,
|
||||
skip_if_not_root,
|
||||
with_tempfile)
|
||||
from tests.support.unit import skipIf
|
||||
import tests.support.paths as paths
|
||||
|
||||
|
@ -41,11 +44,11 @@ class CPModuleTest(ModuleCase):
|
|||
super(CPModuleTest, self).run_function(*args, **kwargs)
|
||||
)
|
||||
|
||||
def test_get_file(self):
|
||||
@with_tempfile
|
||||
def test_get_file(self, tgt):
|
||||
'''
|
||||
cp.get_file
|
||||
'''
|
||||
tgt = os.path.join(paths.TMP, 'scene33')
|
||||
self.run_function(
|
||||
'cp.get_file',
|
||||
[
|
||||
|
@ -73,11 +76,11 @@ class CPModuleTest(ModuleCase):
|
|||
self.assertIn('KNIGHT: They\'re nervous, sire.', data)
|
||||
self.assertNotIn('bacon', data)
|
||||
|
||||
def test_get_file_templated_paths(self):
|
||||
@with_tempfile
|
||||
def test_get_file_templated_paths(self, tgt):
|
||||
'''
|
||||
cp.get_file
|
||||
'''
|
||||
tgt = os.path.join(paths.TMP, 'cheese')
|
||||
self.run_function(
|
||||
'cp.get_file',
|
||||
[
|
||||
|
@ -91,11 +94,11 @@ class CPModuleTest(ModuleCase):
|
|||
self.assertIn('Gromit', data)
|
||||
self.assertNotIn('bacon', data)
|
||||
|
||||
def test_get_file_gzipped(self):
|
||||
@with_tempfile
|
||||
def test_get_file_gzipped(self, tgt):
|
||||
'''
|
||||
cp.get_file
|
||||
'''
|
||||
tgt = os.path.join(paths.TMP, 'file.big')
|
||||
src = os.path.join(paths.FILES, 'file', 'base', 'file.big')
|
||||
with salt.utils.files.fopen(src, 'rb') as fp_:
|
||||
hash_str = hashlib.md5(fp_.read()).hexdigest()
|
||||
|
@ -134,11 +137,11 @@ class CPModuleTest(ModuleCase):
|
|||
self.assertIn('KNIGHT: They\'re nervous, sire.', data)
|
||||
self.assertNotIn('bacon', data)
|
||||
|
||||
def test_get_template(self):
|
||||
@with_tempfile
|
||||
def test_get_template(self, tgt):
|
||||
'''
|
||||
cp.get_template
|
||||
'''
|
||||
tgt = os.path.join(paths.TMP, 'scene33')
|
||||
self.run_function(
|
||||
'cp.get_template',
|
||||
['salt://grail/scene33', tgt],
|
||||
|
@ -183,11 +186,11 @@ class CPModuleTest(ModuleCase):
|
|||
|
||||
# cp.get_url tests
|
||||
|
||||
def test_get_url(self):
|
||||
@with_tempfile
|
||||
def test_get_url(self, tgt):
|
||||
'''
|
||||
cp.get_url with salt:// source given
|
||||
'''
|
||||
tgt = os.path.join(paths.TMP, 'scene33')
|
||||
self.run_function(
|
||||
'cp.get_url',
|
||||
[
|
||||
|
@ -274,11 +277,11 @@ class CPModuleTest(ModuleCase):
|
|||
self.assertIn('KNIGHT: They\'re nervous, sire.', data)
|
||||
self.assertNotIn('bacon', data)
|
||||
|
||||
def test_get_url_https(self):
|
||||
@with_tempfile
|
||||
def test_get_url_https(self, tgt):
|
||||
'''
|
||||
cp.get_url with https:// source given
|
||||
'''
|
||||
tgt = os.path.join(paths.TMP, 'test_get_url_https')
|
||||
self.run_function(
|
||||
'cp.get_url',
|
||||
[
|
||||
|
@ -616,7 +619,8 @@ class CPModuleTest(ModuleCase):
|
|||
self.assertEqual(
|
||||
sha256_hash['hsum'], hashlib.sha256(data).hexdigest())
|
||||
|
||||
def test_get_file_from_env_predefined(self):
|
||||
@with_tempfile
|
||||
def test_get_file_from_env_predefined(self, tgt):
|
||||
'''
|
||||
cp.get_file
|
||||
'''
|
||||
|
@ -630,7 +634,8 @@ class CPModuleTest(ModuleCase):
|
|||
finally:
|
||||
os.unlink(tgt)
|
||||
|
||||
def test_get_file_from_env_in_url(self):
|
||||
@with_tempfile
|
||||
def test_get_file_from_env_in_url(self, tgt):
|
||||
tgt = os.path.join(paths.TMP, 'cheese')
|
||||
try:
|
||||
self.run_function('cp.get_file', ['salt://cheese?saltenv=prod', tgt])
|
||||
|
|
|
@ -147,8 +147,7 @@ class GitModuleTest(ModuleCase):
|
|||
TODO: maybe move this behavior to ModuleCase itself?
|
||||
'''
|
||||
return salt.utils.data.decode(
|
||||
super(GitModuleTest, self).run_function(*args, **kwargs),
|
||||
encoding='utf-8'
|
||||
super(GitModuleTest, self).run_function(*args, **kwargs)
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -207,8 +206,7 @@ class GitModuleTest(ModuleCase):
|
|||
self.run_function('cmd.run', ['cp ' + tar_archive + ' /root/'])
|
||||
with closing(tarfile.open(tar_archive, 'r')) as tar_obj:
|
||||
self.assertEqual(
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames(),
|
||||
encoding='utf-8')),
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames())),
|
||||
sorted([
|
||||
'foo', 'foo/bar', 'foo/baz', 'foo/foo', 'foo/питон',
|
||||
'foo/qux', 'foo/qux/bar', 'foo/qux/baz', 'foo/qux/foo',
|
||||
|
@ -238,8 +236,7 @@ class GitModuleTest(ModuleCase):
|
|||
self.assertTrue(tarfile.is_tarfile(tar_archive))
|
||||
with closing(tarfile.open(tar_archive, 'r')) as tar_obj:
|
||||
self.assertEqual(
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames(),
|
||||
encoding='utf-8')),
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames())),
|
||||
sorted(['foo', 'foo/bar', 'foo/baz', 'foo/foo', 'foo/питон'])
|
||||
)
|
||||
finally:
|
||||
|
|
|
@ -9,11 +9,13 @@ import string
|
|||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import destructiveTest, skip_if_not_root
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import range
|
||||
import salt.utils.files
|
||||
import salt.utils.platform
|
||||
import salt.utils.stringutils
|
||||
|
||||
|
||||
|
@ -34,13 +36,13 @@ class GroupModuleTest(ModuleCase):
|
|||
self._no_user = self.__random_string()
|
||||
self._group = self.__random_string()
|
||||
self._no_group = self.__random_string()
|
||||
self._gid = 64989
|
||||
self._new_gid = 64998
|
||||
os_grain = self.run_function('grains.item', ['kernel'])
|
||||
if os_grain['kernel'] not in 'Linux':
|
||||
self.os_grain = self.run_function('grains.item', ['kernel'])
|
||||
self._gid = 64989 if 'Windows' not in self.os_grain['kernel'] else None
|
||||
self._new_gid = 64998 if 'Windows' not in self.os_grain['kernel'] else None
|
||||
if self.os_grain['kernel'] not in ('Linux', 'Windows'):
|
||||
self.skipTest(
|
||||
'Test not applicable to \'{kernel}\' kernel'.format(
|
||||
**os_grain
|
||||
**self.os_grain
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -110,12 +112,18 @@ class GroupModuleTest(ModuleCase):
|
|||
Test the add group function
|
||||
'''
|
||||
# add a new group
|
||||
self.assertTrue(self.run_function('group.add', [self._group, self._gid]))
|
||||
self.assertTrue(self.run_function('group.add', [self._group], gid=self._gid))
|
||||
group_info = self.run_function('group.info', [self._group])
|
||||
self.assertEqual(group_info['name'], self._group)
|
||||
self.assertEqual(group_info['gid'], self._gid)
|
||||
self.assertEqual(group_info['name'], self._group)
|
||||
# try adding the group again
|
||||
self.assertFalse(self.run_function('group.add', [self._group, self._gid]))
|
||||
if self.os_grain['kernel'] == 'Windows':
|
||||
add_group = self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.assertEqual(add_group['result'], None)
|
||||
self.assertEqual(add_group['comment'], 'The group {0} already exists.'.format(self._group))
|
||||
self.assertEqual(add_group['changes'], [])
|
||||
else:
|
||||
self.assertFalse(self.run_function('group.add', [self._group], gid=self._gid))
|
||||
|
||||
@destructiveTest
|
||||
def test_add_system_group(self):
|
||||
|
@ -164,26 +172,32 @@ class GroupModuleTest(ModuleCase):
|
|||
self.assertTrue(self.run_function('group.delete', [self._group]))
|
||||
|
||||
# group does not exist
|
||||
self.assertFalse(self.run_function('group.delete', [self._no_group]))
|
||||
if self.os_grain['kernel'] == 'Windows':
|
||||
del_group = self.run_function('group.delete', [self._no_group])
|
||||
self.assertEqual(del_group['changes'], [])
|
||||
self.assertEqual(del_group['comment'], 'The group {0} does not exists.'.format(self._no_group))
|
||||
else:
|
||||
self.assertFalse(self.run_function('group.delete', [self._no_group]))
|
||||
|
||||
def test_info(self):
|
||||
'''
|
||||
Test the info group function
|
||||
'''
|
||||
self.run_function('group.add', [self._group, self._gid])
|
||||
self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.run_function('user.add', [self._user])
|
||||
self.run_function('group.adduser', [self._group, self._user])
|
||||
group_info = self.run_function('group.info', [self._group])
|
||||
|
||||
self.assertEqual(group_info['name'], self._group)
|
||||
self.assertEqual(group_info['gid'], self._gid)
|
||||
self.assertIn(self._user, group_info['members'])
|
||||
self.assertIn(self._user, str(group_info['members']))
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'gid test skipped on windows')
|
||||
def test_chgid(self):
|
||||
'''
|
||||
Test the change gid function
|
||||
'''
|
||||
self.run_function('group.add', [self._group, self._gid])
|
||||
self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.assertTrue(self.run_function('group.chgid', [self._group, self._new_gid]))
|
||||
group_info = self.run_function('group.info', [self._group])
|
||||
self.assertEqual(group_info['gid'], self._new_gid)
|
||||
|
@ -192,47 +206,55 @@ class GroupModuleTest(ModuleCase):
|
|||
'''
|
||||
Test the add user to group function
|
||||
'''
|
||||
self.run_function('group.add', [self._group, self._gid])
|
||||
self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.run_function('user.add', [self._user])
|
||||
self.assertTrue(self.run_function('group.adduser', [self._group, self._user]))
|
||||
group_info = self.run_function('group.info', [self._group])
|
||||
self.assertIn(self._user, group_info['members'])
|
||||
# try to add a non existing user
|
||||
self.assertFalse(self.run_function('group.adduser', [self._group, self._no_user]))
|
||||
# try to add a user to non existing group
|
||||
self.assertFalse(self.run_function('group.adduser', [self._no_group, self._user]))
|
||||
# try to add a non existing user to a non existing group
|
||||
self.assertFalse(self.run_function('group.adduser', [self._no_group, self._no_user]))
|
||||
self.assertIn(self._user, str(group_info['members']))
|
||||
if self.os_grain['kernel'] == 'Windows':
|
||||
no_group = self.run_function('group.adduser', [self._no_group, self._no_user])
|
||||
no_user = self.run_function('group.adduser', [self._group, self._no_user])
|
||||
funcs = [no_group, no_user]
|
||||
for func in funcs:
|
||||
self.assertIn('Fail', func['comment'])
|
||||
self.assertFalse(func['result'])
|
||||
else:
|
||||
# try add a non existing user
|
||||
self.assertFalse(self.run_function('group.adduser', [self._group, self._no_user]))
|
||||
# try add a user to non existing group
|
||||
self.assertFalse(self.run_function('group.adduser', [self._no_group, self._user]))
|
||||
# try add a non existing user to a non existing group
|
||||
self.assertFalse(self.run_function('group.adduser', [self._no_group, self._no_user]))
|
||||
|
||||
def test_deluser(self):
|
||||
'''
|
||||
Test the delete user from group function
|
||||
'''
|
||||
self.run_function('group.add', [self._group, self._gid])
|
||||
self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.run_function('user.add', [self._user])
|
||||
self.run_function('group.adduser', [self._group, self._user])
|
||||
self.assertTrue(self.run_function('group.deluser', [self._group, self._user]))
|
||||
group_info = self.run_function('group.info', [self._group])
|
||||
self.assertNotIn(self._user, group_info['members'])
|
||||
self.assertNotIn(self._user, str(group_info['members']))
|
||||
|
||||
def test_members(self):
|
||||
'''
|
||||
Test the members function
|
||||
'''
|
||||
self.run_function('group.add', [self._group, self._gid])
|
||||
self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.run_function('user.add', [self._user])
|
||||
self.run_function('user.add', [self._user1])
|
||||
m = '{0},{1}'.format(self._user, self._user1)
|
||||
self.assertTrue(self.run_function('group.members', [self._group, m]))
|
||||
group_info = self.run_function('group.info', [self._group])
|
||||
self.assertIn(self._user, group_info['members'])
|
||||
self.assertIn(self._user1, group_info['members'])
|
||||
self.assertIn(self._user, str(group_info['members']))
|
||||
self.assertIn(self._user1, str(group_info['members']))
|
||||
|
||||
def test_getent(self):
|
||||
'''
|
||||
Test the getent function
|
||||
'''
|
||||
self.run_function('group.add', [self._group, self._gid])
|
||||
self.run_function('group.add', [self._group], gid=self._gid)
|
||||
self.run_function('user.add', [self._user])
|
||||
self.run_function('group.adduser', [self._group, self._user])
|
||||
ginfo = self.run_function('user.getent')
|
||||
|
|
|
@ -84,7 +84,8 @@ class SaltUtilSyncModuleTest(ModuleCase):
|
|||
'beacons': [],
|
||||
'utils': [],
|
||||
'returners': [],
|
||||
'modules': ['modules.override_test',
|
||||
'modules': ['modules.mantest',
|
||||
'modules.override_test',
|
||||
'modules.runtests_decorators',
|
||||
'modules.runtests_helpers',
|
||||
'modules.salttest'],
|
||||
|
@ -129,7 +130,8 @@ class SaltUtilSyncModuleTest(ModuleCase):
|
|||
'beacons': [],
|
||||
'utils': [],
|
||||
'returners': [],
|
||||
'modules': ['modules.override_test',
|
||||
'modules': ['modules.mantest',
|
||||
'modules.override_test',
|
||||
'modules.runtests_helpers',
|
||||
'modules.salttest'],
|
||||
'renderers': [],
|
||||
|
|
|
@ -59,7 +59,7 @@ class AuthTest(ShellCase):
|
|||
def setUp(self):
|
||||
for user in (self.userA, self.userB):
|
||||
try:
|
||||
if salt.utils.is_darwin() and user not in str(self.run_call('user.list_users')):
|
||||
if salt.utils.platform.is_darwin() and user not in str(self.run_call('user.list_users')):
|
||||
# workaround for https://github.com/saltstack/salt-jenkins/issues/504
|
||||
raise KeyError
|
||||
pwd.getpwnam(user)
|
||||
|
@ -68,7 +68,7 @@ class AuthTest(ShellCase):
|
|||
|
||||
# only put userB into the group for the group auth test
|
||||
try:
|
||||
if salt.utils.is_darwin() and self.group not in str(self.run_call('group.info {0}'.format(self.group))):
|
||||
if salt.utils.platform.is_darwin() and self.group not in str(self.run_call('group.info {0}'.format(self.group))):
|
||||
# workaround for https://github.com/saltstack/salt-jenkins/issues/504
|
||||
raise KeyError
|
||||
grp.getgrnam(self.group)
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Tests man spm
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import destructiveTest, flaky
|
||||
from tests.support.paths import CODE_DIR
|
||||
|
||||
|
||||
@destructiveTest
|
||||
class SPMManTest(ModuleCase):
|
||||
'''
|
||||
Validate man spm
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
self.tmpdir = tempfile.mktemp()
|
||||
os.mkdir(self.tmpdir)
|
||||
self.run_function('cmd.run', ['{0} {1} install --root={2}'.format(
|
||||
sys.executable,
|
||||
os.path.join(CODE_DIR, 'setup.py'),
|
||||
self.tmpdir
|
||||
)])
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir)
|
||||
|
||||
@flaky
|
||||
def test_man_spm(self):
|
||||
'''
|
||||
test man spm
|
||||
'''
|
||||
manpath = self.run_function('cmd.run', ['find {0} -name spm.1'.format(self.tmpdir)])
|
||||
self.assertIn('/man1/', manpath)
|
||||
cmd = self.run_function('cmd.run', ['man {0}'.format(manpath)])
|
||||
self.assertIn('Salt Package Manager', cmd)
|
||||
self.assertIn('command for managing Salt packages', cmd)
|
|
@ -33,7 +33,7 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
Basic test to determine if NPM module was successfully installed and
|
||||
removed.
|
||||
'''
|
||||
ret = self.run_state('npm.installed', name='pm2')
|
||||
ret = self.run_state('npm.installed', name='pm2', registry="http://registry.npmjs.org/")
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('npm.removed', name='pm2')
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
@ -51,7 +51,11 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
else:
|
||||
user = None
|
||||
npm_dir = None
|
||||
ret = self.run_state('npm.installed', name='request/request#v2.81.1', runas=user, dir=npm_dir)
|
||||
ret = self.run_state('npm.installed',
|
||||
name='request/request#v2.81.1',
|
||||
runas=user,
|
||||
dir=npm_dir,
|
||||
registry="http://registry.npmjs.org/")
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('npm.removed', name='git://github.com/request/request', runas=user, dir=npm_dir)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
@ -65,7 +69,7 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
Basic test to determine if NPM module successfully installs multiple
|
||||
packages.
|
||||
'''
|
||||
ret = self.run_state('npm.installed', name='unused', pkgs=['pm2', 'grunt'])
|
||||
ret = self.run_state('npm.installed', name='unused', pkgs=['pm2', 'grunt'], registry="http://registry.npmjs.org/")
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@skipIf(salt.utils.path.which('npm') and LooseVersion(cmd.run('npm -v')) >= LooseVersion(MAX_NPM_VERSION),
|
||||
|
|
|
@ -115,6 +115,9 @@ TEST_SUITES = {
|
|||
'client':
|
||||
{'display_name': 'Client',
|
||||
'path': 'integration/client'},
|
||||
'doc':
|
||||
{'display_name': 'Documentation',
|
||||
'path': 'integration/doc'},
|
||||
'ext_pillar':
|
||||
{'display_name': 'External Pillar',
|
||||
'path': 'integration/pillar'},
|
||||
|
@ -292,6 +295,15 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
|
|||
action='store_true',
|
||||
help='Run tests for client'
|
||||
)
|
||||
self.test_selection_group.add_option(
|
||||
'-d',
|
||||
'--doc',
|
||||
'--doc-tests',
|
||||
dest='doc',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Run tests for documentation'
|
||||
)
|
||||
self.test_selection_group.add_option(
|
||||
'-I',
|
||||
'--ext-pillar',
|
||||
|
|
96
tests/support/win_installer.py
Normal file
96
tests/support/win_installer.py
Normal file
|
@ -0,0 +1,96 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:copyright: Copyright 2013-2017 by the SaltStack Team, see AUTHORS for more details.
|
||||
:license: Apache 2.0, see LICENSE for more details.
|
||||
|
||||
|
||||
tests.support.win_installer
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Fetches the binary Windows installer
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
import hashlib
|
||||
import requests
|
||||
import re
|
||||
|
||||
PREFIX = 'Salt-Minion-'
|
||||
REPO = "https://repo.saltstack.com/windows"
|
||||
|
||||
|
||||
def iter_installers(content):
|
||||
'''
|
||||
Parse a list of windows installer links and their corresponding md5
|
||||
checksum links.
|
||||
'''
|
||||
HREF_RE = "<a href=\"(.*?)\">"
|
||||
installer, md5 = None, None
|
||||
for m in re.finditer(HREF_RE, content):
|
||||
x = m.groups()[0]
|
||||
if not x.startswith(PREFIX):
|
||||
continue
|
||||
if x.endswith('zip'):
|
||||
continue
|
||||
if installer:
|
||||
if x != installer + '.md5':
|
||||
raise Exception("Unable to parse response")
|
||||
md5 = x
|
||||
yield installer, md5
|
||||
installer, md5 = None, None
|
||||
else:
|
||||
installer = x
|
||||
|
||||
|
||||
def split_installer(name):
|
||||
'''
|
||||
Return a tuple of the salt version, python verison and architecture from an
|
||||
installer name.
|
||||
'''
|
||||
x = name[len(PREFIX):]
|
||||
return x.split('-')[:3]
|
||||
|
||||
|
||||
def latest_version(repo=REPO):
|
||||
'''
|
||||
Return the latest version found on the salt repository webpage.
|
||||
'''
|
||||
for name, md5 in iter_installers(requests.get(repo).content):
|
||||
pass
|
||||
return split_installer(name)[0]
|
||||
|
||||
|
||||
def installer_name(salt_ver, py_ver='Py2', arch='AMD64'):
|
||||
'''
|
||||
Create an installer file name
|
||||
'''
|
||||
return "Salt-Minion-{}-{}-{}-Setup.exe".format(salt_ver, py_ver, arch)
|
||||
|
||||
|
||||
def latest_installer_name(repo=REPO, **kwargs):
|
||||
'''
|
||||
Fetch the latest installer name
|
||||
'''
|
||||
return installer_name(latest_version(repo), **kwargs)
|
||||
|
||||
|
||||
def download_and_verify(fp, name, repo=REPO):
|
||||
'''
|
||||
Download an installer and verify it's contents.
|
||||
'''
|
||||
md5 = "{}.md5".format(name)
|
||||
url = lambda x: "{}/{}".format(repo, x)
|
||||
resp = requests.get(url(md5))
|
||||
if resp.status_code != 200:
|
||||
raise Exception("Unable to fetch installer md5")
|
||||
installer_md5 = resp.text.strip().split()[0].lower()
|
||||
resp = requests.get(url(name), stream=True)
|
||||
if resp.status_code != 200:
|
||||
raise Exception("Unable to fetch installer")
|
||||
md5hsh = hashlib.md5()
|
||||
for chunk in resp.iter_content(chunk_size=1024):
|
||||
md5hsh.update(chunk)
|
||||
fp.write(chunk)
|
||||
if md5hsh.hexdigest() != installer_md5:
|
||||
raise Exception("Installer's hash does not match {} != {}".format(
|
||||
md5hsh.hexdigest(), installer_md5
|
||||
))
|
|
@ -19,6 +19,8 @@
|
|||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import errno
|
||||
import subprocess
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
|
@ -33,7 +35,33 @@ from tests.support.mock import (
|
|||
from salt.modules.inspectlib.collector import Inspector
|
||||
|
||||
|
||||
HAS_SYMLINKS = None
|
||||
|
||||
|
||||
def no_symlinks():
|
||||
'''
|
||||
Check if git is installed and has symlinks enabled in the configuration.
|
||||
'''
|
||||
global HAS_SYMLINKS
|
||||
if HAS_SYMLINKS is not None:
|
||||
return not HAS_SYMLINKS
|
||||
output = ''
|
||||
try:
|
||||
output = subprocess.check_output('git config --get core.symlinks', shell=True)
|
||||
except OSError as exc:
|
||||
if exc.errno != errno.ENOENT:
|
||||
raise
|
||||
except subprocess.CalledProcessError:
|
||||
# git returned non-zero status
|
||||
pass
|
||||
HAS_SYMLINKS = False
|
||||
if output.strip() == 'true':
|
||||
HAS_SYMLINKS = True
|
||||
return not HAS_SYMLINKS
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
@skipIf(no_symlinks(), "Git missing 'core.symlinks=true' config")
|
||||
class InspectorCollectorTestCase(TestCase):
|
||||
'''
|
||||
Test inspectlib:collector:Inspector
|
||||
|
|
|
@ -40,6 +40,11 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
X11 Layout: us
|
||||
X11 Model: pc105
|
||||
'''
|
||||
locale_ctl_notset = '''
|
||||
System Locale: n/a
|
||||
VC Keymap: n/a
|
||||
X11 Layout: n/a
|
||||
'''
|
||||
locale_ctl_out_empty = ''
|
||||
locale_ctl_out_broken = '''
|
||||
System error:Recursive traversal of loopback mount points
|
||||
|
@ -79,9 +84,36 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
assert 'LANG' in out['system_locale']
|
||||
assert 'LANGUAGE' in out['system_locale']
|
||||
assert out['system_locale']['LANG'] == out['system_locale']['LANGUAGE'] == 'de_DE.utf8'
|
||||
assert out['vc_keymap'] == 'n/a'
|
||||
assert out['x11_layout'] == 'us'
|
||||
assert out['x11_model'] == 'pc105'
|
||||
assert isinstance(out['vc_keymap'], dict)
|
||||
assert 'data' in out['vc_keymap']
|
||||
assert out['vc_keymap']['data'] == 'n/a'
|
||||
assert isinstance(out['x11_layout'], dict)
|
||||
assert 'data' in out['x11_layout']
|
||||
assert out['x11_layout']['data'] == 'us'
|
||||
assert isinstance(out['x11_model'], dict)
|
||||
assert 'data' in out['x11_model']
|
||||
assert out['x11_model']['data'] == 'pc105'
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/localctl"))
|
||||
@patch('salt.modules.localemod.__salt__', {'cmd.run': MagicMock(return_value=locale_ctl_notset)})
|
||||
def test_localectl_status_parser_notset(self):
|
||||
'''
|
||||
Test localectl status parser.
|
||||
:return:
|
||||
'''
|
||||
out = localemod._localectl_status()
|
||||
assert isinstance(out, dict)
|
||||
for key in ['system_locale', 'vc_keymap', 'x11_layout']:
|
||||
assert key in out
|
||||
assert isinstance(out['system_locale'], dict)
|
||||
assert 'data' in out['system_locale']
|
||||
assert out['system_locale']['data'] == 'n/a'
|
||||
assert isinstance(out['vc_keymap'], dict)
|
||||
assert 'data' in out['vc_keymap']
|
||||
assert out['vc_keymap']['data'] == 'n/a'
|
||||
assert isinstance(out['x11_layout'], dict)
|
||||
assert 'data' in out['x11_layout']
|
||||
assert out['x11_layout']['data'] == 'n/a'
|
||||
|
||||
@patch('salt.modules.localemod.dbus', MagicMock())
|
||||
def test_dbus_locale_parser_matches(self):
|
||||
|
@ -154,7 +186,7 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
assert isinstance(out[key], dict)
|
||||
for in_key in out[key]:
|
||||
assert isinstance(out[key][in_key], six.text_type)
|
||||
assert isinstance(out['reason'], six.text_type)
|
||||
assert isinstance(out['reason']['data'], six.text_type)
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/localctl"))
|
||||
@patch('salt.modules.localemod.__grains__', {'os_family': 'Ubuntu', 'osmajorrelease': 42})
|
||||
|
|
|
@ -6,7 +6,7 @@ import os
|
|||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.unit import TestCase
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import (
|
||||
MagicMock,
|
||||
patch
|
||||
|
@ -14,6 +14,8 @@ from tests.support.mock import (
|
|||
# Import salt libs
|
||||
import salt.states.environ as envstate
|
||||
import salt.modules.environ as envmodule
|
||||
import salt.modules.reg
|
||||
import salt.utils.platform
|
||||
|
||||
|
||||
class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
||||
|
@ -22,17 +24,21 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
loader_globals = {
|
||||
'__env__': 'base',
|
||||
'__opts__': {'test': False},
|
||||
'__salt__': {'environ.setenv': envmodule.setenv}
|
||||
'__salt__': {
|
||||
'environ.setenv': envmodule.setenv,
|
||||
'reg.read_value': salt.modules.reg.read_value,
|
||||
}
|
||||
}
|
||||
return {envstate: loader_globals, envmodule: loader_globals}
|
||||
|
||||
def setUp(self):
|
||||
original_environ = os.environ.copy()
|
||||
os.environ = {'INITIAL': 'initial'}
|
||||
patcher = patch.dict(os.environ, {'INITIAL': 'initial'}, clear=True)
|
||||
patcher.start()
|
||||
|
||||
def reset_environ(original_environ):
|
||||
os.environ = original_environ
|
||||
self.addCleanup(reset_environ, original_environ)
|
||||
def reset_environ(patcher):
|
||||
patcher.stop()
|
||||
|
||||
self.addCleanup(reset_environ, patcher)
|
||||
|
||||
def test_setenv(self):
|
||||
'''
|
||||
|
@ -48,9 +54,12 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
ret = envstate.setenv('test', 'other')
|
||||
self.assertEqual(ret['changes'], {})
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Windows only')
|
||||
def test_setenv_permanent(self):
|
||||
with patch.dict(envmodule.__salt__, {'reg.set_value': MagicMock(), 'reg.delete_value': MagicMock()}), \
|
||||
patch('salt.utils.platform.is_windows', MagicMock(return_value=True)):
|
||||
'''
|
||||
test that we can set perminent environment variables (requires pywin32)
|
||||
'''
|
||||
with patch.dict(envmodule.__salt__, {'reg.set_value': MagicMock(), 'reg.delete_value': MagicMock()}):
|
||||
ret = envstate.setenv('test', 'value', permanent=True)
|
||||
self.assertEqual(ret['changes'], {'test': 'value'})
|
||||
envmodule.__salt__['reg.set_value'].assert_called_with("HKCU", "Environment", 'test', 'value')
|
||||
|
@ -91,7 +100,10 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
ret = envstate.setenv('test', 'value', clear_all=True)
|
||||
self.assertEqual(ret['changes'], {'test': 'value', 'INITIAL': ''})
|
||||
self.assertEqual(envstate.os.environ, {'test': 'value', 'INITIAL': ''})
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'TEST': 'value', 'INITIAL': ''})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'test': 'value', 'INITIAL': ''})
|
||||
|
||||
def test_setenv_clearall_with_unset(self):
|
||||
'''
|
||||
|
@ -100,7 +112,10 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
ret = envstate.setenv('test', 'value', false_unsets=True, clear_all=True)
|
||||
self.assertEqual(ret['changes'], {'test': 'value', 'INITIAL': None})
|
||||
self.assertEqual(envstate.os.environ, {'test': 'value'})
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'TEST': 'value'})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'test': 'value'})
|
||||
|
||||
def test_setenv_unset_multi(self):
|
||||
'''
|
||||
|
@ -113,12 +128,18 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
ret = envstate.setenv(
|
||||
'notimportant', {'test': False, 'foo': 'baz'}, false_unsets=True)
|
||||
self.assertEqual(ret['changes'], {'test': None, 'foo': 'baz'})
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'foo': 'baz'})
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'FOO': 'baz'})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'foo': 'baz'})
|
||||
|
||||
with patch.dict(envstate.__salt__, {'reg.read_value': MagicMock()}):
|
||||
ret = envstate.setenv('notimportant', {'test': False, 'foo': 'bax'})
|
||||
self.assertEqual(ret['changes'], {'test': '', 'foo': 'bax'})
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'foo': 'bax', 'test': ''})
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'FOO': 'bax', 'TEST': ''})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'foo': 'bax', 'test': ''})
|
||||
|
||||
def test_setenv_test_mode(self):
|
||||
'''
|
||||
|
|
|
@ -1846,3 +1846,36 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
|||
run_checks(test=True)
|
||||
run_checks(strptime_format=fake_strptime_format)
|
||||
run_checks(strptime_format=fake_strptime_format, test=True)
|
||||
|
||||
|
||||
class TestFindKeepFiles(TestCase):
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'Do not run on Windows')
|
||||
def test__find_keep_files_unix(self):
|
||||
keep = filestate._find_keep_files(
|
||||
'/test/parent_folder',
|
||||
['/test/parent_folder/meh.txt']
|
||||
)
|
||||
expected = [
|
||||
'/',
|
||||
'/test',
|
||||
'/test/parent_folder',
|
||||
'/test/parent_folder/meh.txt',
|
||||
]
|
||||
actual = sorted(list(keep))
|
||||
assert actual == expected, actual
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Only run on Windows')
|
||||
def test__find_keep_files_win32(self):
|
||||
keep = filestate._find_keep_files(
|
||||
'c:\\test\\parent_folder',
|
||||
['C:\\test\\parent_folder\\meh-2.txt']
|
||||
)
|
||||
expected = [
|
||||
'c:\\',
|
||||
'c:\\test',
|
||||
'c:\\test\\parent_folder',
|
||||
'c:\\test\\parent_folder\\meh-2.txt'
|
||||
]
|
||||
actual = sorted(list(keep))
|
||||
assert actual == expected, actual
|
||||
|
|
|
@ -41,17 +41,18 @@ class WinNetworkTestCase(TestCase, LoaderModuleMockMixin):
|
|||
' static, dhcp.'})
|
||||
self.assertDictEqual(win_network.managed('salt'), ret)
|
||||
|
||||
mock = MagicMock(return_value=False)
|
||||
mock_false = MagicMock(return_value=False)
|
||||
mock_true = MagicMock(return_value=True)
|
||||
mock1 = MagicMock(side_effect=[False, True, True, True, True, True,
|
||||
True])
|
||||
mock2 = MagicMock(side_effect=[False, True, True, {'salt': 'True'},
|
||||
{'salt': 'True'}])
|
||||
with patch.dict(win_network.__salt__, {"ip.is_enabled": mock,
|
||||
with patch.dict(win_network.__salt__, {"ip.is_enabled": mock_false,
|
||||
"ip.is_disabled": mock1,
|
||||
"ip.enable": mock,
|
||||
"ip.enable": mock_false,
|
||||
"ip.get_interface": mock2,
|
||||
"ip.set_dhcp_dns": mock,
|
||||
"ip.set_dhcp_ip": mock}):
|
||||
"ip.set_dhcp_dns": mock_false,
|
||||
"ip.set_dhcp_ip": mock_false}):
|
||||
ret.update({'comment': "Interface 'salt' is up to date."
|
||||
" (already disabled)", 'result': True})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
|
@ -66,52 +67,54 @@ class WinNetworkTestCase(TestCase, LoaderModuleMockMixin):
|
|||
dns_proto='static',
|
||||
ip_proto='static'),
|
||||
ret)
|
||||
mock = MagicMock(side_effect=['True', False, False, False, False,
|
||||
mock_false = MagicMock(side_effect=['True', False, False, False, False,
|
||||
False])
|
||||
with patch.object(win_network, '_validate', mock):
|
||||
ret.update({'comment': 'The following SLS configuration'
|
||||
' errors were detected: T r u e'})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='static',
|
||||
ip_proto='static'),
|
||||
ret)
|
||||
|
||||
ret.update({'comment': "Unable to get current"
|
||||
" configuration for interface 'salt'",
|
||||
'result': False})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='dhcp',
|
||||
ip_proto='dhcp'),
|
||||
ret)
|
||||
with patch.dict(win_network.__salt__, {"ip.is_enabled": mock_true}):
|
||||
with patch.object(win_network, '_validate', mock_false):
|
||||
ret.update({'comment': 'The following SLS configuration'
|
||||
' errors were detected: T r u e'})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='static',
|
||||
ip_proto='static'),
|
||||
ret)
|
||||
|
||||
mock = MagicMock(side_effect=[False, [''],
|
||||
{'dns_proto': 'dhcp',
|
||||
'ip_proto': 'dhcp'},
|
||||
{'dns_proto': 'dhcp',
|
||||
'ip_proto': 'dhcp'}])
|
||||
ret.update({'comment': "Interface 'salt' is up to date.",
|
||||
'result': True})
|
||||
with patch.object(win_network, '_changes', mock):
|
||||
ret.update({'comment': "Unable to get current"
|
||||
" configuration for interface 'salt'",
|
||||
'result': False})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='dhcp',
|
||||
ip_proto='dhcp'
|
||||
), ret)
|
||||
ip_proto='dhcp'),
|
||||
ret)
|
||||
|
||||
ret.update({'comment': "The following changes will be made"
|
||||
" to interface 'salt': ", 'result': None})
|
||||
with patch.dict(win_network.__opts__, {"test": True}):
|
||||
mock_false = MagicMock(side_effect=[False, [''],
|
||||
{'dns_proto': 'dhcp',
|
||||
'ip_proto': 'dhcp'},
|
||||
{'dns_proto': 'dhcp',
|
||||
'ip_proto': 'dhcp'}])
|
||||
ret.update({'comment': "Interface 'salt' is up to date.",
|
||||
'result': True})
|
||||
with patch.object(win_network, '_changes', mock_false):
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='dh'
|
||||
'cp',
|
||||
dns_proto='dhcp',
|
||||
ip_proto='dhcp'
|
||||
), ret)
|
||||
|
||||
with patch.dict(win_network.__opts__, {"test": False}):
|
||||
ret.update({'comment': "Failed to set desired"
|
||||
" configuration settings for interface"
|
||||
" 'salt'", 'result': False})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='dh'
|
||||
'cp',
|
||||
ip_proto='dhcp'
|
||||
), ret)
|
||||
ret.update({'comment': "The following changes will be made"
|
||||
" to interface 'salt': ", 'result': None})
|
||||
with patch.dict(win_network.__opts__, {"test": True}):
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='dh'
|
||||
'cp',
|
||||
ip_proto='dhcp'
|
||||
), ret)
|
||||
|
||||
with patch.dict(win_network.__opts__, {"test": False}):
|
||||
ret.update({'comment': "Failed to set desired"
|
||||
" configuration settings for interface"
|
||||
" 'salt'", 'result': False})
|
||||
self.assertDictEqual(win_network.managed('salt',
|
||||
dns_proto='dh'
|
||||
'cp',
|
||||
ip_proto='dhcp'
|
||||
), ret)
|
||||
|
|
|
@ -13,7 +13,10 @@ from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON
|
|||
|
||||
# Import Salt libs
|
||||
from salt import client
|
||||
from salt.exceptions import EauthAuthenticationError, SaltInvocationError, SaltClientError
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import (
|
||||
EauthAuthenticationError, SaltInvocationError, SaltClientError, SaltReqTimeoutError
|
||||
)
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
|
@ -67,7 +70,13 @@ class LocalClientTestCase(TestCase,
|
|||
kwarg=None, tgt_type='list',
|
||||
ret='')
|
||||
|
||||
@skipIf(salt.utils.platform.is_windows(), 'Not supported on Windows')
|
||||
def test_pub(self):
|
||||
'''
|
||||
Tests that the client cleanly returns when the publisher is not running
|
||||
|
||||
Note: Requires ZeroMQ's IPC transport which is not supported on windows.
|
||||
'''
|
||||
if self.get_config('minion')['transport'] != 'zeromq':
|
||||
self.skipTest('This test only works with ZeroMQ')
|
||||
# Make sure we cleanly return if the publisher isn't running
|
||||
|
@ -83,3 +92,27 @@ class LocalClientTestCase(TestCase,
|
|||
self.assertRaises(SaltInvocationError,
|
||||
self.client.pub,
|
||||
'non_existent_group', 'test.ping', tgt_type='nodegroup')
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Windows only test')
|
||||
def test_pub_win32(self):
|
||||
'''
|
||||
Tests that the client raises a timeout error when using ZeroMQ's TCP
|
||||
transport and publisher is not running.
|
||||
|
||||
Note: Requires ZeroMQ's TCP transport, this is only the default on Windows.
|
||||
'''
|
||||
if self.get_config('minion')['transport'] != 'zeromq':
|
||||
self.skipTest('This test only works with ZeroMQ')
|
||||
# Make sure we cleanly return if the publisher isn't running
|
||||
with patch('os.path.exists', return_value=False):
|
||||
self.assertRaises(SaltReqTimeoutError, lambda: self.client.pub('*', 'test.ping'))
|
||||
|
||||
# Check nodegroups behavior
|
||||
with patch('os.path.exists', return_value=True):
|
||||
with patch.dict(self.client.opts,
|
||||
{'nodegroups':
|
||||
{'group1': 'L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com'}}):
|
||||
# Do we raise an exception if the nodegroup can't be matched?
|
||||
self.assertRaises(SaltInvocationError,
|
||||
self.client.pub,
|
||||
'non_existent_group', 'test.ping', tgt_type='nodegroup')
|
||||
|
|
1
tests/unit/tops/__init__.py
Normal file
1
tests/unit/tops/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
# -*- coding: utf-8 -*-
|
65
tests/unit/tops/test_ext_nodes.py
Normal file
65
tests/unit/tops/test_ext_nodes.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Test ext_nodes master_tops module
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import subprocess
|
||||
import textwrap
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import patch, MagicMock, NO_MOCK, NO_MOCK_REASON
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.stringutils
|
||||
import salt.tops.ext_nodes as ext_nodes
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class ExtNodesTestCase(TestCase, LoaderModuleMockMixin):
|
||||
def setup_loader_modules(self):
|
||||
return {
|
||||
ext_nodes: {
|
||||
'__opts__': {
|
||||
'master_tops': {
|
||||
# Since ext_nodes runs the command with shell=True,
|
||||
# this will keep "command not found" errors from
|
||||
# showing up on the console. We'll be mocking the
|
||||
# communicate results anyway.
|
||||
'ext_nodes': 'echo',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def test_ext_nodes(self):
|
||||
'''
|
||||
Confirm that subprocess.Popen works as expected and does not raise an
|
||||
exception (see https://github.com/saltstack/salt/pull/46863).
|
||||
'''
|
||||
stdout = salt.utils.stringutils.to_bytes(textwrap.dedent('''\
|
||||
classes:
|
||||
- one
|
||||
- two'''))
|
||||
communicate_mock = MagicMock(return_value=(stdout, None))
|
||||
with patch.object(subprocess.Popen, 'communicate', communicate_mock):
|
||||
ret = ext_nodes.top(opts={'id': 'foo'})
|
||||
self.assertEqual(ret, {'base': ['one', 'two']})
|
||||
|
||||
def test_ext_nodes_with_environment(self):
|
||||
'''
|
||||
Same as above, but also tests that the matches are assigned to the proper
|
||||
environment if one is returned by the ext_nodes command.
|
||||
'''
|
||||
stdout = salt.utils.stringutils.to_bytes(textwrap.dedent('''\
|
||||
classes:
|
||||
- one
|
||||
- two
|
||||
environment: dev'''))
|
||||
communicate_mock = MagicMock(return_value=(stdout, None))
|
||||
with patch.object(subprocess.Popen, 'communicate', communicate_mock):
|
||||
ret = ext_nodes.top(opts={'id': 'foo'})
|
||||
self.assertEqual(ret, {'dev': ['one', 'two']})
|
|
@ -240,7 +240,6 @@ class DataTestCase(TestCase):
|
|||
|
||||
ret = salt.utils.data.decode(
|
||||
self.test_data,
|
||||
encoding='utf-8',
|
||||
keep=True,
|
||||
normalize=True,
|
||||
preserve_dict_class=True,
|
||||
|
@ -253,7 +252,6 @@ class DataTestCase(TestCase):
|
|||
UnicodeDecodeError,
|
||||
salt.utils.data.decode,
|
||||
self.test_data,
|
||||
encoding='utf-8',
|
||||
keep=False,
|
||||
normalize=True,
|
||||
preserve_dict_class=True,
|
||||
|
@ -267,7 +265,6 @@ class DataTestCase(TestCase):
|
|||
|
||||
ret = salt.utils.data.decode(
|
||||
self.test_data,
|
||||
encoding='utf-8',
|
||||
keep=True,
|
||||
normalize=True,
|
||||
preserve_dict_class=False,
|
||||
|
|
|
@ -97,7 +97,6 @@ class StringutilsTestCase(TestCase):
|
|||
self.assertEqual(
|
||||
salt.utils.stringutils.to_unicode(
|
||||
EGGS,
|
||||
encoding='utf=8',
|
||||
normalize=True
|
||||
),
|
||||
'яйца'
|
||||
|
@ -105,7 +104,6 @@ class StringutilsTestCase(TestCase):
|
|||
self.assertNotEqual(
|
||||
salt.utils.stringutils.to_unicode(
|
||||
EGGS,
|
||||
encoding='utf=8',
|
||||
normalize=False
|
||||
),
|
||||
'яйца'
|
||||
|
@ -120,9 +118,12 @@ class StringutilsTestCase(TestCase):
|
|||
self.assertEqual(salt.utils.stringutils.to_unicode(str('xyzzy'), 'utf-8'), 'xyzzy') # future lint: disable=blacklisted-function
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode(BYTES, 'utf-8'), UNICODE)
|
||||
|
||||
# Test utf-8 fallback with ascii default encoding
|
||||
# Test that unicode chars are decoded properly even when using
|
||||
# locales which are not UTF-8 compatible
|
||||
with patch.object(builtins, '__salt_system_encoding__', 'ascii'):
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode(u'Ψ'.encode('utf-8')), u'Ψ')
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('Ψ'.encode('utf-8')), 'Ψ')
|
||||
with patch.object(builtins, '__salt_system_encoding__', 'CP1252'):
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('Ψ'.encode('utf-8')), 'Ψ')
|
||||
|
||||
def test_build_whitespace_split_regex(self):
|
||||
expected_regex = '(?m)^(?:[\\s]+)?Lorem(?:[\\s]+)?ipsum(?:[\\s]+)?dolor(?:[\\s]+)?sit(?:[\\s]+)?amet\\,' \
|
||||
|
@ -169,3 +170,12 @@ class StringutilsTestCase(TestCase):
|
|||
context = salt.utils.stringutils.get_context(template, 8, num_lines=2, marker=' <---')
|
||||
expected = '---\n[...]\n6\n7\n8 <---\n9\na\n[...]\n---'
|
||||
self.assertEqual(expected, context)
|
||||
|
||||
def test_expr_match(self):
|
||||
val = 'foo/bar/baz'
|
||||
# Exact match
|
||||
self.assertTrue(salt.utils.stringutils.expr_match(val, val))
|
||||
# Glob match
|
||||
self.assertTrue(salt.utils.stringutils.expr_match(val, 'foo/*/baz'))
|
||||
# Glob non-match
|
||||
self.assertFalse(salt.utils.stringutils.expr_match(val, 'foo/*/bar'))
|
||||
|
|
|
@ -10,6 +10,7 @@ integration.modules.test_data
|
|||
integration.modules.test_disk
|
||||
integration.modules.test_git
|
||||
integration.modules.test_grains
|
||||
integration.modules.test_groupadd
|
||||
integration.modules.test_hosts
|
||||
integration.modules.test_mine
|
||||
integration.modules.test_pillar
|
||||
|
|
Loading…
Add table
Reference in a new issue