Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
* upstream/develop:
  Remove trailing whitespace
  Added preemptible flag to gce.py - see issue saltstack#31606
  Various improvements for the hipchat engine
  Move to getfullargspec() for py3 in vsphere module
  Add changes to raetkey
  add note related to issue saltstack#37027
  network.ifacestartswith throws exception on Solaris-like platforms
  Fix saltstack#38595 - Unexpected error log from redis retuner in master's log
  pillar.get: Raise exception when merge=True and default is not a dict
  Avoid errors when sudo_user is set
  State Gem: fix incorrect warning about missing rvm/rbenv
  Change daemontools __virtualname__ from service to daemontools
  Create queue if one doesn't exist
  Add hash_type argument to MultiKeyCLI.finger_all function
  Add hash_type argument to key module fingerprint functions
  Add hash_type argument to wheel fingerprint functions
  Add finger_master function to wheel.key module
  Fix eauth error with openLDAP/389 directory server groups
  • Loading branch information
jojohans committed Jan 11, 2017
2 parents 784da56 + 424e83d commit 276017b
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 51 deletions.
13 changes: 13 additions & 0 deletions doc/topics/solaris/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=======
Solaris
=======

This section contains details on Solaris specific quirks and workarounds.

.. note::
Solaris refers to both Solaris 10 comaptible platforms like Solaris 10, illumos, SmartOS, OmniOS, OpenIndiana,... and Oracle Solaris 11 platforms.

.. toctree::
:glob:

*
29 changes: 29 additions & 0 deletions doc/topics/solaris/solaris-specific-behavior.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
==========================
Solaris-specific Behaviour
==========================

Salt is capable of managing Solaris systems, however due to various differences
between the operating systems, there are some things you need to keep in mind.

This document will contain any quirks that apply across Salt or limitations in
some modules.


FQDN/UQDN
=========================
On Solaris platforms the FQDN will not always be properly detected.
If an IPv6 address is configured pythons ```socket.getfqdn()``` fails to return
a FQDN and returns the nodename instead. For a full breakdown see the following
issue on github: #37027

Grains
=========================
Not all grains are available or some have empty or 0 as value. Mostly grains
that are depenend on hardware discovery like:
- num_gpus
- gpus

