Merge pull request #833 from dcolish/develop

Fix dynamic reloading of grains
This commit is contained in:
Thomas S Hatch 2012-03-04 13:33:53 -08:00
commit 66611b9dcf
2 changed files with 19 additions and 22 deletions

View File

@ -141,6 +141,7 @@ class Minion(object):
Return the functions and the returners loaded up from the loader Return the functions and the returners loaded up from the loader
module module
''' '''
self.opts['grains'] = salt.loader.grains(self.opts)
functions = salt.loader.minion_mods(self.opts) functions = salt.loader.minion_mods(self.opts)
returners = salt.loader.returners(self.opts) returners = salt.loader.returners(self.opts)
return functions, returners return functions, returners
@ -397,6 +398,11 @@ class Minion(object):
open(fn_, 'w+').write(self.serial.dumps(ret)) open(fn_, 'w+').write(self.serial.dumps(ret))
return ret_val return ret_val
@property
def master_pub(self):
return 'tcp://{ip}:{port}'.format(ip=self.opts['master_ip'],
port=self.publish_port)
def authenticate(self): def authenticate(self):
''' '''
Authenticate with the master, this method breaks the functional Authenticate with the master, this method breaks the functional
@ -431,14 +437,10 @@ class Minion(object):
''' '''
Lock onto the publisher. This is the main event loop for the minion Lock onto the publisher. This is the main event loop for the minion
''' '''
master_pub = 'tcp://{0}:{1}'.format(
self.opts['master_ip'],
str(self.publish_port)
)
context = zmq.Context() context = zmq.Context()
socket = context.socket(zmq.SUB) socket = context.socket(zmq.SUB)
socket.setsockopt(zmq.SUBSCRIBE, '') socket.setsockopt(zmq.SUBSCRIBE, '')
socket.connect(master_pub) socket.connect(self.master_pub)
if self.opts['sub_timeout']: if self.opts['sub_timeout']:
last = time.time() last = time.time()
while True: while True:
@ -463,7 +465,7 @@ class Minion(object):
socket.close() socket.close()
socket = context.socket(zmq.SUB) socket = context.socket(zmq.SUB)
socket.setsockopt(zmq.SUBSCRIBE, '') socket.setsockopt(zmq.SUBSCRIBE, '')
socket.connect(master_pub) socket.connect(self.master_pub)
last = time.time() last = time.time()
time.sleep(0.05) time.sleep(0.05)
multiprocessing.active_children() multiprocessing.active_children()

View File

@ -163,28 +163,23 @@ class State(object):
python, pyx, or .so. Always refresh if the function is recuse, python, pyx, or .so. Always refresh if the function is recuse,
since that can lay down anything. since that can lay down anything.
''' '''
def _refresh():
self.load_modules()
module_refresh_path = os.path.join(
self.opts['cachedir'],
'module_refresh')
with open(module_refresh_path, 'w+') as f:
f.write('')
if data['state'] == 'file': if data['state'] == 'file':
if data['fun'] == 'managed': if data['fun'] == 'managed':
if data['name'].endswith( if data['name'].endswith(
('.py', '.pyx', '.pyo', '.pyc', '.so')): ('.py', '.pyx', '.pyo', '.pyc', '.so')):
self.load_modules() _refresh()
open(os.path.join(
self.opts['cachedir'],
'module_refresh'),
'w+').write('')
elif data['fun'] == 'recurse': elif data['fun'] == 'recurse':
self.load_modules() _refresh()
open(os.path.join(
self.opts['cachedir'],
'module_refresh'),
'w+').write('')
elif data['state'] == 'pkg': elif data['state'] == 'pkg':
self.load_modules() _refresh()
open(os.path.join(
self.opts['cachedir'],
'module_refresh'),
'w+').write('')
def format_verbosity(self, returns): def format_verbosity(self, returns):
''' '''