Merge branch 'develop' of https://github.com/saltstack/salt into custom-net-ps-modules

This commit is contained in:
remy.d1 2016-05-31 11:49:59 +02:00
commit b695a65980
37 changed files with 355 additions and 79 deletions

View File

@ -2434,7 +2434,7 @@ zypper install salt salt\-minion salt\-master
.fi
.UNINDENT
.UNINDENT
.SS Suse Linux Enterprise
.SS SUSE Linux Enterprise
.sp
For SLE 12 run the following as root:
.INDENT 0.0
@ -15972,8 +15972,8 @@ describes the package. An example of this file is:
.nf
.ft C
name: apache
os: RedHat, Debian, Ubuntu, Suse, FreeBSD
os_family: RedHat, Debian, Suse, FreeBSD
os: RedHat, Debian, Ubuntu, SUSE, FreeBSD
os_family: RedHat, Debian, SUSE, FreeBSD
version: 201506
release: 2
summary: Formula for installing Apache
@ -40629,7 +40629,7 @@ channels:
.UNINDENT
.INDENT 0.0
.IP \(bu 2
\fI\%OpenSuse Build Service\fP
\fI\%openSUSE Build Service\fP
.UNINDENT
.sp
Optionally WinRM can be used instead of \fIwinexe\fP if the python module \fIpywinrm\fP
@ -232592,7 +232592,7 @@ repo. Secondly, it will be the name of the file as stored in
.TP
.B humanname
This is used as the "name" value in the repo file in
\fB/etc/yum.repos.d/\fP (or \fB/etc/zypp/repos.d\fP for Suse distros).
\fB/etc/yum.repos.d/\fP (or \fB/etc/zypp/repos.d\fP for SUSE distros).
.TP
.B baseurl
The URL to a yum repository
@ -281393,7 +281393,7 @@ as improved error checking for sls files in the state system. A new provider
system has been added to allow for redirecting what modules run in the
background for individual states.
.sp
Support for OpenSUSE has been added and support for Solaris has begun
Support for openSUSE has been added and support for Solaris has begun
serious development. Windows support has been significantly enhanced as well.
.sp
The matcher and target systems have received a great deal of attention. The
@ -281749,7 +281749,7 @@ The \fBpkg\fP module on Debian, Ubuntu,
and derivatives force apt to run in a non\-interactive mode. This prevents
issues when package installation waits for confirmation.
.sp
A \fBpkg\fP module for OpenSUSE\(aqs
A \fBpkg\fP module for openSUSE\(aqs
zypper was added.
.sp
The \fBservice\fP module on Ubuntu

View File

@ -28,7 +28,7 @@ channels:
.. __: http://rpm.pbone.net/index.php3?stat=3&search=winexe
* `OpenSuse Build Service`__
* `openSUSE Build Service`__
.. __: http://software.opensuse.org/package/winexe

View File

@ -137,7 +137,7 @@ For openSUSE 13.2 run the following as root:
zypper refresh
zypper install salt salt-minion salt-master
Suse Linux Enterprise
SUSE Linux Enterprise
---------------------
For SLE 12 run the following as root:

View File

@ -26,7 +26,7 @@ as improved error checking for sls files in the state system. A new provider
system has been added to allow for redirecting what modules run in the
background for individual states.
Support for OpenSUSE has been added and support for Solaris has begun
Support for openSUSE has been added and support for Solaris has begun
serious development. Windows support has been significantly enhanced as well.
The matcher and target systems have received a great deal of attention. The
@ -339,7 +339,7 @@ The :doc:`pkg </ref/modules/all/salt.modules.aptpkg>` module on Debian, Ubuntu,
and derivatives force apt to run in a non-interactive mode. This prevents
issues when package installation waits for confirmation.
A :doc:`pkg </ref/modules/all/salt.modules.zypper>` module for OpenSUSE's
A :doc:`pkg </ref/modules/all/salt.modules.zypper>` module for openSUSE's
zypper was added.
The :doc:`service </ref/modules/all/salt.modules.upstart>` module on Ubuntu

View File

@ -10,8 +10,8 @@ describes the package. An example of this file is:
.. code-block:: yaml
name: apache
os: RedHat, Debian, Ubuntu, Suse, FreeBSD
os_family: RedHat, Debian, Suse, FreeBSD
os: RedHat, Debian, Ubuntu, SUSE, FreeBSD
os_family: RedHat, Debian, SUSE, FreeBSD
version: 201506
release: 2
summary: Formula for installing Apache

View File

@ -70,7 +70,7 @@ collection of minion matches is defined; for now simply specify all hosts
.. code-block:: yaml
base:
'G@os:Fedora':
'os:Fedora':
- match: grain
- webserver

View File

@ -52,7 +52,7 @@ Turning on the Salt Master is easy -- just turn it on! The default configuration
is suitable for the vast majority of installations. The Salt Master can be
controlled by the local Linux/Unix service manager:
On Systemd based platforms (newer Debian, OpenSuse, Fedora):
On Systemd based platforms (newer Debian, openSUSE, Fedora):
.. code-block:: bash

View File

@ -15,9 +15,9 @@ index cfafe24..d581916 100644
@@ -47,7 +47,7 @@ def __virtual__():
if __grains__['kernel'] != 'Linux':
return False
# Suse >=12.0 uses systemd
# SUSE >=12.0 uses systemd
- if __grains__.get('os', '') == 'openSUSE':
+ if __grains__.get('os_family', '') == 'Suse':
+ if __grains__.get('os_family', '') == 'SUSE':
try:
if int(__grains__.get('osrelease', '').split('.')[0]) >= 12:
return False

View File

@ -13,8 +13,8 @@ index d581916..dab0817 100644
--- a/salt/modules/service.py
+++ b/salt/modules/service.py
@@ -49,7 +49,12 @@ def __virtual__():
# Suse >=12.0 uses systemd
if __grains__.get('os_family', '') == 'Suse':
# SUSE >=12.0 uses systemd
if __grains__.get('os_family', '') == 'SUSE':
try:
- if int(__grains__.get('osrelease', '').split('.')[0]) >= 12:
+ # osrelease might be in decimal format (e.g. "12.1"), or for

View File

@ -81,7 +81,7 @@ Tue Apr 9 18:56:15 UTC 2013 - aboe76@gmail.com
-------------------------------------------------------------------
Wed Jan 30 21:00:43 UTC 2013 - aboe76@gmail.com
- Updated spec file with Suse Copyright
- Updated spec file with SUSE Copyright
-------------------------------------------------------------------
Sat Jan 26 09:19:19 UTC 2013 - aboe76@gmail.com

View File

@ -1321,7 +1321,7 @@ Thu Feb 14 06:43:08 UTC 2013 - aboe76@gmail.com
-------------------------------------------------------------------
Wed Jan 30 20:57:57 UTC 2013 - aboe76@gmail.com
- Updated Suse Copyright in Spec-file
- Updated SUSE Copyright in Spec-file
-------------------------------------------------------------------
Mon Jan 28 15:23:08 UTC 2013 - toddrme2178@gmail.com

View File

@ -221,7 +221,10 @@ def _cache(bank, key, fun, **kwargs):
items = cache.fetch(bank, key)
if items is None:
items = {}
item_list = fun(**kwargs)
try:
item_list = fun(**kwargs)
except CloudError as exc:
log.warn('There was a cloud error calling {0} with kwargs {1}: {2}'.format(fun, kwargs, exc))
for item in item_list:
items[item.name] = object_to_dict(item)
cache.store(bank, key, items)

View File

@ -5152,7 +5152,7 @@ install_opensuse_stable_deps() {
# shellcheck disable=SC2086
__zypper_install ${__PACKAGES} || return 1
# Fix for OpenSUSE 13.2 and 2015.8 - gcc should not be required. Work around until package is fixed by SuSE
# Fix for openSUSE 13.2 and 2015.8 - gcc should not be required. Work around until package is fixed by SuSE
_EXTRA_PACKAGES="${_EXTRA_PACKAGES} gcc python-devel libgit2-devel"
if [ "${_EXTRA_PACKAGES}" != "" ]; then

View File

@ -55,16 +55,31 @@ def node_state(id_):
'''
Libcloud supported node states
'''
states = {0: 'RUNNING',
1: 'REBOOTING',
2: 'TERMINATED',
3: 'PENDING',
4: 'UNKNOWN',
5: 'STOPPED',
6: 'SUSPENDED',
7: 'ERROR',
8: 'PAUSED'}
return states[id_]
states_int = {
0: 'RUNNING',
1: 'REBOOTING',
2: 'TERMINATED',
3: 'PENDING',
4: 'UNKNOWN',
5: 'STOPPED',
6: 'SUSPENDED',
7: 'ERROR',
8: 'PAUSED'}
states_str = {
'running': 'RUNNING',
'rebooting': 'REBOOTING',
'starting': 'STARTING',
'terminated': 'TERMINATED',
'pending': 'PENDING',
'unknown': 'UNKNOWN',
'stopping': 'STOPPING',
'stopped': 'STOPPED',
'suspended': 'SUSPENDED',
'error': 'ERROR',
'paused': 'PAUSED',
'reconfiguring': 'RECONFIGURING'
}
return states_str[id_] if isinstance(id_, string_types) else states_int[id_]
def check_libcloud_version(reqver=LIBCLOUD_MINIMAL_VERSION, why=None):

View File

@ -1030,14 +1030,14 @@ _OS_FAMILY_MAP = {
'VMwareESX': 'VMware',
'Bluewhite64': 'Bluewhite',
'Slamd64': 'Slackware',
'SLES': 'Suse',
'SUSE Enterprise Server': 'Suse',
'SUSE Enterprise Server': 'Suse',
'SLED': 'Suse',
'openSUSE': 'Suse',
'SUSE': 'Suse',
'openSUSE Leap': 'Suse',
'openSUSE Tumbleweed': 'Suse',
'SLES': 'SUSE',
'SUSE Enterprise Server': 'SUSE',
'SUSE Enterprise Server': 'SUSE',
'SLED': 'SUSE',
'openSUSE': 'SUSE',
'SUSE': 'SUSE',
'openSUSE Leap': 'SUSE',
'openSUSE Tumbleweed': 'SUSE',
'Solaris': 'Solaris',
'SmartOS': 'Solaris',
'OpenIndiana Development': 'Solaris',

View File

@ -52,7 +52,7 @@ def _detect_os():
os_family = __grains__['os_family']
if os_family == 'RedHat':
return 'apachectl'
elif os_family == 'Debian' or os_family == 'Suse':
elif os_family == 'Debian' or os_family == 'SUSE':
return 'apache2ctl'
else:
return 'apachectl'

View File

@ -74,7 +74,7 @@ class Inspector(object):
'''
if self.grains_core.os_data().get('os_family') == 'Debian':
return self.__get_cfg_pkgs_dpkg()
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
elif self.grains_core.os_data().get('os_family') in ['SUSE', 'redhat']:
return self.__get_cfg_pkgs_rpm()
else:
return dict()
@ -150,7 +150,7 @@ class Inspector(object):
if self.grains_core.os_data().get('os_family') == 'Debian':
cfg_data = salt.utils.to_str(self._syscall("dpkg", None, None, '--verify',
pkg_name)[0]).split(os.linesep)
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
elif self.grains_core.os_data().get('os_family') in ['SUSE', 'redhat']:
cfg_data = salt.utils.to_str(self._syscall("rpm", None, None, '-V', '--nodeps', '--nodigest',
'--nosignature', '--nomtime', '--nolinkto',
pkg_name)[0]).split(os.linesep)
@ -209,7 +209,7 @@ class Inspector(object):
'''
if self.grains_core.os_data().get('os_family') == 'Debian':
return self.__get_managed_files_dpkg()
elif self.grains_core.os_data().get('os_family') in ['Suse', 'redhat']:
elif self.grains_core.os_data().get('os_family') in ['SUSE', 'redhat']:
return self.__get_managed_files_rpm()
return list(), list(), list()

View File

@ -80,7 +80,7 @@ def _conf(family='ipv4'):
return '/var/lib/ip6tables/rules-save'
else:
return '/var/lib/iptables/rules-save'
elif __grains__['os_family'] == 'Suse':
elif __grains__['os_family'] == 'SUSE':
# SuSE does not seem to use separate files for IPv4 and IPv6
return '/etc/sysconfig/scripts/SuSEfirewall2-custom'
else:

View File

@ -132,7 +132,7 @@ def get_locale():
return params.get('LANG', '')
elif 'RedHat' in __grains__['os_family']:
cmd = 'grep "^LANG=" /etc/sysconfig/i18n'
elif 'Suse' in __grains__['os_family']:
elif 'SUSE' in __grains__['os_family']:
cmd = 'grep "^RC_LANG" /etc/sysconfig/language'
elif 'Debian' in __grains__['os_family']:
# this block only applies to Debian without systemd
@ -172,7 +172,7 @@ def set_locale(locale):
'LANG="{0}"'.format(locale),
append_if_not_found=True
)
elif 'Suse' in __grains__['os_family']:
elif 'SUSE' in __grains__['os_family']:
if not __salt__['file.file_exists']('/etc/sysconfig/language'):
__salt__['file.touch']('/etc/sysconfig/language')
__salt__['file.replace'](
@ -261,7 +261,7 @@ def gen_locale(locale, **kwargs):
on_debian = __grains__.get('os') == 'Debian'
on_ubuntu = __grains__.get('os') == 'Ubuntu'
on_gentoo = __grains__.get('os_family') == 'Gentoo'
on_suse = __grains__.get('os_family') == 'Suse'
on_suse = __grains__.get('os_family') == 'SUSE'
on_solaris = __grains__.get('os_family') == 'Solaris'
if on_solaris: # all locales are pre-generated

View File

@ -51,8 +51,8 @@ def __virtual__():
# Disable on all non-Linux OSes as well
if __grains__['kernel'] != 'Linux':
return (False, 'Non Linux OSes are not supported')
# Suse >=12.0 uses systemd
if __grains__.get('os_family', '') == 'Suse':
# SUSE >=12.0 uses systemd
if __grains__.get('os_family', '') == 'SUSE':
try:
# osrelease might be in decimal format (e.g. "12.1"), or for
# SLES might include service pack (e.g. "11 SP3"), so split on
@ -60,7 +60,7 @@ def __virtual__():
# number (it'd be so much simpler if it was always "X.Y"...)
import re
if int(re.split(r'\D+', __grains__.get('osrelease', ''))[0]) >= 12:
return (False, 'Suse version greater than or equal to 12 is not supported')
return (False, 'SUSE version greater than or equal to 12 is not supported')
except ValueError:
return (False, 'You are missing the os_family grain')
return 'service'

View File

@ -139,7 +139,7 @@ def get_zone():
if __grains__['os'].lower() == 'centos':
return _get_zone_etc_localtime()
os_family = __grains__['os_family']
for family in ('RedHat', 'Suse'):
for family in ('RedHat', 'SUSE'):
if family in os_family:
return _get_zone_sysconfig()
for family in ('Debian', 'Gentoo'):
@ -218,7 +218,7 @@ def set_zone(timezone):
if 'RedHat' in __grains__['os_family']:
__salt__['file.sed'](
'/etc/sysconfig/clock', '^ZONE=.*', 'ZONE="{0}"'.format(timezone))
elif 'Suse' in __grains__['os_family']:
elif 'SUSE' in __grains__['os_family']:
__salt__['file.sed'](
'/etc/sysconfig/clock', '^ZONE=.*', 'ZONE="{0}"'.format(timezone))
elif 'Debian' in __grains__['os_family']:
@ -312,7 +312,7 @@ def get_hwclock():
else:
os_family = __grains__['os_family']
for family in ('RedHat', 'Suse'):
for family in ('RedHat', 'SUSE'):
if family in os_family:
cmd = ['tail', '-n', '1', '/etc/adjtime']
return __salt__['cmd.run'](cmd, python_shell=False)
@ -401,7 +401,7 @@ def set_hwclock(clock):
elif 'RedHat' in __grains__['os_family']:
__salt__['file.sed'](
'/etc/sysconfig/clock', '^ZONE=.*', 'ZONE="{0}"'.format(timezone))
elif 'Suse' in __grains__['os_family']:
elif 'SUSE' in __grains__['os_family']:
__salt__['file.sed'](
'/etc/sysconfig/clock', '^ZONE=.*', 'ZONE="{0}"'.format(timezone))
elif 'Debian' in __grains__['os_family']:

View File

@ -16,7 +16,10 @@ import salt.utils
_HKEY = 'HKLM'
_SNMP_KEY = r'SYSTEM\CurrentControlSet\Services\SNMP\Parameters'
_AGENT_KEY = r'{0}\RFC1156Agent'.format(_SNMP_KEY)
_COMMUNITIES_KEY = r'{0}\ValidCommunities'.format(_SNMP_KEY)
_PERMISSION_TYPES = {'None': 1, 'Notify': 2, 'Read Only': 4, 'Read Write': 8,
'Read Create': 16}
_SERVICE_TYPES = {'None': 0, 'Physical': 1, 'Datalink and subnetwork': 2, 'Internet': 4,
'End-to-end': 8, 'Applications': 64}
@ -51,6 +54,22 @@ def get_agent_service_types():
return _SERVICE_TYPES.keys()
def get_permission_types():
'''
Get the permission types that can be configured for communities.
:return: A list of the permission types.
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' win_snmp.get_permission_types
'''
return _PERMISSION_TYPES.keys()
def get_agent_settings():
'''
Determine the value of the SNMP sysContact, sysLocation, and sysServices settings.
@ -212,3 +231,104 @@ def set_auth_traps_enabled(status=True):
return True
_LOG.error('Unable to configure %s with value: %s', vname, vdata)
return False
def get_community_names():
'''
Get the current accepted SNMP community names and their permissions.
:return: A dictionary of community names and permissions.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' win_snmp.get_community_names
'''
ret = dict()
current_values = __salt__['reg.list_values'](_HKEY, _COMMUNITIES_KEY, include_default=False)
# The communities are stored as the community name with a numeric permission value. Convert
# the numeric value to the text equivalent, as present in the Windows SNMP service GUI.
for current_value in current_values:
permissions = str()
for permission_name in _PERMISSION_TYPES:
if current_value['vdata'] == _PERMISSION_TYPES[permission_name]:
permissions = permission_name
break
ret[current_value['vname']] = permissions
if not ret:
_LOG.debug('Unable to find existing communities.')
return ret
def set_community_names(communities):
'''
Manage the SNMP accepted community names and their permissions.
:param str communities: A dictionary of SNMP community names and permissions.
The possible permissions can be found via win_snmp.get_permission_types.
:return: A boolean representing whether the change succeeded.
:rtype: bool
CLI Example:
.. code-block:: bash
salt '*' win_snmp.set_community_names communities="{'TestCommunity': 'Read Only'}'
'''
values = dict()
current_communities = get_community_names()
if communities == current_communities:
_LOG.debug('Communities already contain the provided values.')
return True
for vname in communities:
if not communities[vname]:
communities[vname] = 'None'
try:
vdata = _PERMISSION_TYPES[communities[vname]]
except KeyError:
message = ("Invalid permission '{0}' specified. Valid permissions:"
' {1}').format(communities[vname], _PERMISSION_TYPES.keys())
raise SaltInvocationError(message)
values[vname] = vdata
# Check current communities.
for current_vname in current_communities:
if current_vname in values:
# Modify existing communities that have a different permission value.
if current_communities[current_vname] != values[current_vname]:
__salt__['reg.set_value'](_HKEY, _COMMUNITIES_KEY, current_vname, values[current_vname], 'REG_DWORD')
else:
# Remove current communities that weren't provided.
__salt__['reg.delete_value'](_HKEY, _COMMUNITIES_KEY, current_vname)
# Create any new communities.
for vname in values:
if vname not in current_communities:
__salt__['reg.set_value'](_HKEY, _COMMUNITIES_KEY, vname, values[vname], 'REG_DWORD')
# Get the fields post-change so that we can verify tht all values
# were modified successfully. Track the ones that weren't.
new_communities = get_community_names()
failed_communities = dict()
for new_vname in new_communities:
if new_vname not in communities:
failed_communities[new_vname] = None
for vname in communities:
if communities[vname] != new_communities[vname]:
failed_communities[vname] = communities[vname]
if failed_communities:
_LOG.error('Unable to configure communities: %s', failed_communities)
return False
_LOG.debug('Communities configured successfully: %s', communities.keys())
return True

View File

@ -60,6 +60,7 @@ EXT_NAME_MAPPINGS = OrderedDict([
])
CERT_DEFAULTS = {'days_valid': 365, 'version': 3, 'serial_bits': 64, 'algorithm': 'sha256'}
PEM_RE = re.compile(r"(-----BEGIN CERTIFICATE-----\s?.+?\s?-----END CERTIFICATE-----)\s?", re.DOTALL)
def __virtual__():
@ -359,6 +360,11 @@ def get_pem_entry(text, pem_type=None):
else:
pem_header = '-----BEGIN {0}-----'.format(pem_type)
pem_footer = '-----END {0}-----'.format(pem_type)
if pem_type == 'CERTIFICATE':
for _match in PEM_RE.finditer(text):
# get the first certificate
text = _match.group(0)
break
# Split based on defined headers
if (len(text.split(pem_header)) is not 2 or
len(text.split(pem_footer)) is not 2):
@ -1331,7 +1337,7 @@ def verify_signature(certificate, signing_pub_key=None):
.. code-block:: bash
salt '*' x509.verify_private_key private_key=/etc/pki/myca.key public_key=/etc/pki/myca.crt
salt '*' x509.verify_signature /etc/pki/mycert.pem signing_pub_key=/etc/pki/myca.crt
'''
cert = _get_certificate_obj(certificate)

View File

@ -54,9 +54,9 @@ def __virtual__():
'''
Set the virtual pkg module if the os is openSUSE
'''
if __grains__.get('os_family', '') != 'Suse':
if __grains__.get('os_family', '') != 'SUSE':
return (False, "Module zypper: non SUSE OS not suppored by zypper package manager")
# Not all versions of Suse use zypper, check that it is available
# Not all versions of SUSE use zypper, check that it is available
if not salt.utils.which('zypper'):
return (False, "Module zypper: zypper package manager not found")
return __virtualname__

View File

@ -122,6 +122,14 @@ def output(data):
The HighState Outputter is only meant to be used with the state.highstate
function, or a function that returns highstate return data.
'''
# Discard retcode in dictionary as present in orchestrate data
local_masters = [key for key in data.keys() if key.endswith('.local_master')]
orchestrator_output = 'retcode' in data.keys() and len(local_masters) == 1
if orchestrator_output:
del data['retcode']
# If additional information is passed through via the "data" dictionary to
# the highstate outputter, such as "outputter" or "retcode", discard it.
# We only want the state data that was passed through, if it is wrapped up
@ -169,7 +177,7 @@ def _format_host(host, data):
# Verify that the needed data is present
data_tmp = {}
for tname, info in six.iteritems(data):
if isinstance(info, dict) and '__run_num__' not in info:
if isinstance(info, dict) and tname is not 'changes' and '__run_num__' not in info:
err = (u'The State execution failed to record the order '
'in which all states were executed. The state '
'return missing data is:')

View File

@ -25,7 +25,7 @@ no disk space:
- unless: echo 'foo' > /tmp/.test && rm -f /tmp/.test
Only run if the file specified by ``creates`` does not exist, in this case
touch /tmp/foo if it does not exist.
touch /tmp/foo if it does not exist:
.. code-block:: yaml
@ -33,6 +33,16 @@ touch /tmp/foo if it does not exist.
cmd.run:
- creates: /tmp/foo
``creates`` also accepts a list of files:
.. code-block:: yaml
echo 'foo' | tee /tmp/bar > /tmp/baz:
cmd.run:
- creates:
- /tmp/bar
- /tmp/baz
.. note::
The ``creates`` option was added to version 2014.7.0
@ -467,7 +477,7 @@ def wait(name,
a state. For more information, see the :ref:`stateful-argument` section.
creates
Only run if the file specified by ``creates`` does not exist.
Only run if the file or files specified by ``creates`` do not exist.
.. versionadded:: 2014.7.0
@ -741,7 +751,7 @@ def run(name,
.. versionadded:: 2015.8.0
creates
Only run if the file specified by ``creates`` does not exist.
Only run if the file or files specified by ``creates`` do not exist.
.. versionadded:: 2014.7.0
@ -973,7 +983,7 @@ def script(name,
'arg two' arg3"
creates
Only run if the file specified by ``creates`` does not exist.
Only run if the file or files specified by ``creates`` do not exist.
.. versionadded:: 2014.7.0

View File

@ -1510,7 +1510,8 @@ def managed(name,
if isinstance(contents_pillar, list):
list_contents = []
for nextp in contents_pillar:
nextc = __salt__['pillar.get'](nextp, __NOT_FOUND)
nextc = __salt__['pillar.get'](nextp, __NOT_FOUND,
delimiter=contents_delimiter)
if nextc is __NOT_FOUND:
return _error(
ret,
@ -1519,7 +1520,8 @@ def managed(name,
list_contents.append(nextc)
use_contents = os.linesep.join(list_contents)
else:
use_contents = __salt__['pillar.get'](contents_pillar, __NOT_FOUND)
use_contents = __salt__['pillar.get'](contents_pillar, __NOT_FOUND,
delimiter=contents_delimiter)
if use_contents is __NOT_FOUND:
return _error(
ret,
@ -1530,7 +1532,8 @@ def managed(name,
if isinstance(contents_grains, list):
list_contents = []
for nextg in contents_grains:
nextc = __salt__['grains.get'](nextg, __NOT_FOUND)
nextc = __salt__['grains.get'](nextg, __NOT_FOUND,
delimiter=contents_delimiter)
if nextc is __NOT_FOUND:
return _error(
ret,
@ -1539,7 +1542,8 @@ def managed(name,
list_contents.append(nextc)
use_contents = os.linesep.join(list_contents)
else:
use_contents = __salt__['grains.get'](contents_grains, __NOT_FOUND)
use_contents = __salt__['grains.get'](contents_grains, __NOT_FOUND,
delimiter=contents_delimiter)
if use_contents is __NOT_FOUND:
return _error(
ret,

View File

@ -128,7 +128,7 @@ def managed(name, ppa=None, **kwargs):
humanname
This is used as the "name" value in the repo file in
``/etc/yum.repos.d/`` (or ``/etc/zypp/repos.d`` for Suse distros).
``/etc/yum.repos.d/`` (or ``/etc/zypp/repos.d`` for SUSE distros).
baseurl
The URL to a yum repository

View File

@ -189,7 +189,7 @@ def managed(name,
)
except CommandNotFoundError as err:
ret['result'] = False
ret['comment'] = 'Failed to create virtualenv: {0}'.formar(err)
ret['comment'] = 'Failed to create virtualenv: {0}'.format(err)
return ret
if _ret['retcode'] != 0:

View File

@ -30,9 +30,8 @@ def agent_settings(name, contact, location, services=None):
'comment': str(),
'result': None}
ret_settings = dict()
ret_settings['changes'] = {}
ret_settings['failures'] = {}
ret_settings = {'changes': dict(),
'failures': dict()}
if not services:
services = ['None']
@ -105,3 +104,78 @@ def auth_traps_enabled(name, status=True):
ret['result'] = __salt__['win_snmp.set_auth_traps_enabled'](status=status)
return ret
def community_names(name, communities=None):
'''
Manage the SNMP accepted community names and their permissions.
:param str communities: A dictionary of SNMP communities and permissions.
'''
ret = {'name': name,
'changes': dict(),
'comment': str(),
'result': None}
ret_communities = {'changes': dict(),
'failures': dict()}
if not communities:
communities = dict()
current_communities = __salt__['win_snmp.get_community_names']()
# Note any existing communities that should be removed.
for current_vname in current_communities:
if current_vname not in communities:
ret_communities['changes'][current_vname] = {'old': current_communities[current_vname],
'new': None}
# Note any new communities or existing communities that should be changed.
for vname in communities:
current_vdata = None
if vname in current_communities:
current_vdata = current_communities[vname]
if communities[vname] != current_vdata:
ret_communities['changes'][vname] = {'old': current_vdata,
'new': communities[vname]}
if not ret_communities['changes']:
ret['comment'] = 'Communities already contain the provided values.'
ret['result'] = True
return ret
elif __opts__['test']:
ret['comment'] = 'Communities will be changed.'
ret['changes'] = ret_communities
return ret
__salt__['win_snmp.set_community_names'](communities=communities)
new_communities = __salt__['win_snmp.get_community_names']()
# Verify that any communities that needed to be removed were removed.
for new_vname in new_communities:
if new_vname not in communities:
ret_communities['failures'][new_vname] = {'old': current_communities[new_vname],
'new': new_communities[new_vname]}
ret_communities['changes'].pop(new_vname, None)
# Verify that any new communities or existing communities that
# needed to be changed were changed.
for vname in communities:
new_vdata = None
if vname in new_communities:
new_vdata = new_communities[vname]
if communities[vname] != new_vdata:
ret_communities['failures'][vname] = {'old': current_communities[vname],
'new': new_vdata}
ret_communities['changes'].pop(vname, None)
if ret_communities['failures']:
ret['comment'] = 'Some communities failed to change.'
ret['changes'] = ret_communities
ret['result'] = False
else:
ret['comment'] = 'Set communities to contain the provided values.'
ret['changes'] = ret_communities['changes']
ret['result'] = True
return ret

View File

@ -652,7 +652,7 @@ def get_ca_bundle(opts=None):
'/etc/pki/tls/certs/ca-bundle.trust.crt',
# RedHat's link for Debian compatibility
'/etc/ssl/certs/ca-bundle.crt',
# Suse has an unusual path
# SUSE has an unusual path
'/var/lib/ca-certificates/ca-bundle.pem',
# OpenBSD has an unusual path
'/etc/ssl/cert.pem',

View File

@ -220,7 +220,7 @@ class PkgModuleTest(integration.ModuleCase,
keys = ret.keys()
self.assertIn('rpm', keys)
self.assertIn('yum', keys)
elif os_family == 'Suse':
elif os_family == 'SUSE':
ret = self.run_function(func, ['less', 'zypper'])
keys = ret.keys()
self.assertIn('less', keys)

View File

@ -58,7 +58,7 @@ class UseraddModuleTest(integration.ModuleCase):
try:
uinfo = self.run_function('user.info', [uname])
if grains['os_family'] in ('Suse',):
if grains['os_family'] in ('SUSE',):
self.assertIn('users', uinfo['groups'])
else:
self.assertIn(uname, uinfo['groups'])

View File

@ -36,7 +36,7 @@ _PKG_TARGETS = {
'Debian': ['python-plist', 'apg'],
'RedHat': ['xz-devel', 'zsh-html'],
'FreeBSD': ['aalib', 'pth'],
'Suse': ['aalib', 'python-pssh']
'SUSE': ['aalib', 'python-pssh']
}

View File

@ -30,7 +30,7 @@ _PKG_TARGETS = {
'Debian': ['python-plist', 'apg'],
'RedHat': ['xz-devel', 'zsh-html'],
'FreeBSD': ['aalib', 'pth'],
'Suse': ['aalib', 'python-pssh'],
'SUSE': ['aalib', 'python-pssh'],
'MacOS': ['libpng', 'jpeg'],
}

View File

@ -151,7 +151,7 @@ class UserTest(integration.ModuleCase,
group_name = grp.getgrgid(ret['gid']).gr_name
self.assertTrue(os.path.isdir('/var/lib/salt_test'))
if grains['os_family'] in ('Suse',):
if grains['os_family'] in ('SUSE',):
self.assertEqual(group_name, 'users')
elif grains['os_family'] == 'MacOS':
self.assertEqual(group_name, 'staff')

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
'''
:codeauthor: `Anthony Shaw <anthonyshaw@apache.org>`
tests.unit.cloud.clouds.dimensiondata_test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'''
# Import Python libs
from __future__ import absolute_import
# Import Salt Testing Libs
from salttesting import TestCase
# Import Salt Libs
import salt.cloud.libcloudfuncs as libcloud
# Import Salt Testing Libs
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
class LibcloudTestCase(TestCase):
def test_node_state_libcloud_020(self):
state = libcloud.node_state(2)
self.assertEqual('TERMINATED', state)
def test_node_state_libcloud_100(self):
state = libcloud.node_state('terminated')
self.assertEqual('TERMINATED', state)
if __name__ == '__main__':
from unit import run_tests
run_tests(LibcloudTestCase, needs_daemon=False)