Also some resolver related grains like:
- domain
- dns:options
- dns:sortlist
4 changes: 3 additions & 1 deletion salt/cloud/clouds/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,9 @@ def request_instance(vm_):
'ex_service_accounts': config.get_cloud_config_value(
'ex_service_accounts', vm_, __opts__, default=None),
'ex_can_ip_forward': config.get_cloud_config_value(
'ip_forwarding', vm_, __opts__, default=False
'ip_forwarding', vm_, __opts__, default=False),
'ex_preemptible': config.get_cloud_config_value(
'preemptible', vm_, __opts__, default=False
)
})
if kwargs.get('ex_disk_type') not in ('pd-standard', 'pd-ssd'):
Expand Down
40 changes: 30 additions & 10 deletions salt/engines/hipchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
engines:
hipchat:
api_url: http://api.hipchat.myteam.com
token: 'XXXXXX'
room: 'salt'
control: True
Expand All @@ -30,6 +31,8 @@
cmd: jobs.list_jobs
list_commands:
cmd: pillar.get salt:engines:hipchat:valid_commands target=saltmaster tgt_type=list
max_rooms: 0
wait_time: 1
'''

from __future__ import absolute_import
Expand All @@ -55,11 +58,14 @@
def __virtual__():
return HAS_HYPCHAT


log = logging.getLogger(__name__)

_DEFAULT_API_URL = 'https://api.hipchat.com'
_DEFAULT_SLEEP = 5
_DEFAULT_MAX_ROOMS = 1000


def _publish_file(token, room, filepath, message='', host='api.hipchat.com'):
def _publish_file(token, room, filepath, message='', api_url=None):
""" Send file to a HipChat room via API version 2
Parameters
----------
Expand All @@ -71,16 +77,16 @@ def _publish_file(token, room, filepath, message='', host='api.hipchat.com'):
Full path of file to be sent
message: str, optional
Message to send to room
host: str, optional
Host to connect to, defaults to api.hipchat.com
api_url: str, optional
Hipchat API URL to use, defaults to http://api.hipchat.com
"""

if not os.path.isfile(filepath):
raise ValueError("File '{0}' does not exist".format(filepath))
if len(message) > 1000:
raise ValueError('Message too long')

url = "https://{0}/v2/room/{1}/share/file".format(host, room)
url = "{0}/v2/room/{1}/share/file".format(api_url, room)
headers = {'Content-type': 'multipart/related; boundary=boundary123456'}
headers['Authorization'] = "Bearer " + token
msg = json.dumps({'message': message})
Expand Down Expand Up @@ -110,7 +116,11 @@ def start(token,
valid_commands=None,
control=False,
trigger="!",
tag='salt/engines/hipchat/incoming'):
tag='salt/engines/hipchat/incoming',
api_key=None,
api_url=None,
max_rooms=None,
wait_time=None):
'''
Listen to Hipchat messages and forward them to Salt
'''
Expand Down Expand Up @@ -142,17 +152,27 @@ def _eval_bot_mentions(all_messages, trigger):
text = message_text.replace(trigger, '').strip()
yield message['from']['mention_name'], text

token = token or api_key
if not token:
raise UserWarning("Hipchat token not found")

runner_functions = sorted(salt.runner.Runner(__opts__).functions)

hipc = hypchat.HypChat(token)
if not api_url:
api_url = _DEFAULT_API_URL
hipc = hypchat.HypChat(token, endpoint=api_url)
if not hipc:
raise UserWarning("Unable to connect to hipchat")

log.debug('Connected to Hipchat')
all_rooms = hipc.rooms(max_results=1000)['items']
rooms_kwargs = {}
if max_rooms is None:
max_rooms = _DEFAULT_MAX_ROOMS
rooms_kwargs['max_results'] = max_rooms
elif max_rooms > 0:
rooms_kwargs['max_results'] = max_rooms
# if max_rooms is 0 => retrieve all (rooms_kwargs is empty dict)
all_rooms = hipc.rooms(**rooms_kwargs)['items']
for a_room in all_rooms:
if a_room['name'] == room:
target_room = a_room
Expand Down Expand Up @@ -241,6 +261,6 @@ def _eval_bot_mentions(all_messages, trigger):
with salt.utils.fopen(tmp_path_fn, 'w+') as fp_:
fp_.write(json.dumps(ret, sort_keys=True, indent=4))
message_string = '@{0} Results for: {1} {2} {3} on {4}'.format(partner, cmd, args, kwargs, target)
_publish_file(token, room, tmp_path_fn, message=message_string)
_publish_file(token, room, tmp_path_fn, message=message_string, api_url=api_url)
salt.utils.safe_rm(tmp_path_fn)
time.sleep(5)
time.sleep(wait_time or _DEFAULT_SLEEP)
32 changes: 22 additions & 10 deletions salt/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ def print_key(self, match):
def print_all(self):
self._call_all('print_all')

def finger(self, match):
self._call_all('finger', match)
def finger(self, match, hash_type):
self._call_all('finger', match, hash_type)

def finger_all(self):
self._call_all('finger_all')
def finger_all(self, hash_type):
self._call_all('finger_all', hash_type)

def prep_signature(self):
self._call_all('prep_signature')
Expand Down Expand Up @@ -897,10 +897,13 @@ def reject_all(self):
salt.crypt.dropfile(self.opts['cachedir'], self.opts['user'])
return self.list_keys()

def finger(self, match):
def finger(self, match, hash_type=None):
'''
Return the fingerprint for a specified key
'''
if hash_type is None:
hash_type = __opts__['hash_type']

matches = self.name_match(match, True)
ret = {}
for status, keys in six.iteritems(matches):
Expand All @@ -910,13 +913,16 @@ def finger(self, match):
path = os.path.join(self.opts['pki_dir'], key)
else:
path = os.path.join(self.opts['pki_dir'], status, key)
ret[status][key] = salt.utils.pem_finger(path, sum_type=self.opts['hash_type'])
ret[status][key] = salt.utils.pem_finger(path, sum_type=hash_type)
return ret

def finger_all(self):
def finger_all(self, hash_type=None):
'''
Return fingerprints for all keys
'''
if hash_type is None:
hash_type = __opts__['hash_type']

ret = {}
for status, keys in six.iteritems(self.all_keys()):
ret[status] = {}
Expand All @@ -925,7 +931,7 @@ def finger_all(self):
path = os.path.join(self.opts['pki_dir'], key)
else:
path = os.path.join(self.opts['pki_dir'], status, key)
ret[status][key] = salt.utils.pem_finger(path, sum_type=self.opts['hash_type'])
ret[status][key] = salt.utils.pem_finger(path, sum_type=hash_type)
return ret


Expand Down Expand Up @@ -1322,10 +1328,13 @@ def reject_all(self):
self.check_minion_cache()
return self.list_keys()

def finger(self, match):
def finger(self, match, hash_type=None):
'''
Return the fingerprint for a specified key
'''
if hash_type is None:
hash_type = __opts__['hash_type']

matches = self.name_match(match, True)
ret = {}
for status, keys in six.iteritems(matches):
Expand All @@ -1338,10 +1347,13 @@ def finger(self, match):
ret[status][key] = self._get_key_finger(path)
return ret

def finger_all(self):
def finger_all(self, hash_type=None):
'''
Return fingerprints for all keys
'''
if hash_type is None:
hash_type = __opts__['hash_type']

ret = {}
for status, keys in six.iteritems(self.list_keys()):
ret[status] = {}
Expand Down
7 changes: 0 additions & 7 deletions salt/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,13 +1719,6 @@ def process_eauth(self, clear_load, auth_type):
message=msg))

name = self.loadauth.load_name(clear_load)
if not ((name in self.opts['external_auth'][clear_load['eauth']]) |
('*' in self.opts['external_auth'][clear_load['eauth']])):
msg = ('Authentication failure of type "eauth" occurred for '
'user {0}.').format(clear_load.get('username', 'UNKNOWN'))
log.warning(msg)
return dict(error=dict(name='EauthAuthenticationError',
message=msg))
if self.loadauth.time_auth(clear_load) is False:
msg = ('Authentication failure of type "eauth" occurred for '
'user {0}.').format(clear_load.get('username', 'UNKNOWN'))
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/daemontools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

log = logging.getLogger(__name__)

__virtualname__ = 'service'
__virtualname__ = 'daemontools'

VALID_SERVICE_DIRS = [
'/service',
Expand Down
28 changes: 20 additions & 8 deletions salt/modules/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,43 @@
import salt.utils


def finger():
def finger(hash_type=None):
'''
Return the minion's public key fingerprint
hash_type
The hash algorithm used to calculate the fingerprint
CLI Example:
.. code-block:: bash
salt '*' key.finger
'''
# MD5 here is temporary. Change to SHA256 when retired.
return salt.utils.pem_finger(os.path.join(__opts__['pki_dir'], 'minion.pub'),
sum_type=__opts__.get('hash_type', 'md5'))
if hash_type is None:
hash_type = __opts__['hash_type']

return salt.utils.pem_finger(
os.path.join(__opts__['pki_dir'], 'minion.pub'),
sum_type=hash_type)


def finger_master():
def finger_master(hash_type=None):
'''
Return the fingerprint of the master's public key on the minion.
hash_type
The hash algorithm used to calculate the fingerprint
CLI Example:
.. code-block:: bash
salt '*' key.finger_master
'''
# MD5 here is temporary. Change to SHA256 when retired.
return salt.utils.pem_finger(os.path.join(__opts__['pki_dir'], 'minion_master.pub'),
sum_type=__opts__.get('hash_type', 'md5'))
if hash_type is None:
hash_type = __opts__['hash_type']

return salt.utils.pem_finger(
os.path.join(__opts__['pki_dir'], 'minion_master.pub'),
sum_type=hash_type)
5 changes: 4 additions & 1 deletion salt/modules/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,10 @@ def ifacestartswith(cidr):
if 'inet' in ifval:
for inet in ifval['inet']:
if inet['address'][0:size] == pattern:
intfnames.append(inet['label'])
if 'label' in inet:
intfnames.append(inet['label'])
else:
intfnames.append(ifname)
return intfnames


Expand Down
6 changes: 5 additions & 1 deletion salt/modules/pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import salt.pillar
import salt.utils
from salt.defaults import DEFAULT_TARGET_DELIM
from salt.exceptions import CommandExecutionError
from salt.exceptions import CommandExecutionError, SaltInvocationError

__proxyenabled__ = ['*']

Expand Down Expand Up @@ -97,6 +97,10 @@ def get(key,
else items(saltenv=saltenv, pillarenv=pillarenv)

if merge:
if not isinstance(default, dict):
raise SaltInvocationError(
'default must be a dictionary when merge=True'
)
ret = salt.utils.traverse_dict_and_list(pillar_dict, key, {}, delimiter)
if isinstance(ret, collections.Mapping) and \
isinstance(default, collections.Mapping):
Expand Down
9 changes: 6 additions & 3 deletions salt/modules/vbox_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,22 @@ def _additions_install_opensuse(**kwargs):
r'^(\d|\.|-)*', '', __grains__.get('kernelrelease', ''))
kernel_devel = 'kernel-{0}-devel'.format(kernel_type)
ret = __salt__['state.single']('pkg.installed', 'devel packages',
pkgs=['make', 'gcc', kernel_devel])
pkgs=['make', 'gcc', kernel_devel],
concurrent=bool(__opts__.get('sudo_user')))
return ret


def _additions_install_ubuntu(**kwargs):
ret = __salt__['state.single']('pkg.installed', 'devel packages',
pkgs=['dkms', ])
pkgs=['dkms', ],
concurrent=bool(__opts__.get('sudo_user')))
return ret


def _additions_install_fedora(**kwargs):
ret = __salt__['state.single']('pkg.installed', 'devel packages',
pkgs=['dkms', 'gcc'])
pkgs=['dkms', 'gcc'],
concurrent=bool(__opts__.get('sudo_user')))
return ret


Expand Down
9 changes: 7 additions & 2 deletions salt/modules/vsphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,13 @@ def gets_service_instance_via_proxy(fn):
is returned.
'''
fn_name = fn.__name__
arg_names, args_name, kwargs_name, default_values = \
inspect.getargspec(fn)
try:
arg_names, args_name, kwargs_name, default_values, _, _, _ = \
inspect.getfullargspec(fn)
except AttributeError:
# Fallback to Python 2.7
arg_names, args_name, kwargs_name, default_values = \
inspect.getargspec(fn)
default_values = default_values if default_values is not None else []

@wraps(fn)
Expand Down

0 comments on commit 276017b

Please sign in to comment.