Change the socket to use a hash of the minion id

This commit is contained in:
Thomas S Hatch 2012-09-19 13:23:55 -06:00
parent 0cff0e4976
commit 3a0a4125d6
2 changed files with 8 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import multiprocessing
import fnmatch
import os
import hashlib
import re
import threading
import time
@ -482,13 +483,14 @@ class Minion(object):
# Prepare the minion event system
#
# Start with the publish socket
id_hash = hashlib.md5(self.opts['id']).hexdigest()
epub_sock_path = os.path.join(
self.opts['sock_dir'],
'minion_event_{0}_pub.ipc'.format(self.opts['id'])
'minion_event_{0}_pub.ipc'.format(id_hash)
)
epull_sock_path = os.path.join(
self.opts['sock_dir'],
'minion_event_{0}_pull.ipc'.format(self.opts['id'])
'minion_event_{0}_pull.ipc'.format(id_hash)
)
epub_sock = context.socket(zmq.PUB)
if self.opts.get('ipc_mode', '') == 'tcp':

View File

@ -14,6 +14,7 @@ Manage events
#
# Import Python libs
import os
import hashlib
import errno
import logging
import multiprocessing
@ -43,6 +44,7 @@ class SaltEvent(object):
Return the string uri for the location of the pull and pub sockets to
use for firing and listening to events
'''
id_hash = hashlib.md5(kwargs.get('id', '')).hexdigest()
if node == 'master':
puburi = 'ipc://{0}'.format(os.path.join(
sock_dir,
@ -63,11 +65,11 @@ class SaltEvent(object):
else:
puburi = 'ipc://{0}'.format(os.path.join(
sock_dir,
'minion_event_{0}_pub.ipc'.format(kwargs.get('id', ''))
'minion_event_{0}_pub.ipc'.format(id_hash)
))
pulluri = 'ipc://{0}'.format(os.path.join(
sock_dir,
'minion_event_{0}_pull.ipc'.format(kwargs.get('id', ''))
'minion_event_{0}_pull.ipc'.format(id_hash)
))
log.debug(
'{0} PUB socket URI: {1}'.format(self.__class__.__name__, puburi)