diff --git a/HACKING.rst b/HACKING.rst index 281dd14c6873..4c17e671b9ad 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -94,10 +94,10 @@ virtualenv using the ``--system-site-packages`` option so that these modules are available in the virtualenv. -Installing dependencies on OS X -``````````````````````````````` +Installing dependencies on macOS +```````````````````````````````` -One simple way to get all needed dependencies on OS X is to use homebrew, +One simple way to get all needed dependencies on macOS is to use homebrew, and install the following packages:: brew install zmq @@ -187,7 +187,7 @@ Edit the master config file: ``/path/to/your/virtualenv/salt-master.pid``. 4. If you are also running a non-development version of Salt you will have to change the ``publish_port`` and ``ret_port`` values as well. -5. On OS X also set max_open_files to 2048. +5. On xxxOS X also set max_open_files to 2048. Edit the minion config file: diff --git a/doc/topics/beacons/index.rst b/doc/topics/beacons/index.rst index 54d0600d9d48..0fe50ba8a4ce 100644 --- a/doc/topics/beacons/index.rst +++ b/doc/topics/beacons/index.rst @@ -48,7 +48,7 @@ minion pillar, grains, or local config file. .. note:: The `inotify` beacon only works on OSes that have `inotify` kernel support. - Currently this excludes FreeBSD, Mac OS X, and Windows. + Currently this excludes FreeBSD, macOS, and Windows. Beacon Monitoring Interval -------------------------- diff --git a/doc/topics/cloud/install/index.rst b/doc/topics/cloud/install/index.rst index 7bab0666266d..f551aba5aeb0 100644 --- a/doc/topics/cloud/install/index.rst +++ b/doc/topics/cloud/install/index.rst @@ -12,7 +12,7 @@ On Ubuntu, install Salt Cloud by using following command: sudo apt-get update sudo apt-get install salt-cloud -If using Salt Cloud on OS X, ``curl-ca-bundle`` must be installed. Presently, +If using Salt Cloud on macOS, ``curl-ca-bundle`` must be installed. Presently, this package is not available via ``brew``, but it is available using MacPorts: .. code-block:: bash diff --git a/doc/topics/development/hacking.rst b/doc/topics/development/hacking.rst index 90add5267003..763cbd111b1a 100644 --- a/doc/topics/development/hacking.rst +++ b/doc/topics/development/hacking.rst @@ -83,10 +83,10 @@ Install Salt (and dependencies) into the virtualenv: .. _`Fedora Linux`: http://fedoraproject.org/ .. _`Amazon Linux`: https://aws.amazon.com/amazon-linux-ami/ -.. note:: Installing dependencies on OS X. +.. note:: Installing dependencies on macOS. - You can install needed dependencies on OS X using homebrew or macports. - See :ref:`OS X Installation ` + You can install needed dependencies on macOS using homebrew or macports. + See :ref:`macOS Installation ` .. warning:: Installing on RedHat-based Distros @@ -195,7 +195,7 @@ If you would like to log to the console instead of to the log file, remove the # use 'limit descriptors 2047' for c-shell ulimit -n 2047 - To set file descriptors on OSX, refer to the :ref:`OS X Installation + To set file descriptors on macOS, refer to the :ref:`macOS Installation ` instructions. diff --git a/doc/topics/development/tests/integration.rst b/doc/topics/development/tests/integration.rst index ecc37b368094..57c10e31f02a 100644 --- a/doc/topics/development/tests/integration.rst +++ b/doc/topics/development/tests/integration.rst @@ -82,9 +82,9 @@ test suite illustrating the broad usefulness of each function. The ``setUp`` function is used to set up any repetitive or useful tasks that the tests in a test class need before running. For example, any of the ``mac_*`` -integration tests should only run on OSX machines. The ``setUp`` function can be -used to test for the presence of the ``Darwin`` kernel. If the ``Darwin`` kernel -is not present, then the test should be skipped. +integration tests should only run on macOS machines. The ``setUp`` function can +be used to test for the presence of the ``Darwin`` kernel. If the ``Darwin`` +kernel is not present, then the test should be skipped. .. code-block:: python diff --git a/doc/topics/installation/osx.rst b/doc/topics/installation/osx.rst index 676e82552685..399c597a2505 100644 --- a/doc/topics/installation/osx.rst +++ b/doc/topics/installation/osx.rst @@ -1,8 +1,8 @@ .. _macos-installation: -==== -OS X -==== +===== +macOS +===== Installation from the Official SaltStack Repository =================================================== @@ -39,7 +39,7 @@ Installation from MacPorts Installation from Pip ===================== -When only using the OS X system's pip, install this way: +When only using the macOS system's pip, install this way: .. code-block:: bash @@ -48,15 +48,15 @@ When only using the OS X system's pip, install this way: Salt-Master Customizations ========================== .. note:: - Salt master on OS X is not tested or supported by SaltStack. See `SaltStack Platform Support `_ for more information. + Salt master on macOS is not tested or supported by SaltStack. See `SaltStack Platform Support `_ for more information. -To run salt-master on OS X, sudo add this configuration option to the /etc/salt/master file: +To run salt-master on macOS, sudo add this configuration option to the /etc/salt/master file: .. code-block:: bash max_open_files: 8192 -On versions previous to OS X 10.10 (Yosemite), increase the root user maxfiles limit: +On versions previous to macOS 10.10 (Yosemite), increase the root user maxfiles limit: .. code-block:: bash @@ -64,7 +64,7 @@ On versions previous to OS X 10.10 (Yosemite), increase the root user maxfiles l .. note:: - On OS X 10.10 (Yosemite) and higher, maxfiles should not be adjusted. The + On macOS 10.10 (Yosemite) and higher, maxfiles should not be adjusted. The default limits are sufficient in all but the most extreme scenarios. Overriding these values with the setting below will cause system instability! diff --git a/doc/topics/releases/0.17.0.rst b/doc/topics/releases/0.17.0.rst index e00948944ad0..e819eadbe930 100644 --- a/doc/topics/releases/0.17.0.rst +++ b/doc/topics/releases/0.17.0.rst @@ -160,10 +160,10 @@ Extensive additions have been added to Salt for LXC support. This included the backend libs for managing LXC containers. Addition into the salt-virt system is still in the works. -Mac OS X User/Group Support ---------------------------- +macOS User/Group Support +------------------------ -Salt is now able to manage users and groups on Minions running Mac OS X. +Salt is now able to manage users and groups on Minions running macOS. However, at this time user passwords cannot be managed. Django ORM External Pillar diff --git a/doc/topics/releases/0.17.2.rst b/doc/topics/releases/0.17.2.rst index 4bcfb53d94c1..0d6308da8d4d 100644 --- a/doc/topics/releases/0.17.2.rst +++ b/doc/topics/releases/0.17.2.rst @@ -66,7 +66,7 @@ Version 0.17.2 is another bugfix release for :ref:`0.17.0 - Fix compound matcher for grains (:issue:`7944`) - Improve error reporting in ebuild module (related to :issue:`5393`) - Add ``dir_mode`` to ``file.managed`` (:issue:`7860`) -- Improve traceroute support for FreeBSD and OS X (:issue:`4927`) +- Improve traceroute support for FreeBSD and macOS (:issue:`4927`) - Fix for matching minions under syndics (:issue:`7671`) - Improve exception handling for missing ID (:issue:`8259`) - Fix grain mismatch for ScientificLinux (:issue:`8338`) diff --git a/doc/topics/releases/2016.3.0.rst b/doc/topics/releases/2016.3.0.rst index 60368b043b4c..f22e70ae1e7c 100644 --- a/doc/topics/releases/2016.3.0.rst +++ b/doc/topics/releases/2016.3.0.rst @@ -107,7 +107,7 @@ Cloud Changes Platform Changes ================ -- Renamed modules related to OS X. The following module filenames were changed. +- Renamed modules related to macOS. The following module filenames were changed. The virtual name remained unchanged. - **PR** `#30558`_: renamed osxdesktop.py to mac_desktop.py diff --git a/doc/topics/troubleshooting/index.rst b/doc/topics/troubleshooting/index.rst index 86f932d41434..112ca070fb01 100644 --- a/doc/topics/troubleshooting/index.rst +++ b/doc/topics/troubleshooting/index.rst @@ -244,7 +244,7 @@ Then pass the signal to the master or minion when it seems to be unresponsive: killall -SIGUSR1 salt-master killall -SIGUSR1 salt-minion -Also under BSD and Mac OS X in addition to SIGUSR1 signal, debug subroutine set +Also under BSD and macOS in addition to SIGUSR1 signal, debug subroutine set up for SIGINFO which has an advantage of being sent by Ctrl+T shortcut. When filing an issue or sending questions to the mailing list for a problem diff --git a/doc/topics/tutorials/index.rst b/doc/topics/tutorials/index.rst index fd93b3cdb361..7bb26a60019d 100644 --- a/doc/topics/tutorials/index.rst +++ b/doc/topics/tutorials/index.rst @@ -30,6 +30,6 @@ Tutorials Index * :ref:`How to Convert Jinja Logic to an Execution Module ` * :ref:`Using Salt with Stormpath ` * :ref:`Syslog-ng usage ` -* :ref:`The MacOS X (Maverick) Developer Step By Step Guide To Salt Installation ` +* :ref:`The macOS (Maverick) Developer Step By Step Guide To Salt Installation ` * :ref:`SaltStack Walk-through ` * :ref:`Writing Salt Tests ` diff --git a/doc/topics/tutorials/walkthrough_macosx.rst b/doc/topics/tutorials/walkthrough_macosx.rst index c5e9225ef994..af5a860d7c9d 100644 --- a/doc/topics/tutorials/walkthrough_macosx.rst +++ b/doc/topics/tutorials/walkthrough_macosx.rst @@ -1,11 +1,11 @@ .. _tutorial-macos-walk-through: -======================================================================== -The MacOS X (Maverick) Developer Step By Step Guide To Salt Installation -======================================================================== +====================================================================== +The macOS (Maverick) Developer Step By Step Guide To Salt Installation +====================================================================== This document provides a step-by-step guide to installing a Salt cluster -consisting of one master, and one minion running on a local VM hosted on Mac OS X. +consisting of one master, and one minion running on a local VM hosted on macOS. .. note:: @@ -85,12 +85,12 @@ Step 1 - Configuring The Salt Master On Your Mac `official documentation `_ -Because Salt has a lot of dependencies that are not built in Mac OS X, we will -use Homebrew to install Salt. Homebrew is a package manager for Mac, it's -great, use it (for this tutorial at least!). Some people spend a lot of time -installing libs by hand to better understand dependencies, and then realize how -useful a package manager is once they're configuring a brand new machine and -have to do it all over again. It also lets you *uninstall* things easily. +Because Salt has a lot of dependencies that are not built in macOS, we will use +Homebrew to install Salt. Homebrew is a package manager for Mac, it's great, use +it (for this tutorial at least!). Some people spend a lot of time installing +libs by hand to better understand dependencies, and then realize how useful a +package manager is once they're configuring a brand new machine and have to do +it all over again. It also lets you *uninstall* things easily. .. note:: @@ -109,7 +109,7 @@ have to do it all over again. It also lets you *uninstall* things easily. .. tip:: - Use the keyboard shortcut ``cmd + shift + period`` in the "open" Mac OS X + Use the keyboard shortcut ``cmd + shift + period`` in the "open" macOS dialog box to display hidden files and folders, such as .profile. @@ -169,7 +169,7 @@ http://docs.saltstack.com/ref/configuration/examples.html#configuration-examples ``/etc/salt/master`` is a file, not a folder. Salt Master configuration changes. The Salt master needs a few customization -to be able to run on Mac OS X: +to be able to run on macOS: .. code-block:: bash @@ -216,7 +216,7 @@ Install VirtualBox ------------------ Go get it here: https://www.virtualBox.org/wiki/Downloads (click on VirtualBox -for OS X hosts => x86/amd64) +for macOS hosts => x86/amd64) Install Vagrant --------------- @@ -317,7 +317,7 @@ following: .. note:: - That ip is the ip of your VM host (the Mac OS X OS). The number is a + That ip is the ip of your VM host (the macOS host). The number is a VirtualBox default and is displayed in the log after the Vagrant ssh command. We'll use that IP to tell the minion where the Salt master is. Once you're done, end the ssh session by typing ``exit``. @@ -436,7 +436,7 @@ and then applied by running the :py:func:`state.apply ` function to have the Salt master order its minions to update their instructions and run the associated commands. -First Create an empty file on your Salt master (Mac OS X machine): +First Create an empty file on your Salt master (macOS machine): .. code-block:: bash diff --git a/pkg/osx/README.md b/pkg/osx/README.md index 3e91ca0fa88a..2111f688b369 100644 --- a/pkg/osx/README.md +++ b/pkg/osx/README.md @@ -1,36 +1,34 @@ -=============================== -Building Native Packages on OSX -=============================== +================================= +Building Native Packages on macOS +================================= -Salt runs well on the Mac, but does have some limitations. +Salt runs well on the macOS, but does have some limitations. -In this directory you will find scripts and collateral to build an OSX -.pkg-style package that uses a custom-built Python. This process has -been tested on Mac OSX Lion (10.7) and following. +In this directory you will find scripts and collateral to build a macOS +.pkg-style package that uses a custom-built Python. This process has been +tested on macOS Lion (10.7) and later. -In addition, because of changes in launchd from version -to version of the OS, a simpler approach is taken for -the launchd plist files. +In addition, because of changes in launchd from version to version of the OS, a +simpler approach is taken for the launchd plist files. -This approach enables Salt users to potentially -add items to their Salt install via 'pip install' without -interfering with the rest of their system's Python packages. +This approach enables Salt users to potentially add items to their Salt install +via 'pip install' without interfering with the rest of their system's Python +packages. To build a native package you will need the following installed: - Xcode, or the Xcode Command Line Tools - git -The native package will install package files into /opt/salt. -Configuration files will be installed to /etc, but will have -'.dist' appended to them. +The native package will install package files into /opt/salt. Configuration +files will be installed to /etc, but will have '.dist' appended to them. -Launchd plists will be placed in /Library/LaunchDaemons. By default -salt-minion will NOT be enabled or started. +Launchd plists will be placed in /Library/LaunchDaemons. By default salt-minion +will NOT be enabled or started. -The process has been automated via the ``build.sh`` script -in the directory with this README file. Checkout the Salt repo from -GitHub, chdir into the base repo directory, and run +The process has been automated via the ``build.sh`` script in the directory with +this README file. Checkout the Salt repo from GitHub, chdir into the base repo +directory, and run ./build.sh @@ -39,5 +37,3 @@ References: http://crushbeercrushcode.org/2014/01/using-pkgbuild-and-productbuild-on-os-x-10-7/ http://stackoverflow.com/questions/11487596/making-os-x-installer-packages-like-a-pro-xcode-developer-id-ready-pkg - - diff --git a/pkg/osx/build.sh b/pkg/osx/build.sh index 213865c0aec7..e304248328a5 100755 --- a/pkg/osx/build.sh +++ b/pkg/osx/build.sh @@ -1,12 +1,12 @@ #!/bin/bash ############################################################################ # -# Title: Build Salt Script for OSX +# Title: Build Salt Script for macOS # Authors: CR Oldham, Shane Lee # Date: December 2015 # # Description: This script downloads and installs all dependencies and build -# tools required to create a .pkg file for installation on OSX. +# tools required to create a .pkg file for installation on macOS. # Salt and all dependencies will be installed to /opt/salt. A # .pkg file will then be created based on the contents of # /opt/salt @@ -57,7 +57,7 @@ PKGRESOURCES=$SRCDIR/pkg/osx ############################################################################ if [[ ! -e "$SRCDIR/.git" ]] && [[ ! -e "$SRCDIR/scripts/salt" ]]; then echo "This directory doesn't appear to be a git repository." - echo "The OS X build process needs some files from a Git checkout of Salt." + echo "The macOS build process needs some files from a Git checkout of Salt." echo "Run this script from the root of the Git checkout." exit -1 fi diff --git a/pkg/osx/build_env.sh b/pkg/osx/build_env.sh index d63a0c93ea8a..2b236b8fc674 100755 --- a/pkg/osx/build_env.sh +++ b/pkg/osx/build_env.sh @@ -2,11 +2,11 @@ ############################################################################ # -# Title: Build Environment Script for OSX +# Title: Build Environment Script for macOS # Authors: CR Oldham, Shane Lee # Date: December 2015 # -# Description: This script sets up a build environment for salt on OSX. +# Description: This script sets up a build environment for salt on macOS. # # Requirements: # - XCode Command Line Tools (xcode-select --install) @@ -15,7 +15,7 @@ # This script is not passed any parameters # # Example: -# The following will set up a build environment for salt on OSX +# The following will set up a build environment for salt on macOS # # ./dev_env.sh # diff --git a/pkg/osx/build_pkg.sh b/pkg/osx/build_pkg.sh index ac1f64a12e52..86ad9aa450cf 100755 --- a/pkg/osx/build_pkg.sh +++ b/pkg/osx/build_pkg.sh @@ -1,11 +1,11 @@ #!/bin/bash ############################################################################ # -# Title: Build Package Script for OSX +# Title: Build Package Script for macOS # Authors: CR Oldham, Shane Lee # Date: December 2015 # -# Description: This creates an OSX package for Salt from the contents of +# Description: This creates an macOS package for Salt from the contents of # /opt/salt # # Requirements: @@ -67,7 +67,7 @@ PKGRESOURCES=$SRCDIR/pkg/osx ############################################################################ if [[ ! -e "$SRCDIR/.git" ]] && [[ ! -e "$SRCDIR/scripts/salt" ]]; then echo "This directory doesn't appear to be a git repository." - echo "The OS X build process needs some files from a Git checkout of Salt." + echo "The macOS build process needs some files from a Git checkout of Salt." echo "Run this script from the 'pkg/osx' directory of the Git checkout." exit -1 fi diff --git a/pkg/osx/build_sig.sh b/pkg/osx/build_sig.sh index 6dc5373baca5..a68c821d9b99 100755 --- a/pkg/osx/build_sig.sh +++ b/pkg/osx/build_sig.sh @@ -1,11 +1,11 @@ #!/bin/bash ############################################################################ # -# Title: Sign Package Script for OSX +# Title: Sign Package Script for macOS # Authors: Shane Lee # Date: December 2015 # -# Description: This signs an OSX Installer Package (.pkg) +# Description: This signs an macOS Installer Package (.pkg) # /opt/salt # # Requirements: diff --git a/pkg/osx/pkg-scripts/postinstall b/pkg/osx/pkg-scripts/postinstall index c3f1f7e6643c..89404e2158e0 100755 --- a/pkg/osx/pkg-scripts/postinstall +++ b/pkg/osx/pkg-scripts/postinstall @@ -12,7 +12,7 @@ # - None # # Usage: -# This script is run as a part of the OSX Salt Installation +# This script is run as a part of the macOS Salt Installation # ############################################################################### echo "Post install started on:" > /tmp/postinstall.txt diff --git a/pkg/osx/pkg-scripts/preinstall b/pkg/osx/pkg-scripts/preinstall index d649072c0ecd..e9a12c7c9aec 100755 --- a/pkg/osx/pkg-scripts/preinstall +++ b/pkg/osx/pkg-scripts/preinstall @@ -6,13 +6,13 @@ # Date: December 2015 # # Description: This script stops the salt minion service before attempting to -# install Salt on Mac OSX +# install Salt on macOS # # Requirements: # - None # # Usage: -# This script is run as a part of the OSX Salt Installation +# This script is run as a part of the macOS Salt Installation # ############################################################################### echo "Preinstall started on:" > /tmp/preinstall.txt diff --git a/salt/beacons/inotify.py b/salt/beacons/inotify.py index 40df4d2a0f42..728a89efc726 100644 --- a/salt/beacons/inotify.py +++ b/salt/beacons/inotify.py @@ -11,7 +11,7 @@ the beacon configuration. :note: The `inotify` beacon only works on OSes that have `inotify` kernel support. - Currently this excludes FreeBSD, Mac OS X, and Windows. + Currently this excludes FreeBSD, macOS, and Windows. ''' # Import Python libs diff --git a/salt/cli/key.py b/salt/cli/key.py index d89c3c3b174a..1454a2b43c48 100644 --- a/salt/cli/key.py +++ b/salt/cli/key.py @@ -2,6 +2,7 @@ from __future__ import print_function from __future__ import absolute_import + from salt.utils import parsers from salt.utils.verify import check_user, verify_log diff --git a/salt/cli/salt.py b/salt/cli/salt.py index e9a995ecd5cd..591386113051 100644 --- a/salt/cli/salt.py +++ b/salt/cli/salt.py @@ -2,8 +2,9 @@ # Import python libs from __future__ import absolute_import, print_function -import os import sys +sys.modules['pkg_resources'] = None +import os # Import Salt libs from salt.ext.six import string_types diff --git a/salt/cloud/clouds/gogrid.py b/salt/cloud/clouds/gogrid.py index a1779c3aac20..285600e4c9ee 100644 --- a/salt/cloud/clouds/gogrid.py +++ b/salt/cloud/clouds/gogrid.py @@ -321,10 +321,11 @@ def list_passwords(kwargs=None, call=None): ret = {} for item in response['list']: - server = item['server']['name'] - if server not in ret: - ret[server] = [] - ret[server].append(item) + if 'server' in item: + server = item['server']['name'] + if server not in ret: + ret[server] = [] + ret[server].append(item) return ret diff --git a/salt/grains/core.py b/salt/grains/core.py index 6a7ea8d8dfaa..93571401e2e7 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -1045,7 +1045,7 @@ def _windows_platform_data(): def _osx_platform_data(): ''' - Additional data for Mac OS X systems + Additional data for macOS systems Returns: A dictionary containing values for the following: - model_name - boot_rom_version diff --git a/salt/master.py b/salt/master.py index ac003c99223d..da2722f84fbb 100644 --- a/salt/master.py +++ b/salt/master.py @@ -400,7 +400,7 @@ def __set_max_open_files(self): # Let's check to see how our max open files(ulimit -n) setting is mof_s, mof_h = resource.getrlimit(resource.RLIMIT_NOFILE) if mof_h == resource.RLIM_INFINITY: - # Unclear what to do with infinity... OSX reports RLIM_INFINITY as + # Unclear what to do with infinity... macOS reports RLIM_INFINITY as # hard limit,but raising to anything above soft limit fails... mof_h = mof_s log.info( @@ -433,7 +433,7 @@ def __set_max_open_files(self): ) except ValueError: # https://github.com/saltstack/salt/issues/1991#issuecomment-13025595 - # A user under OSX reported that our 100000 default value is + # A user under macOS reported that our 100000 default value is # still too high. log.critical( 'Failed to raise max open files setting to {0}. If this ' diff --git a/salt/modules/boto_kms.py b/salt/modules/boto_kms.py index 9c9ca9403568..233c6bc97190 100644 --- a/salt/modules/boto_kms.py +++ b/salt/modules/boto_kms.py @@ -64,7 +64,7 @@ # pylint: enable=unused-import logging.getLogger('boto').setLevel(logging.CRITICAL) HAS_BOTO = True -except ImportError: +except (ImportError, AttributeError): HAS_BOTO = False diff --git a/salt/modules/launchctl.py b/salt/modules/launchctl.py index def9ec69d865..62ed41cfd116 100644 --- a/salt/modules/launchctl.py +++ b/salt/modules/launchctl.py @@ -39,7 +39,7 @@ def __virtual__(): ''' if not salt.utils.is_darwin(): return (False, 'Failed to load the mac_service module:\n' - 'Only available on Mac OS X systems.') + 'Only available on macOS systems.') if not os.path.exists('/bin/launchctl'): return (False, 'Failed to load the mac_service module:\n' diff --git a/salt/modules/mac_assistive.py b/salt/modules/mac_assistive.py index 4586476a8a2a..8bfa5b11b50a 100644 --- a/salt/modules/mac_assistive.py +++ b/salt/modules/mac_assistive.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -This module allows you to manage assistive access on OS X minions with 10.9+ +This module allows you to manage assistive access on macOS minions with 10.9+ .. versionadded:: 2016.3.0 @@ -30,7 +30,8 @@ def __virtual__(): ''' if salt.utils.is_darwin() and LooseVersion(__grains__['osrelease']) >= '10.9': return True - return False, 'The assistive module cannot be loaded: must be run on OSX 10.9 or newer.' + return False, 'The assistive module cannot be loaded: must be run on ' \ + 'macOS 10.9 or newer.' def install(app_id, enable=True): diff --git a/salt/modules/mac_brew.py b/salt/modules/mac_brew.py index f545dbd393fe..8f5fa7b90e9e 100644 --- a/salt/modules/mac_brew.py +++ b/salt/modules/mac_brew.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Homebrew for Mac OS X +Homebrew for macOS .. important:: If you feel that Salt should be using this module to manage packages on a diff --git a/salt/modules/mac_desktop.py b/salt/modules/mac_desktop.py index f84061e9243e..d9c77845c6cf 100644 --- a/salt/modules/mac_desktop.py +++ b/salt/modules/mac_desktop.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Mac OS X implementations of various commands in the "desktop" interface +macOS implementations of various commands in the "desktop" interface ''' from __future__ import absolute_import @@ -18,7 +18,7 @@ def __virtual__(): ''' if salt.utils.is_darwin(): return __virtualname__ - return False, 'Cannot load OSX desktop module: This is not an OSX host.' + return False, 'Cannot load macOS desktop module: This is not a macOS host.' def get_output_volume(): diff --git a/salt/modules/mac_package.py b/salt/modules/mac_package.py index 8bc3342a3008..287689187f15 100644 --- a/salt/modules/mac_package.py +++ b/salt/modules/mac_package.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Install pkg, dmg and .app applications on Mac OS X minions. +Install pkg, dmg and .app applications on macOS minions. ''' diff --git a/salt/modules/mac_pkgutil.py b/salt/modules/mac_pkgutil.py index fc0828bba7c7..1626e73644f5 100644 --- a/salt/modules/mac_pkgutil.py +++ b/salt/modules/mac_pkgutil.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ''' -Installer support for OS X. +Installer support for macOS. -Installer is the native .pkg/.mpkg package manager for OS X. +Installer is the native .pkg/.mpkg package manager for macOS. ''' # Import Python libs diff --git a/salt/modules/mac_ports.py b/salt/modules/mac_ports.py index fbe328826921..ed450b3c5675 100644 --- a/salt/modules/mac_ports.py +++ b/salt/modules/mac_ports.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Support for MacPorts under Mac OSX. +Support for MacPorts under macOS. This module has some caveats. diff --git a/salt/modules/mac_power.py b/salt/modules/mac_power.py index d8cf7943561a..d7e09dce19c8 100644 --- a/salt/modules/mac_power.py +++ b/salt/modules/mac_power.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Module for editing power settings on Mac OS X +Module for editing power settings on macOS .. versionadded:: 2016.3.0 ''' @@ -18,11 +18,11 @@ def __virtual__(): ''' - Only for Mac OS X + Only for macOS ''' if not salt.utils.is_darwin(): return (False, 'The mac_power module could not be loaded: ' - 'module only works on Mac OS X systems.') + 'module only works on macOS systems.') return __virtualname__ @@ -423,7 +423,7 @@ def set_restart_freeze(enabled): ''' Specifies whether the server restarts automatically after a system freeze. This setting doesn't seem to be editable. The command completes successfully - but the setting isn't actually updated. This is probably an OS X bug. The + but the setting isn't actually updated. This is probably a macOS. The functions remains in case they ever fix the bug. :param bool enabled: True to enable, False to disable. "On" and "Off" are diff --git a/salt/modules/mac_service.py b/salt/modules/mac_service.py index 64f25d46936d..227f199cc148 100644 --- a/salt/modules/mac_service.py +++ b/salt/modules/mac_service.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -The service module for Mac OS X +The service module for macOS .. versionadded:: 2016.3.0 ''' from __future__ import absolute_import @@ -29,11 +29,11 @@ def __virtual__(): ''' - Only for Mac OS X with launchctl + Only for macOS with launchctl ''' if not salt.utils.is_darwin(): return (False, 'Failed to load the mac_service module:\n' - 'Only available on Mac OS X systems.') + 'Only available on macOS systems.') if not salt.utils.which('launchctl'): return (False, 'Failed to load the mac_service module:\n' @@ -45,7 +45,7 @@ def __virtual__(): if LooseVersion(__grains__['osrelease']) < LooseVersion('10.11'): return (False, 'Failed to load the mac_service module:\n' - 'Requires OS X 10.11 or newer') + 'Requires macOS 10.11 or newer') return __virtualname__ @@ -308,7 +308,7 @@ def start(name, runas=None): Start a launchd service. Raises an error if the service fails to start .. note:: - To start a service in Mac OS X the service must be enabled first. Use + To start a service in macOS the service must be enabled first. Use ``service.enable`` to enable the service. :param str name: Service label, file name, or full path @@ -337,7 +337,7 @@ def stop(name, runas=None): Stop a launchd service. Raises an error if the service fails to stop .. note:: - Though ``service.stop`` will unload a service in Mac OS X, the service + Though ``service.stop`` will unload a service in macOS, the service will start on next boot unless it is disabled. Use ``service.disable`` to disable the service diff --git a/salt/modules/mac_shadow.py b/salt/modules/mac_shadow.py index 0e40004fefa4..d434f87e09ff 100644 --- a/salt/modules/mac_shadow.py +++ b/salt/modules/mac_shadow.py @@ -2,7 +2,7 @@ ''' .. versionadded:: 2016.3.0 -Manage Mac OSX local directory passwords and policies. +Manage macOS local directory passwords and policies. Note that it is usually better to apply password policies through the creation of a configuration profile. @@ -32,9 +32,9 @@ def __virtual__(): - # Is this os x? + # Is this macOS? if not salt.utils.is_darwin(): - return False, 'Not Darwin' + return False, 'Not macOS' if HAS_PWD: return __virtualname__ @@ -339,13 +339,13 @@ def get_maxdays(name): def set_mindays(name, days): ''' - Set the minimum password age in days. Not available in OS X. + Set the minimum password age in days. Not available in macOS. :param str name: The user name :param int days: The number of days - :return: Will always return False until OSX supports this feature. + :return: Will always return False until macOS supports this feature. :rtype: bool CLI Example: @@ -360,13 +360,13 @@ def set_mindays(name, days): def set_inactdays(name, days): ''' Set the number if inactive days before the account is locked. Not available - in OS X + in macOS :param str name: The user name :param int days: The number of days - :return: Will always return False until OSX supports this feature. + :return: Will always return False until macOS supports this feature. :rtype: bool CLI Example: @@ -381,13 +381,13 @@ def set_inactdays(name, days): def set_warndays(name, days): ''' Set the number of days before the password expires that the user will start - to see a warning. Not available in OS X + to see a warning. Not available in macOS :param str name: The user name :param int days: The number of days - :return: Will always return False until OSX supports this feature. + :return: Will always return False until macOS supports this feature. :rtype: bool CLI Example: diff --git a/salt/modules/mac_sysctl.py b/salt/modules/mac_sysctl.py index fe9166647ad2..1075dcc46d99 100644 --- a/salt/modules/mac_sysctl.py +++ b/salt/modules/mac_sysctl.py @@ -17,12 +17,12 @@ def __virtual__(): ''' - Only run on Darwin (OS X) systems + Only run on Darwin (macOS) systems ''' if __grains__['os'] == 'MacOS': return __virtualname__ return (False, 'The darwin_sysctl execution module cannot be loaded: ' - 'only available on MacOS systems.') + 'Only available on macOS systems.') def show(config_file=False): diff --git a/salt/modules/mac_system.py b/salt/modules/mac_system.py index 3d9a991fb6f1..1b4e22c645af 100644 --- a/salt/modules/mac_system.py +++ b/salt/modules/mac_system.py @@ -603,7 +603,7 @@ def set_boot_arch(arch='default'): The setting is not updated. This is either an apple bug, not available on the test system, or a result of system files now being locked down in - OS X (SIP Protection). + macOS (SIP Protection). :param str arch: A string representing the desired architecture. If no value is passed, default is assumed. Valid values include: diff --git a/salt/modules/mac_timezone.py b/salt/modules/mac_timezone.py index 3f2ef3c57467..ab5528a12063 100644 --- a/salt/modules/mac_timezone.py +++ b/salt/modules/mac_timezone.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Module for editing date/time settings on Mac OS X +Module for editing date/time settings on macOS .. versionadded:: 2016.3.0 ''' @@ -19,11 +19,11 @@ def __virtual__(): ''' - Only for Mac OS X + Only for macOS ''' if not salt.utils.is_darwin(): return (False, 'The mac_timezone module could not be loaded: ' - 'module only works on Mac OS X systems.') + 'module only works on macOS systems.') return __virtualname__ @@ -333,7 +333,7 @@ def set_time_server(time_server='time.apple.com'): network time server. :param time_server: IP or DNS name of the network time server. If nothing is - passed the time server will be set to the OS X default of 'time.apple.com' + passed the time server will be set to the macOS default of 'time.apple.com' :type: str :return: True if successful, False if not diff --git a/salt/modules/network.py b/salt/modules/network.py index 62c0ca9df82e..6f584115caf7 100644 --- a/salt/modules/network.py +++ b/salt/modules/network.py @@ -378,7 +378,7 @@ def _netstat_route_linux(): def _netstat_route_freebsd(): ''' - Return netstat routing information for FreeBSD and OS X + Return netstat routing information for FreeBSD and macOS ''' ret = [] cmd = 'netstat -f inet -rn | tail -n+5' diff --git a/salt/modules/npm.py b/salt/modules/npm.py index 09660a10c45d..f4454c3357c2 100644 --- a/salt/modules/npm.py +++ b/salt/modules/npm.py @@ -185,7 +185,7 @@ def _extract_json(npm_output): lines = lines[1:] while lines and not lines[-1].startswith('}') and not lines[-1].startswith(']'): lines = lines[:-1] - # Mac OSX with fsevents includes the following line in the return + # macOS with fsevents includes the following line in the return # when a new module is installed which is invalid JSON: # [fsevents] Success: "..." while lines and lines[0].startswith('[fsevents]'): diff --git a/salt/modules/osquery.py b/salt/modules/osquery.py index 9fb74cc8d962..137125f070f0 100644 --- a/salt/modules/osquery.py +++ b/salt/modules/osquery.py @@ -29,7 +29,7 @@ def __virtual__(): if salt.utils.which('osqueryi'): return __virtualname__ return (False, 'The osquery execution module cannot be loaded: ' - 'osqueryi binary is not in the path.') + 'osqueryi binary is not in the path.') def _table_attrs(table): @@ -659,7 +659,7 @@ def alf(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='alf', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def alf_exceptions(attrs=None, where=None): @@ -674,7 +674,7 @@ def alf_exceptions(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='alf_exceptions', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def alf_explicit_auths(attrs=None, where=None): @@ -689,7 +689,7 @@ def alf_explicit_auths(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='alf_explicit_auths', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def alf_services(attrs=None, where=None): @@ -704,7 +704,7 @@ def alf_services(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='alf_services', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def apps(attrs=None, where=None): @@ -719,7 +719,7 @@ def apps(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='apps', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def certificates(attrs=None, where=None): @@ -734,7 +734,7 @@ def certificates(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='certificates', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def chrome_extensions(attrs=None, where=None): @@ -749,7 +749,7 @@ def chrome_extensions(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='chrome_extensions', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def firefox_addons(attrs=None, where=None): @@ -764,7 +764,7 @@ def firefox_addons(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='firefox_addons', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def homebrew_packages(attrs=None, where=None): @@ -779,7 +779,7 @@ def homebrew_packages(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='homebrew_packages', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def iokit_devicetree(attrs=None, where=None): @@ -794,7 +794,7 @@ def iokit_devicetree(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='iokit_devicetree', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def iokit_registry(attrs=None, where=None): @@ -809,7 +809,7 @@ def iokit_registry(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='iokit_registry', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def kernel_extensions(attrs=None, where=None): @@ -824,7 +824,7 @@ def kernel_extensions(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='kernel_extensions', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def keychain_items(attrs=None, where=None): @@ -839,7 +839,7 @@ def keychain_items(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='keychain_items', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def launchd(attrs=None, where=None): @@ -854,7 +854,7 @@ def launchd(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='launchd', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def nfs_shares(attrs=None, where=None): @@ -869,7 +869,7 @@ def nfs_shares(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='nfs_shares', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def nvram(attrs=None, where=None): @@ -884,7 +884,7 @@ def nvram(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='nvram', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def preferences(attrs=None, where=None): @@ -899,7 +899,7 @@ def preferences(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='preferences', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def quarantine(attrs=None, where=None): @@ -914,7 +914,7 @@ def quarantine(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='quarantine', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def safari_extensions(attrs=None, where=None): @@ -929,7 +929,7 @@ def safari_extensions(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='safari_extensions', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def startup_items(attrs=None, where=None): @@ -944,7 +944,7 @@ def startup_items(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='startup_items', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def xattr_where_from(attrs=None, where=None): @@ -959,7 +959,7 @@ def xattr_where_from(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='xattr_where_from', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def xprotect_entries(attrs=None, where=None): @@ -974,7 +974,7 @@ def xprotect_entries(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='xprotect_entries', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def xprotect_reports(attrs=None, where=None): @@ -989,7 +989,7 @@ def xprotect_reports(attrs=None, where=None): ''' if salt.utils.is_darwin(): return _osquery_cmd(table='xprotect_reports', attrs=attrs, where=where) - return {'result': False, 'comment': 'Only available on OS X systems.'} + return {'result': False, 'comment': 'Only available on macOS systems.'} def file_(attrs=None, where=None): diff --git a/salt/modules/proxy.py b/salt/modules/proxy.py index 6fe2bdca19fc..cc0c28abb3a9 100644 --- a/salt/modules/proxy.py +++ b/salt/modules/proxy.py @@ -128,7 +128,8 @@ def get_http_proxy(network_service="Ethernet"): Returns the current http proxy settings network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS CLI Example: @@ -160,7 +161,8 @@ def set_http_proxy(server, port, user=None, password=None, network_service="Ethe The password to use if required by the server network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS bypass_hosts The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use @@ -183,7 +185,8 @@ def get_https_proxy(network_service="Ethernet"): Returns the current https proxy settings network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS CLI Example: @@ -215,7 +218,8 @@ def set_https_proxy(server, port, user=None, password=None, network_service="Eth The password to use if required by the server network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS bypass_hosts The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use @@ -238,7 +242,8 @@ def get_ftp_proxy(network_service="Ethernet"): Returns the current ftp proxy settings network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS CLI Example: @@ -269,7 +274,8 @@ def set_ftp_proxy(server, port, user=None, password=None, network_service="Ether The password to use if required by the server network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS bypass_hosts The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use @@ -292,7 +298,8 @@ def get_proxy_bypass(network_service="Ethernet"): Returns the current domains that can bypass the proxy network_service - The network service to get the bypass domains from, this is only necessary on OSX + The network service to get the bypass domains from, this is only + necessary on macOS CLI Example: @@ -322,7 +329,8 @@ def set_proxy_bypass(domains, network_service="Ethernet"): An array of domains allowed to bypass the proxy network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS CLI Example: diff --git a/salt/modules/rbenv.py b/salt/modules/rbenv.py index 5125479355d9..cdae6e9d9af4 100644 --- a/salt/modules/rbenv.py +++ b/salt/modules/rbenv.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Manage ruby installations with rbenv. rbenv is supported on Linux and Mac OS X. +Manage ruby installations with rbenv. rbenv is supported on Linux and macOS. rbenv doesn't work on Windows (and isn't really necessary on Windows as there is no system Ruby on Windows). On Windows, the RubyInstaller and/or Pik are both good alternatives to work with multiple versions of Ruby on the same box. diff --git a/salt/modules/system_profiler.py b/salt/modules/system_profiler.py index 7c2da3bef7b1..31e0b8efe36e 100644 --- a/salt/modules/system_profiler.py +++ b/salt/modules/system_profiler.py @@ -2,7 +2,7 @@ ''' System Profiler Module -Interface with Mac OSX's command-line System Profiler utility to get +Interface with macOS's command-line System Profiler utility to get information about package receipts and installed applications. .. versionadded:: 2015.5.0 diff --git a/salt/modules/timezone.py b/salt/modules/timezone.py index 724458fd32f4..a983f98beea4 100644 --- a/salt/modules/timezone.py +++ b/salt/modules/timezone.py @@ -33,7 +33,7 @@ def __virtual__(): if salt.utils.is_darwin(): return (False, 'The timezone execution module failed to load: ' - 'mac_timezone.py should replace this module on OS X.' + 'mac_timezone.py should replace this module on macOS.' 'There was a problem loading mac_timezone.py.') return __virtualname__ diff --git a/salt/modules/win_file.py b/salt/modules/win_file.py index aa3a2d3a1e02..94c88744505b 100644 --- a/salt/modules/win_file.py +++ b/salt/modules/win_file.py @@ -27,6 +27,7 @@ import errno # do not remove, used in imported file.py functions import shutil # do not remove, used in imported file.py functions import re # do not remove, used in imported file.py functions +import string # do not remove, used in imported file.py functions import sys # do not remove, used in imported file.py functions import fileinput # do not remove, used in imported file.py functions import fnmatch # do not remove, used in imported file.py functions diff --git a/salt/modules/win_service.py b/salt/modules/win_service.py index 6d156ad9e3cc..47e1e8441aa7 100644 --- a/salt/modules/win_service.py +++ b/salt/modules/win_service.py @@ -92,9 +92,11 @@ def __virtual__(): Only works on Windows systems with PyWin32 installed ''' if not salt.utils.is_windows(): - return (False, 'Module win_service: module only works on Windows.') + return False, 'Module win_service: module only works on Windows.' + if not HAS_WIN32_MODS: - return (False, 'Module win_service: failed to load win32 modules') + return False, 'Module win_service: failed to load win32 modules' + return __virtualname__ @@ -654,13 +656,15 @@ def modify(name, ''' # https://msdn.microsoft.com/en-us/library/windows/desktop/ms681987(v=vs.85).aspx # https://msdn.microsoft.com/en-us/library/windows/desktop/ms681988(v-vs.85).aspx - handle_scm = win32service.OpenSCManager( None, None, win32service.SC_MANAGER_CONNECT) try: handle_svc = win32service.OpenService( - handle_scm, name, win32service.SERVICE_ALL_ACCESS) + handle_scm, + name, + win32service.SERVICE_CHANGE_CONFIG | + win32service.SERVICE_QUERY_CONFIG) except pywintypes.error as exc: raise CommandExecutionError( 'Failed To Open {0}: {1}'.format(name, exc[2])) diff --git a/salt/pillar/stack.py b/salt/pillar/stack.py index 3d5d7104c503..09159ba4a4ca 100644 --- a/salt/pillar/stack.py +++ b/salt/pillar/stack.py @@ -105,7 +105,9 @@ files that will then be merged to build pillar data. The path of these ``yaml`` files must be relative to the directory of the -PillarStack config file. +PillarStack config file. These paths support unix style pathname pattern +expansion through the +`Python glob module `. The following variables are available in jinja2 templating of PillarStack configuration files: @@ -128,6 +130,7 @@ $ cat /path/to/stack/config.cfg core.yml + common/*.yml osarchs/{{ __grains__['osarch'] }}.yml oscodenames/{{ __grains__['oscodename'] }}.yml {%- for role in pillar.get('roles', []) %} @@ -143,6 +146,9 @@ /path/to/stack/ ├── config.cfg ├── core.yml + ├── common/ + │   ├── xxx.yml + │   └── yyy.yml ├── osarchs/ │   ├── amd64.yml │   └── armhf.yml @@ -164,6 +170,8 @@ the following ``yaml`` files would be merged in order: - ``core.yml`` +- ``common/xxx.yml`` +- ``common/yyy.yml`` - ``osarchs/amd64.yml`` - ``oscodenames/jessie.yml`` - ``roles/db.yml`` @@ -371,11 +379,14 @@ import os import logging from functools import partial +from glob import glob + import yaml -from jinja2 import FileSystemLoader, Environment, TemplateNotFound +from jinja2 import FileSystemLoader, Environment # Import Salt libs import salt.ext.six as six +import salt.utils log = logging.getLogger(__name__) @@ -383,7 +394,6 @@ def ext_pillar(minion_id, pillar, *args, **kwargs): - import salt.utils stack = {} stack_config_files = list(args) traverse = { @@ -417,28 +427,30 @@ def _process_stack_cfg(cfg, stack, minion_id, pillar): "__opts__": __opts__, "__salt__": __salt__, "__grains__": __grains__, + "__stack__": { + 'traverse': salt.utils.traverse_dict_and_list + }, "minion_id": minion_id, "pillar": pillar, }) - for path in _parse_stack_cfg(jenv.get_template(filename).render(stack=stack)): - try: + for item in _parse_stack_cfg( + jenv.get_template(filename).render(stack=stack)): + if not item.strip(): + continue # silently ignore whitespace or empty lines + paths = glob(os.path.join(basedir, item)) + if not paths: + log.warning('Ignoring pillar stack template "{0}": can\'t find from ' + 'root dir "{1}"'.format(item, basedir)) + continue + for path in sorted(paths): log.debug('YAML: basedir={0}, path={1}'.format(basedir, path)) - obj = yaml.safe_load(jenv.get_template(path).render(stack=stack)) + obj = yaml.safe_load(jenv.get_template( + os.path.relpath(path, basedir)).render(stack=stack)) if not isinstance(obj, dict): log.info('Ignoring pillar stack template "{0}": Can\'t parse ' 'as a valid yaml dictionary'.format(path)) continue stack = _merge_dict(stack, obj) - except TemplateNotFound as e: - if hasattr(e, 'name') and e.name != path: - log.info('Jinja include file "{0}" not found ' - 'from root dir "{1}", which was included ' - 'by stack template "{2}"'.format( - e.name, basedir, path)) - else: - log.info('Ignoring pillar stack template "{0}": can\'t find from ' - 'root dir "{1}"'.format(path, basedir)) - continue return stack diff --git a/salt/proxy/napalm.py b/salt/proxy/napalm.py index e6337761cfeb..18ee9afced37 100644 --- a/salt/proxy/napalm.py +++ b/salt/proxy/napalm.py @@ -81,6 +81,8 @@ except ImportError: HAS_NAPALM = False +from salt.ext import six as six + # ---------------------------------------------------------------------------------------------------------------------- # proxy properties # ---------------------------------------------------------------------------------------------------------------------- @@ -281,6 +283,14 @@ def call(method, **params): if not NETWORK_DEVICE.get('UP', False): raise Exception('not connected') # if connected will try to execute desired command + # but lets clean the kwargs first + params_copy = {} + params_copy.update(params) + for karg, warg in six.iteritems(params_copy): + # will remove None values + # thus the NAPALM methods will be called with their defaults + if warg is None: + params.pop(karg) out = getattr(NETWORK_DEVICE.get('DRIVER'), method)(**params) # calls the method with the specified parameters result = True except Exception as error: diff --git a/salt/runners/state.py b/salt/runners/state.py index 24b88071aa83..cc6029e30bf6 100644 --- a/salt/runners/state.py +++ b/salt/runners/state.py @@ -203,7 +203,7 @@ def event(tagmatch='*', # Watch the event bus forever in a shell while-loop. salt-run state.event | while read -r tag data; do echo $tag - echo $data | jq -colour-output . + echo $data | jq --color-output . done .. seealso:: diff --git a/salt/states/kapacitor.py b/salt/states/kapacitor.py index b1afa1928d57..0cb66ea0265c 100644 --- a/salt/states/kapacitor.py +++ b/salt/states/kapacitor.py @@ -72,16 +72,26 @@ def task_present(name, with salt.utils.fopen(script_path, 'r') as file: new_script = file.read().replace('\t', ' ') - if old_script == new_script: + is_up_to_date = task and ( + old_script == new_script and + task_type == task['type'] and + task['dbrps'] == [{'db': database, 'rp': retention_policy}] + ) + + if is_up_to_date: comments.append('Task script is already up-to-date') else: if __opts__['test']: ret['result'] = None comments.append('Task would have been updated') else: - result = __salt__['kapacitor.define_task'](name, script_path, - task_type=task_type, database=database, - retention_policy=retention_policy) + result = __salt__['kapacitor.define_task']( + name, + script_path, + task_type=task_type, + database=database, + retention_policy=retention_policy + ) ret['result'] = result['success'] if not ret['result']: comments.append('Could not define task') @@ -89,12 +99,25 @@ def task_present(name, comments.append(result['stderr']) ret['comment'] = '\n'.join(comments) return ret - ret['changes']['TICKscript diff'] = '\n'.join(difflib.unified_diff( - old_script.splitlines(), - new_script.splitlines(), - lineterm='' - )) - comments.append('Task script updated') + + if old_script != new_script: + ret['changes']['TICKscript diff'] = '\n'.join(difflib.unified_diff( + old_script.splitlines(), + new_script.splitlines(), + )) + comments.append('Task script updated') + + if not task or task['type'] != task_type: + ret['changes']['type'] = task_type + comments.append('Task type updated') + + if not task or task['dbrps'][0]['db'] != database: + ret['changes']['db'] = database + comments.append('Task database updated') + + if not task or task['dbrps'][0]['rp'] != retention_policy: + ret['changes']['rp'] = retention_policy + comments.append('Task retention policy updated') if enable: if task and task['enabled']: diff --git a/salt/states/mac_assistive.py b/salt/states/mac_assistive.py index a2e59a0d4d28..d5375deb8b9f 100644 --- a/salt/states/mac_assistive.py +++ b/salt/states/mac_assistive.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- ''' -Allows you to manage assistive access on OS X minions with 10.9+ -================================================================ +Allows you to manage assistive access on macOS minions with 10.9+ +================================================================= -Install, enable and disable assitive access on OS X minions +Install, enable and disable assistive access on macOS minions .. code-block:: yaml diff --git a/salt/states/mac_defaults.py b/salt/states/mac_defaults.py index 394865d5091f..0eee644753f9 100644 --- a/salt/states/mac_defaults.py +++ b/salt/states/mac_defaults.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ''' -Writing/reading defaults from an OS X minion +Writing/reading defaults from a macOS minion ============================================ ''' diff --git a/salt/states/mac_keychain.py b/salt/states/mac_keychain.py index 6c748b614289..e67a99a40351 100644 --- a/salt/states/mac_keychain.py +++ b/salt/states/mac_keychain.py @@ -3,7 +3,7 @@ Installing of certificates to the keychain ========================================== -Install certificats to the OS X keychain +Install certificats to the macOS keychain .. code-block:: yaml @@ -35,7 +35,7 @@ def __virtual__(): def installed(name, password, keychain="/Library/Keychains/System.keychain", **kwargs): ''' - Install a p12 certificate file into the OS X keychain + Install a p12 certificate file into the macOS keychain name The certificate to install @@ -100,7 +100,7 @@ def installed(name, password, keychain="/Library/Keychains/System.keychain", **k def uninstalled(name, password, keychain="/Library/Keychains/System.keychain", keychain_password=None): ''' - Uninstall a p12 certificate file from the OS X keychain + Uninstall a p12 certificate file from the macOS keychain name The certificate to uninstall, this can be a path for a .p12 or the friendly diff --git a/salt/states/mac_package.py b/salt/states/mac_package.py index 8aa702abb9cc..ed7dae040374 100644 --- a/salt/states/mac_package.py +++ b/salt/states/mac_package.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- ''' Installing of mac pkg files -======================= +=========================== -Install any kind of pkg, dmg or app file on Mac OS X: +Install any kind of pkg, dmg or app file on macOS: .. code-block:: yaml diff --git a/salt/states/mac_xattr.py b/salt/states/mac_xattr.py index bdedbf22362c..10960e8daa2a 100644 --- a/salt/states/mac_xattr.py +++ b/salt/states/mac_xattr.py @@ -3,7 +3,7 @@ Allows you to manage extended attributes on files or directories ================================================================ -Install, enable and disable assitive access on OS X minions +Install, enable and disable assistive access on macOS minions .. code-block:: yaml diff --git a/salt/states/proxy.py b/salt/states/proxy.py index cbdd1eb221dc..f284d4e5ee37 100644 --- a/salt/states/proxy.py +++ b/salt/states/proxy.py @@ -59,7 +59,8 @@ def managed(name, port, services=None, user=None, password=None, bypass_domains= An array of the domains that should bypass the proxy network_service - The network service to apply the changes to, this only necessary on OSX + The network service to apply the changes to, this only necessary on + macOS ''' ret = {'name': name, 'result': True, diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 243c66c6692a..67e5faf3e3ac 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -1662,7 +1662,7 @@ def is_linux(): @real_memoize def is_darwin(): ''' - Simple function to return if a host is Darwin (OS X) or not + Simple function to return if a host is Darwin (macOS) or not ''' return sys.platform.startswith('darwin') diff --git a/salt/utils/win_functions.py b/salt/utils/win_functions.py index 3e18b2f784aa..73e2eb999c2d 100644 --- a/salt/utils/win_functions.py +++ b/salt/utils/win_functions.py @@ -6,9 +6,6 @@ from __future__ import absolute_import from salt.exceptions import CommandExecutionError -# Import Salt Libs -import salt.utils - # Import 3rd Party Libs try: import psutil @@ -21,12 +18,12 @@ HAS_WIN32 = False +# Although utils are often directly imported, it is also possible to use the +# loader. def __virtual__(): ''' - Load only on Windows with necessary modules + Only load if Win32 Libraries are installed ''' - if not salt.utils.is_windows(): - return False, 'This utility only works on Windows' if not HAS_WIN32: return False, 'This utility requires pywin32' diff --git a/salt/utils/win_osinfo.py b/salt/utils/win_osinfo.py index 7ad789c2df52..bdaefb254a28 100644 --- a/salt/utils/win_osinfo.py +++ b/salt/utils/win_osinfo.py @@ -1,14 +1,32 @@ # -*- coding: utf-8 -*- ''' -Get Versioning information from Windows +Get Version information from Windows ''' # http://stackoverflow.com/questions/32300004/python-ctypes-getting-0-with-getversionex-function from __future__ import absolute_import +# Import Third Party Libs import ctypes -from ctypes.wintypes import BYTE, WORD, DWORD, WCHAR +try: + from ctypes.wintypes import BYTE, WORD, DWORD, WCHAR + HAS_WIN32 = True +except (ImportError, ValueError): + HAS_WIN32 = False -kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) +if HAS_WIN32: + kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) + + +# Although utils are often directly imported, it is also possible to use the +# loader. +def __virtual__(): + ''' + Only load if Win32 Libraries are installed + ''' + if not HAS_WIN32: + return False, 'This utility requires pywin32' + + return 'win_osinfo' class OSVERSIONINFO(ctypes.Structure): @@ -38,8 +56,9 @@ def errcheck_bool(result, func, args): raise ctypes.WinError(ctypes.get_last_error()) return args -kernel32.GetVersionExW.errcheck = errcheck_bool -kernel32.GetVersionExW.argtypes = (ctypes.POINTER(OSVERSIONINFO),) +if HAS_WIN32: + kernel32.GetVersionExW.errcheck = errcheck_bool + kernel32.GetVersionExW.argtypes = (ctypes.POINTER(OSVERSIONINFO),) def get_os_version_info(): diff --git a/salt/utils/win_runas.py b/salt/utils/win_runas.py index 17110e5128a3..7d5b6fce0120 100644 --- a/salt/utils/win_runas.py +++ b/salt/utils/win_runas.py @@ -27,20 +27,20 @@ except ImportError: HAS_WIN32 = False -# Import Salt Libs -import salt.utils - # Set up logging log = logging.getLogger(__name__) +# Although utils are often directly imported, it is also possible to use the +# loader. def __virtual__(): ''' - Load only on Windows + Only load if Win32 Libraries are installed ''' - if salt.utils.is_windows() and HAS_WIN32: - return 'win_runas' - return False + if not HAS_WIN32: + return False, 'This utility requires pywin32' + + return 'win_runas' if HAS_WIN32: diff --git a/salt/utils/winservice.py b/salt/utils/winservice.py index 3ad3ce5b9c4e..64eff0ef586a 100644 --- a/salt/utils/winservice.py +++ b/salt/utils/winservice.py @@ -8,10 +8,26 @@ from sys import modules # Import third party libs -import win32serviceutil -import win32service -import win32event -import win32api +try: + import win32serviceutil + import win32service + import win32event + import win32api + HAS_WIN32 = True +except ImportError: + HAS_WIN32 = False + + +# Although utils are often directly imported, it is also possible to use the +# loader. +def __virtual__(): + ''' + Only load if Win32 Libraries are installed + ''' + if not HAS_WIN32: + return False, 'This utility requires pywin32' + + return 'winservice' class Service(win32serviceutil.ServiceFramework): diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index ef2ee04eb20e..9a651d5bea66 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -121,7 +121,7 @@ def terminate_process_pid(pid, only_children=False): try: cmdline = process.cmdline() except psutil.AccessDenied: - # OSX denies us access to the above information + # macOS denies us access to the above information cmdline = None if not cmdline: try: @@ -597,7 +597,7 @@ def _wait_until_running(self): if exc.errno != errno.ENOTCONN: raise except AttributeError: - # This is not OSX !? + # This is not macOS !? pass del sock elif isinstance(port, str): diff --git a/tests/integration/files/engines/runtests_engine.py b/tests/integration/files/engines/runtests_engine.py index 9353371c4d8f..572b72c6abde 100644 --- a/tests/integration/files/engines/runtests_engine.py +++ b/tests/integration/files/engines/runtests_engine.py @@ -84,7 +84,7 @@ def handle_connection(self, connection, address): if exc.errno != errno.ENOTCONN: raise except AttributeError: - # This is not OSX !? + # This is not macOS !? pass @gen.coroutine diff --git a/tests/integration/modules/mac_brew.py b/tests/integration/modules/mac_brew.py index d84c4434710a..a5f8e6596081 100644 --- a/tests/integration/modules/mac_brew.py +++ b/tests/integration/modules/mac_brew.py @@ -30,7 +30,7 @@ @destructiveTest -@skipIf(not salt.utils.is_darwin(), 'Test only applies to OS X') +@skipIf(not salt.utils.is_darwin(), 'Test only applies to macOS') @skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test') @skipIf(not salt.utils.which('brew'), 'This test requires the brew binary') class BrewModuleTest(integration.ModuleCase): diff --git a/tests/integration/modules/mac_pkgutil.py b/tests/integration/modules/mac_pkgutil.py index 5fbdf9d2e55e..8ee15698a710 100644 --- a/tests/integration/modules/mac_pkgutil.py +++ b/tests/integration/modules/mac_pkgutil.py @@ -30,7 +30,7 @@ def setUp(self): Get current settings ''' if not salt.utils.is_darwin(): - self.skipTest('Test only available on Mac OS X') + self.skipTest('Test only available on macOS') if not salt.utils.which('pkgutil'): self.skipTest('Test requires pkgutil binary') diff --git a/tests/integration/modules/mac_ports.py b/tests/integration/modules/mac_ports.py index 2a0bbdb21aca..786ca00874f7 100644 --- a/tests/integration/modules/mac_ports.py +++ b/tests/integration/modules/mac_ports.py @@ -26,7 +26,7 @@ def setUp(self): Get current settings ''' if not salt.utils.is_darwin(): - self.skipTest('Test only available on Mac OS X') + self.skipTest('Test only available on macOS') if not salt.utils.which('port'): self.skipTest('Test requires port binary') diff --git a/tests/integration/modules/mac_service.py b/tests/integration/modules/mac_service.py index 242fe2760731..f3cc35ae1d14 100644 --- a/tests/integration/modules/mac_service.py +++ b/tests/integration/modules/mac_service.py @@ -16,7 +16,7 @@ import salt.utils -@skipIf(not salt.utils.is_darwin(), 'Test only available on Mac OS X') +@skipIf(not salt.utils.is_darwin(), 'Test only available on macOS') @skipIf(not salt.utils.which('launchctl'), 'Test requires launchctl binary') @skipIf(not salt.utils.which('plutil'), 'Test requires plutil binary') @skipIf(salt.utils.get_uid(salt.utils.get_user()) != 0, diff --git a/tests/integration/modules/mac_shadow.py b/tests/integration/modules/mac_shadow.py index 754e34a60377..c3bca54c00b4 100644 --- a/tests/integration/modules/mac_shadow.py +++ b/tests/integration/modules/mac_shadow.py @@ -43,7 +43,7 @@ def setUp(self): Get current settings ''' if not salt.utils.is_darwin(): - self.skipTest('Test only available on Mac OS X') + self.skipTest('Test only available on macOS') if not salt.utils.which('dscl'): self.skipTest('Test requires dscl binary') diff --git a/tests/integration/modules/mac_softwareupdate.py b/tests/integration/modules/mac_softwareupdate.py index d4669995b318..51978328c3d7 100644 --- a/tests/integration/modules/mac_softwareupdate.py +++ b/tests/integration/modules/mac_softwareupdate.py @@ -28,7 +28,7 @@ def setUp(self): Get current settings ''' if not salt.utils.is_darwin(): - self.skipTest('Test only available on Mac OS X') + self.skipTest('Test only available on macOS') if not salt.utils.which('softwareupdate'): self.skipTest('Test requires softwareupdate binary') diff --git a/tests/integration/modules/mac_timezone.py b/tests/integration/modules/mac_timezone.py index 0615c2157900..e9a0a3b896b7 100644 --- a/tests/integration/modules/mac_timezone.py +++ b/tests/integration/modules/mac_timezone.py @@ -39,7 +39,7 @@ def setUp(self): Get current settings ''' if not salt.utils.is_darwin(): - self.skipTest('Test only available on Mac OS X') + self.skipTest('Test only available on macOS') if not salt.utils.which('systemsetup'): self.skipTest('Test requires systemsetup binary') diff --git a/tests/integration/modules/mac_xattr.py b/tests/integration/modules/mac_xattr.py index ff3f364c5be0..8b13203e3021 100644 --- a/tests/integration/modules/mac_xattr.py +++ b/tests/integration/modules/mac_xattr.py @@ -29,7 +29,7 @@ def setUp(self): Create test file for testing extended attributes ''' if not salt.utils.is_darwin(): - self.skipTest('Test only available on Mac OS X') + self.skipTest('Test only available on macOS') if not salt.utils.which('xattr'): self.skipTest('Test requires xattr binary') diff --git a/tests/integration/modules/sysctl.py b/tests/integration/modules/sysctl.py index ddf4833451a8..728dd10d15e7 100644 --- a/tests/integration/modules/sysctl.py +++ b/tests/integration/modules/sysctl.py @@ -46,7 +46,7 @@ def test_show_openbsd(self): ret.get('kern.ostype'), 'OpenBSD', 'Incorrect kern.ostype' ) - @skipIf(not sys.platform.startswith('darwin'), 'Darwin (OS X) specific') + @skipIf(not sys.platform.startswith('darwin'), 'Darwin (macOS) specific') def test_show_darwin(self): ret = self.run_function('sysctl.show') self.assertIn('kern.ostype', ret, 'kern.ostype absent') diff --git a/tests/unit/modules/mac_keychain_test.py b/tests/unit/modules/mac_keychain_test.py index d83aaf85d0ca..428b7c66f770 100644 --- a/tests/unit/modules/mac_keychain_test.py +++ b/tests/unit/modules/mac_keychain_test.py @@ -23,7 +23,7 @@ class KeychainTestCase(TestCase): def test_install_cert(self): ''' - Test installing a certificate into the OSX keychain + Test installing a certificate into the macOS keychain ''' mock = MagicMock() with patch.dict(keychain.__salt__, {'cmd.run': mock}): @@ -34,7 +34,7 @@ def test_install_cert(self): @patch('salt.modules.mac_keychain.unlock_keychain') def test_install_cert_extras(self, unlock_mock): ''' - Test installing a certificate into the OSX keychain with extras + Test installing a certificate into the macOS keychain with extras ''' mock = MagicMock() with patch.dict(keychain.__salt__, {'cmd.run': mock}): @@ -45,7 +45,7 @@ def test_install_cert_extras(self, unlock_mock): def test_uninstall_cert(self): ''' - Test uninstalling a certificate from the OSX keychain + Test uninstalling a certificate from the macOS keychain ''' mock = MagicMock() with patch.dict(keychain.__salt__, {'cmd.run': mock}): diff --git a/tests/unit/modules/proxy_test.py b/tests/unit/modules/proxy_test.py index 76a210672a0e..3338861fa32a 100644 --- a/tests/unit/modules/proxy_test.py +++ b/tests/unit/modules/proxy_test.py @@ -29,10 +29,10 @@ class ProxyTestCase(TestCase): Test cases for salt.modules.proxy ''' - def test_get_http_proxy_osx(self): + def test_get_http_proxy_macos(self): ''' Test to make sure that we correctly get the current proxy info - on OSX + on macOS ''' proxy.__grains__['os'] = 'Darwin' mock = MagicMock(return_value='Enabled: Yes\nServer: 192.168.0.1\nPort: 3128\nAuthenticated Proxy Enabled: 0') @@ -47,10 +47,10 @@ def test_get_http_proxy_osx(self): mock.assert_called_once_with('networksetup -getwebproxy Ethernet') self.assertEqual(expected, out) - def test_get_https_proxy_osx(self): + def test_get_https_proxy_macos(self): ''' Test to make sure that we correctly get the current proxy info - on OSX + on macOS ''' proxy.__grains__['os'] = 'Darwin' mock = MagicMock(return_value='Enabled: Yes\nServer: 192.168.0.1\nPort: 3128\nAuthenticated Proxy Enabled: 0') @@ -65,10 +65,10 @@ def test_get_https_proxy_osx(self): mock.assert_called_once_with('networksetup -getsecurewebproxy Ethernet') self.assertEqual(expected, out) - def test_get_ftp_proxy_osx(self): + def test_get_ftp_proxy_macos(self): ''' Test to make sure that we correctly get the current proxy info - on OSX + on macOS ''' proxy.__grains__['os'] = 'Darwin' mock = MagicMock(return_value='Enabled: Yes\nServer: 192.168.0.1\nPort: 3128\nAuthenticated Proxy Enabled: 0') @@ -83,7 +83,7 @@ def test_get_ftp_proxy_osx(self): mock.assert_called_once_with('networksetup -getftpproxy Ethernet') self.assertEqual(expected, out) - def test_get_http_proxy_osx_none(self): + def test_get_http_proxy_macos_none(self): ''' Test to make sure that we correctly return when theres no proxy set ''' @@ -95,10 +95,10 @@ def test_get_http_proxy_osx_none(self): mock.assert_called_once_with('networksetup -getwebproxy Ethernet') self.assertEqual({}, out) - def test_set_http_proxy_osx(self): + def test_set_http_proxy_macos(self): ''' Test to make sure that we correctly set the proxy info - on OSX + on macOS ''' proxy.__grains__['os'] = 'Darwin' mock = MagicMock() @@ -108,10 +108,10 @@ def test_set_http_proxy_osx(self): mock.assert_called_once_with('networksetup -setwebproxy Ethernet 192.168.0.1 3128 On frank badpassw0rd') self.assertTrue(out) - def test_set_https_proxy_osx(self): + def test_set_https_proxy_macos(self): ''' Test to make sure that we correctly set the proxy info - on OSX + on macOS ''' proxy.__grains__['os'] = 'Darwin' mock = MagicMock() @@ -121,10 +121,10 @@ def test_set_https_proxy_osx(self): mock.assert_called_once_with('networksetup -setsecurewebproxy Ethernet 192.168.0.1 3128 On frank passw0rd') self.assertTrue(out) - def test_set_ftp_proxy_osx(self): + def test_set_ftp_proxy_macos(self): ''' Test to make sure that we correctly set the proxy info - on OSX + on macOS ''' proxy.__grains__['os'] = 'Darwin' mock = MagicMock() @@ -197,7 +197,7 @@ def test_get_ftp_proxy_windows(self): 'ProxyServer') self.assertEqual(expected, out) - def test_get_all_proxies_osx_fails(self): + def test_get_all_proxies_macos_fails(self): proxy.__grains__['os'] = 'Darwin' mock = MagicMock() with patch.dict(proxy.__salt__, {'reg.read_value': mock}): diff --git a/tests/unit/states/kapacitor_test.py b/tests/unit/states/kapacitor_test.py index c5da273ea994..390e06ac7da8 100644 --- a/tests/unit/states/kapacitor_test.py +++ b/tests/unit/states/kapacitor_test.py @@ -25,7 +25,7 @@ def _present(name='testname', define_result=True, enable_result=True, disable_result=True, - script='test'): + script='testscript'): ''' Run a "kapacitor.present" state after setting up mocks, and return the state return value as well as the mocks to make assertions. @@ -57,6 +57,15 @@ def _present(name='testname', return retval, get_mock, define_mock, enable_mock, disable_mock +def _task(script='testscript', enabled=True, task_type='stream', db='testdb', rp='default'): + return { + 'script': script, + 'enabled': enabled, + 'type': task_type, + 'dbrps': [{'db': db, 'rp': rp}], + } + + class KapacitorTestCase(TestCase): def test_task_present_new_task(self): ret, get_mock, define_mock, enable_mock, _ = _present() @@ -68,9 +77,8 @@ def test_task_present_new_task(self): self.assertIn('enabled', ret['changes']) self.assertEqual(True, ret['changes']['enabled']['new']) - def test_task_present_existing_task(self): - old_task = {'script': 'old_task', 'enabled': True} - ret, get_mock, define_mock, enable_mock, _ = _present(task=old_task) + def test_task_present_existing_task_updated_script(self): + ret, get_mock, define_mock, enable_mock, _ = _present(task=_task(script='oldscript')) get_mock.assert_called_once_with('testname') define_mock.assert_called_once_with('testname', '/tmp/script.tick', database='testdb', retention_policy='default', task_type='stream') @@ -79,8 +87,7 @@ def test_task_present_existing_task(self): self.assertNotIn('enabled', ret['changes']) def test_task_present_existing_task_not_enabled(self): - old_task = {'script': 'test', 'enabled': False} - ret, get_mock, define_mock, enable_mock, _ = _present(task=old_task) + ret, get_mock, define_mock, enable_mock, _ = _present(task=_task(enabled=False)) get_mock.assert_called_once_with('testname') self.assertEqual(False, define_mock.called) enable_mock.assert_called_once_with('testname') @@ -89,8 +96,7 @@ def test_task_present_existing_task_not_enabled(self): self.assertEqual(True, ret['changes']['enabled']['new']) def test_task_present_disable_existing_task(self): - old_task = {'script': 'test', 'enabled': True} - ret, get_mock, define_mock, _, disable_mock = _present(task=old_task, enable=False) + ret, get_mock, define_mock, _, disable_mock = _present(task=_task(), enable=False) get_mock.assert_called_once_with('testname') self.assertEqual(False, define_mock.called) disable_mock.assert_called_once_with('testname') diff --git a/tests/unit/states/mac_keychain_test.py b/tests/unit/states/mac_keychain_test.py index 2fb4859a61a7..600040f523bf 100644 --- a/tests/unit/states/mac_keychain_test.py +++ b/tests/unit/states/mac_keychain_test.py @@ -24,7 +24,7 @@ class KeychainTestCase(TestCase): def test_install_cert(self): ''' - Test installing a certificate into the OSX keychain + Test installing a certificate into the macOS keychain ''' expected = { 'changes': {'installed': 'Friendly Name'}, @@ -47,7 +47,8 @@ def test_install_cert(self): def test_installed_cert(self): ''' - Test installing a certificate into the OSX keychain when it's already installed + Test installing a certificate into the macOS keychain when it's + already installed ''' expected = { 'changes': {}, @@ -72,7 +73,8 @@ def test_installed_cert(self): def test_uninstall_cert(self): ''' - Test uninstalling a certificate into the OSX keychain when it's already installed + Test uninstalling a certificate into the macOS keychain when it's + already installed ''' expected = { 'changes': {'uninstalled': 'Friendly Name'}, @@ -95,7 +97,8 @@ def test_uninstall_cert(self): def test_uninstalled_cert(self): ''' - Test uninstalling a certificate into the OSX keychain when it's not installed + Test uninstalling a certificate into the macOS keychain when it's + not installed ''' expected = { 'changes': {}, @@ -178,7 +181,8 @@ def test_default_keychain_missing(self, exists_mock): def test_install_cert_salt_fileserver(self): ''' - Test installing a certificate into the OSX keychain from the salt fileserver + Test installing a certificate into the macOS keychain from the salt + fileserver ''' expected = { 'changes': {'installed': 'Friendly Name'}, @@ -203,8 +207,8 @@ def test_install_cert_salt_fileserver(self): def test_installed_cert_hash_different(self): ''' - Test installing a certificate into the OSX keychain when it's already installed but - the certificate has changed + Test installing a certificate into the macOS keychain when it's + already installed but the certificate has changed ''' expected = { 'changes': {'installed': 'Friendly Name', 'uninstalled': 'Friendly Name'}, diff --git a/tests/unit/states/proxy_test.py b/tests/unit/states/proxy_test.py index a12747b849fe..f1734239f723 100644 --- a/tests/unit/states/proxy_test.py +++ b/tests/unit/states/proxy_test.py @@ -28,9 +28,9 @@ class ProxyTestCase(TestCase): ''' Validate the proxy state ''' - def test_set_proxy_osx(self): + def test_set_proxy_macos(self): ''' - Test to make sure we can set the proxy settings on OSX + Test to make sure we can set the proxy settings on macOS ''' proxy.__grains__['os'] = 'Darwin' expected = {'changes': { @@ -80,9 +80,9 @@ def test_set_proxy_osx(self): set_proxy_mock.assert_has_calls(calls) self.assertEqual(out, expected) - def test_set_proxy_osx_same(self): + def test_set_proxy_macos_same(self): ''' - Test to make sure we can set the proxy settings on OSX + Test to make sure we can set the proxy settings on macOS ''' proxy.__grains__['os'] = 'Darwin' expected = {'changes': {