Merge branch '2014.7' into develop

Conflicts:
	salt/config.py
This commit is contained in:
Colton Myers 2014-09-23 12:43:47 -06:00
commit 3db44821e4
3 changed files with 49 additions and 41 deletions

View File

@ -494,8 +494,10 @@ class LoadPillar(ioflo.base.deeding.Deed):
''' '''
Initial pillar Initial pillar
''' '''
route = {'src': (self.opts.value['id'], 0, None), # default master is the first remote
'dst': ('master', None, 'remote_cmd')} # this default destination will not work with multiple masters
route = {'src': (self.udp_stack.value.local.name, 0, None),
'dst': (self.udp_stack.value.remotes.values()[0].name, None, 'remote_cmd')}
load = {'id': self.opts.value['id'], load = {'id': self.opts.value['id'],
'grains': self.grains.value, 'grains': self.grains.value,
'saltenv': self.opts.value['environment'], 'saltenv': self.opts.value['environment'],
@ -723,18 +725,22 @@ class Router(ioflo.base.deeding.Deed):
sender is the unique name of the remote estate that sent the message sender is the unique name of the remote estate that sent the message
''' '''
try: try:
d_estate = msg['route']['dst'][0] s_estate, s_yard, s_share = msg['route']['src']
d_yard = msg['route']['dst'][1] d_estate, d_yard, d_share = msg['route']['dst']
d_share = msg['route']['dst'][2]
except (ValueError, IndexError): except (ValueError, IndexError):
log.error('Received invalid message: {0}'.format(msg)) log.error('Received invalid message: {0}'.format(msg))
return return
if s_estate is None: # drop
return
if d_estate is None: if d_estate is None:
pass pass
elif d_estate != self.udp_stack.value.local.name: elif d_estate != self.udp_stack.value.local.name:
log.error( log.error(
'Received message for wrong estate: {0}'.format(d_estate)) 'Received message for wrong estate: {0}'.format(d_estate))
return return
if d_yard is not None: if d_yard is not None:
# Meant for another yard, send it off! # Meant for another yard, send it off!
if d_yard in self.uxd_stack.value.nameRemotes: if d_yard in self.uxd_stack.value.nameRemotes:
@ -769,22 +775,32 @@ class Router(ioflo.base.deeding.Deed):
sender is unique name of remote that sent the message sender is unique name of remote that sent the message
''' '''
try: try:
d_estate = msg['route']['dst'][0] s_estate, s_yard, s_share = msg['route']['src']
d_yard = msg['route']['dst'][1] d_estate, d_yard, d_share = msg['route']['dst']
d_share = msg['route']['dst'][2]
except (ValueError, IndexError): except (ValueError, IndexError):
log.error('Received invalid message: {0}'.format(msg)) log.error('Received invalid message: {0}'.format(msg))
return return
if s_yard is None:
return # drop message
if s_estate is None: # substitute local estate
s_estate = self.udp_stack.value.local.name
msg['route']['src'] = (s_estate, s_yard, s_share)
if d_estate is None: if d_estate is None:
pass pass
elif d_estate != self.udp_stack.value.local: elif d_estate != self.udp_stack.value.local.name:
# Forward to the correct estate # Forward to the correct estate
uid = self.udp_stack.value.fetchUidByName(d_estate) if d_estate in self.udp_stack.value.nameRemotes:
self.udp_stack.value.message(msg, uid) self.udp_stack.value.message(msg,
self.udp_stack.value.nameRemotes[d_estate].uid)
return return
if d_share == 'pub_ret': if d_share == 'pub_ret':
if msg.get('__worker_verify') == self.worker_verify.value: if msg.get('__worker_verify') == self.worker_verify.value:
self.publish.value.append(msg) self.publish.value.append(msg)
if d_yard is None: if d_yard is None:
pass pass
elif d_yard != self.uxd_stack.value.local.name: elif d_yard != self.uxd_stack.value.local.name:
@ -931,7 +947,8 @@ class NixExecutor(ioflo.base.deeding.Deed):
'modules': '.salt.loader.modules', 'modules': '.salt.loader.modules',
'returners': '.salt.loader.returners', 'returners': '.salt.loader.returners',
'fun': '.salt.var.fun', 'fun': '.salt.var.fun',
'executors': '.salt.track.executors'} 'executors': '.salt.track.executors',
'udp_stack': '.raet.udp.stack.stack', }
def postinitio(self): def postinitio(self):
''' '''
@ -971,9 +988,9 @@ class NixExecutor(ioflo.base.deeding.Deed):
''' '''
Send the return data back via the uxd socket Send the return data back via the uxd socket
''' '''
route = {'src': (self.udp_stack.value.local.name, stack.local.name, 'jid_ret'),
'dst': (msg['route']['src'][0], None, 'remote_cmd')}
mid = self.opts['id'] mid = self.opts['id']
route = {'src': (mid, stack.local.name, 'jid_ret'),
'dst': (msg['route']['src'][0], None, 'remote_cmd')}
ret['cmd'] = '_return' ret['cmd'] = '_return'
ret['id'] = mid ret['id'] = mid
try: try:

