Additional corrections to use option defaults directly from salt.config

* correct 'id' entry in salt.config
  * add 'event_match_type' in salt.config
  * ensure that hash is only calculated in minion since it isn't needed by the master

Conflicts:
	salt/config.py
This commit is contained in:
Thayne Harbaugh 2015-10-21 22:15:13 -06:00 committed by rallytime
parent 4e53ef0bf6
commit 460a3c98cc
4 changed files with 25 additions and 8 deletions

View file

@ -811,3 +811,9 @@
############################################
# Which returner(s) will be used for minion's result:
#return: mysql
###### Miscellaneous settings ######
############################################
# Default match type for filtering events tags: startswith, endswith, find, regex, fnmatch
#event_match_type: startswith

View file

@ -655,3 +655,9 @@
############################################
# Which returner(s) will be used for minion's result:
#return: mysql
###### Miscellaneous settings ######
############################################
# Default match type for filtering events tags: startswith, endswith, find, regex, fnmatch
#event_match_type: startswith

View file

@ -387,6 +387,9 @@ VALID_OPTS = {
# Events matching a tag in this list should never be sent to an event returner.
'event_return_blacklist': list,
# default match type for filtering events tags: startswith, endswith, find, regex, fnmatch
'event_match_type': str,
# This pidfile to write out to when a daemon starts
'pidfile': str,
@ -781,7 +784,7 @@ DEFAULT_MINION_OPTS = {
'user': 'root',
'root_dir': salt.syspaths.ROOT_DIR,
'pki_dir': os.path.join(salt.syspaths.CONFIG_DIR, 'pki', 'minion'),
'id': None,
'id': '',
'cachedir': os.path.join(salt.syspaths.CACHE_DIR, 'minion'),
'cache_jobs': False,
'grains_cache': False,
@ -966,6 +969,7 @@ DEFAULT_MINION_OPTS = {
'salt_event_pub_hwm': 2000,
# ZMQ HWM for EventPublisher pub socket - different for minion vs. master
'event_publisher_pub_hwm': 1000,
'event_match_type': 'startswith',
}
DEFAULT_MASTER_OPTS = {
@ -1115,6 +1119,7 @@ DEFAULT_MASTER_OPTS = {
'event_return_queue': 0,
'event_return_whitelist': [],
'event_return_blacklist': [],
'event_match_type': 'startswith',
'serial': 'msgpack',
'state_verbose': True,
'state_output': 'full',

View file

@ -220,10 +220,6 @@ class SaltEvent(object):
Return the string URI for the location of the pull and pub sockets to
use for firing and listening to events
'''
hash_type = getattr(hashlib, self.opts['hash_type'])
# Only use the first 10 chars to keep longer hashes from exceeding the
# max socket path length.
id_hash = hash_type(salt.utils.to_bytes(self.opts.get('id', ''))).hexdigest()[:10]
if node == 'master':
if self.opts['ipc_mode'] == 'tcp':
puburi = 'tcp://127.0.0.1:{0}'.format(
@ -252,6 +248,10 @@ class SaltEvent(object):
self.opts['tcp_pull_port']
)
else:
hash_type = getattr(hashlib, self.opts['hash_type'])
# Only use the first 10 chars to keep longer hashes from exceeding the
# max socket path length.
id_hash = hash_type(salt.utils.to_bytes(self.opts['id'])).hexdigest()[:10]
puburi = 'ipc://{0}'.format(os.path.join(
sock_dir,
'minion_event_{0}_pub.ipc'.format(id_hash)
@ -340,7 +340,7 @@ class SaltEvent(object):
def _get_match_func(self, match_type=None):
if match_type is None:
match_type = self.opts.get('event_match_type', 'startswith')
match_type = self.opts['event_match_type']
return getattr(self, '_match_tag_{0}'.format(match_type), None)
def _check_pending(self, tag, match_func=None):
@ -724,7 +724,7 @@ class MinionEvent(SaltEvent):
'''
def __init__(self, opts, listen=True):
super(MinionEvent, self).__init__(
'minion', sock_dir=opts['sock_dir'], opts=opts, listen=listen)
'minion', sock_dir=opts.get('sock_dir'), opts=opts, listen=listen)
class AsyncEventPublisher(object):
@ -745,7 +745,7 @@ class AsyncEventPublisher(object):
hash_type = getattr(hashlib, self.opts['hash_type'])
# Only use the first 10 chars to keep longer hashes from exceeding the
# max socket path length.
id_hash = hash_type(salt.utils.to_bytes(self.opts.get('id', ''))).hexdigest()[:10]
id_hash = hash_type(salt.utils.to_bytes(self.opts['id'])).hexdigest()[:10]
epub_sock_path = os.path.join(
self.opts['sock_dir'],
'minion_event_{0}_pub.ipc'.format(id_hash)