View File

@ -8,6 +8,7 @@ The core behaviors used by minion and master
import time import time
import os import os
import multiprocessing import multiprocessing
import logging
# Import salt libs # Import salt libs
import salt.daemons.masterapi import salt.daemons.masterapi
@ -19,6 +20,8 @@ from raet.lane.yarding import RemoteYard
# Import ioflo libs # Import ioflo libs
import ioflo.base.deeding import ioflo.base.deeding
log = logging.getLogger(__name__)
class WorkerFork(ioflo.base.deeding.Deed): class WorkerFork(ioflo.base.deeding.Deed):
''' '''
@ -153,6 +156,7 @@ class WorkerRouter(ioflo.base.deeding.Deed):
''' '''
Ioinits = { Ioinits = {
'uxd_stack': '.salt.uxd.stack.stack', 'uxd_stack': '.salt.uxd.stack.stack',
'udp_stack': '.raet.udp.stack.stack',
'opts': '.salt.opts', 'opts': '.salt.opts',
'yid': '.salt.yid', 'yid': '.salt.yid',
'worker_verify': '.salt.var.worker_verify', 'worker_verify': '.salt.var.worker_verify',
@ -168,6 +172,13 @@ class WorkerRouter(ioflo.base.deeding.Deed):
self.uxd_stack.value.serviceAll() self.uxd_stack.value.serviceAll()
while self.uxd_stack.value.rxMsgs: while self.uxd_stack.value.rxMsgs:
msg, sender = self.uxd_stack.value.rxMsgs.popleft() msg, sender = self.uxd_stack.value.rxMsgs.popleft()
try:
s_estate, s_yard, s_share = msg['route']['src']
d_estate, d_yard, d_share = msg['route']['dst']
except (ValueError, IndexError):
log.error('Received invalid message: {0}'.format(msg))
return
if 'load' in msg: if 'load' in msg:
cmd = msg['load'].get('cmd') cmd = msg['load'].get('cmd')
if not cmd: if not cmd:
@ -175,10 +186,10 @@ class WorkerRouter(ioflo.base.deeding.Deed):
elif cmd.startswith('__'): elif cmd.startswith('__'):
continue continue
ret = {} ret = {}
if msg['route']['dst'][2] == 'remote_cmd': if d_share == 'remote_cmd':
if hasattr(self.remote.value, cmd): if hasattr(self.remote.value, cmd):
ret['return'] = getattr(self.remote.value, cmd)(msg['load']) ret['return'] = getattr(self.remote.value, cmd)(msg['load'])
elif msg['route']['dst'][2] == 'local_cmd': elif d_share == 'local_cmd':
if hasattr(self.local.value, cmd): if hasattr(self.local.value, cmd):
ret['return'] = getattr(self.local.value, cmd)(msg['load']) ret['return'] = getattr(self.local.value, cmd)(msg['load'])
else: else:
@ -187,10 +198,10 @@ class WorkerRouter(ioflo.base.deeding.Deed):
r_share = 'pub_ret' r_share = 'pub_ret'
ret['__worker_verify'] = self.worker_verify.value ret['__worker_verify'] = self.worker_verify.value
else: else:
r_share = msg['route']['src'][2] r_share = s_share
ret['route'] = { ret['route'] = {
'src': (self.opts.value.get('id', 'master'), self.uxd_stack.value.local.name, None), 'src': (None, self.uxd_stack.value.local.name, None),
'dst': (msg['route']['src'][0], msg['route']['src'][1], r_share) 'dst': (s_estate, s_yard, r_share)
} }
self.uxd_stack.value.transmit(ret, self.uxd_stack.value.transmit(ret,
self.uxd_stack.value.fetchUidByName('manor')) self.uxd_stack.value.fetchUidByName('manor'))

View File

@ -331,7 +331,7 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
self.run_script( self.run_script(
'salt-call', 'salt-call',
'-c {0} --output-file={1} --output-file-append -g'.format( '-c {0} --output-file={1} -g'.format(
self.get_config_dir(), self.get_config_dir(),
output_file output_file
), ),
@ -340,27 +340,7 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
) )
stat2 = os.stat(output_file) stat2 = os.stat(output_file)
self.assertEqual(stat1.st_mode, stat2.st_mode) self.assertEqual(stat1.st_mode, stat2.st_mode)
# Data was appeneded to file # self.assertEqual(stat1.st_ctime, stat2.st_ctime)
self.assertTrue(stat1.st_size < stat2.st_size)
# Let's remove the output file
os.unlink(output_file)
# Not appending data
self.run_script(
'salt-call',
'-c {0} --output-file={1} -g'.format(
self.get_config_dir(),
output_file
),
catch_stderr=True,
with_retcode=True
)
stat3 = os.stat(output_file)
# Mode must have changed since we're creating a new log file
self.assertNotEqual(stat1.st_mode, stat3.st_mode)
# Data was appended to file
self.assertEqual(stat1.st_size, stat3.st_size)
finally: finally:
if os.path.exists(output_file): if os.path.exists(output_file):
os.unlink(output_file) os.unlink(output_file)