desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Assign .ushers by parsing opts'
def action(self):
masters = 'master' port = None if self.opts.value.get('cluster_mode', False): masters = 'cluster_masters' self.ushers.value = daemons.extract_masters(self.opts.value, masters=masters, port=port)
'Assign .ushers by parsing opts'
def action(self):
masters = 'cluster_masters' port = 'raet_port' self.ushers.value = daemons.extract_masters(self.opts.value, masters=masters, port=port, raise_if_empty=False)
'Populate loads from masters in stack.remotes'
def action(self, **kwa):
if self.opts.value.get('cluster_mode'): for remote in list(self.stack.value.remotes.values()): if (remote.kind == kinds.applKinds.master): self.masters.value[remote.name] = odict(load=0.0, expire=self.store.stamp)
'Assign class defaults'
def _prepare(self):
RoadStack.Bk = raeting.BodyKind.msgpack.value RoadStack.JoinentTimeout = 0.0
'enter action should only run once to setup road stack. moved from _prepare so can do clean up before stack is initialized do salt raet road stack setup at enter'
def action(self):
kind = self.opts.value['__role'] if (kind not in kinds.APPL_KINDS): emsg = "Invalid application kind = '{0}'.".format(kind) log.error((emsg + '\n')) raise ValueError(emsg) role = self.opts.value.get('id', '') if (not role): emsg = 'Missing role required ...
'Close udp socket'
def action(self, **kwa):
if (self.stack.value and isinstance(self.stack.value, RoadStack)): self.stack.value.server.close()
'Join with all masters'
def action(self, **kwa):
stack = self.stack.value if (stack and isinstance(stack, RoadStack)): refresh_masters = (self.opts.value.get('raet_clear_remote_masters', True) or (not stack.remotes)) refresh_all = (self.opts.value.get('raet_clear_remotes', True) or (not stack.remotes)) if refresh_masters: f...
'Update .status share'
def action(self, **kwa):
stack = self.stack.value joined = False if (stack and isinstance(stack, RoadStack)): if stack.remotes: joined = any([remote.joined for remote in list(stack.remotes.values()) if (remote.kind == kinds.applKinds.master)]) self.status.update(joined=joined)
'Update .status share'
def action(self, **kwa):
stack = self.stack.value rejected = False if (stack and isinstance(stack, RoadStack)): if stack.remotes: rejected = all([(remote.acceptance == raeting.Acceptance.rejected.value) for remote in stack.remotes.values() if (remote.kind == kinds.applKinds.master)]) else: re...
'Receive any udp packets on server socket and put in rxes Send any packets in txes'
def action(self, **kwa):
stack = self.stack.value if (stack and isinstance(stack, RoadStack)): for remote in stack.remotes.values(): if (remote.kind == kinds.applKinds.master): stack.allow(uid=remote.uid, timeout=0.0)
'Update .status share'
def action(self, **kwa):
stack = self.stack.value allowed = False if (stack and isinstance(stack, RoadStack)): if stack.remotes: allowed = any([remote.allowed for remote in list(stack.remotes.values()) if (remote.kind == kinds.applKinds.master)]) self.status.update(allowed=allowed)
'Manage the presence of any remotes availables is set of names of alive remotes which are also allowed changeds is is share with two fields: plus is set of names of newly available remotes minus is set of names of newly unavailable remotes alloweds is dict of allowed remotes keyed by name aliveds is dict of alived remo...
def action(self, **kwa):
stack = self.stack.value if (stack and isinstance(stack, RoadStack)): stack.manage(cascade=True) self.availables.value = set(self.stack.value.availables) self.changeds.update(plus=set(self.stack.value.changeds['plus'])) self.changeds.update(minus=set(self.stack.value.changeds['mi...
'Queue up message'
def action(self, **kwa):
rxMsgs = self.rxmsgs.value while rxMsgs: (msg, name) = rxMsgs.popleft() console.terse('\nReceived....\n{0}\n'.format(msg))
'Return the functions and the returners loaded up from the loader module'
def _load_modules(self):
if (self.grain_time.value is None): self.grain_time.value = 0.0 modules_max_memory = False if ((self.opts.value.get('modules_max_memory', (-1)) > 0) and HAS_PSUTIL and HAS_RESOURCE): log.debug('modules_max_memory set, enforcing a maximum of {0}'.format(self.opts.value['modu...
'Initial pillar'
def action(self):
available_masters = [remote for remote in list(self.road_stack.value.remotes.values()) if remote.allowed] while (not available_masters): available_masters = [remote for remote in self.road_stack.value.remotes.values() if remote.allowed] time.sleep(0.1) random_master = self.opts.value.get('ra...
'Map opts and make the schedule object'
def _prepare(self):
self.utils.value = salt.loader.utils(self.opts.value) self.modules.value = salt.loader.minion_mods(self.opts.value, utils=self.utils.value) self.returners.value = salt.loader.returners(self.opts.value, self.modules.value) self.schedule = salt.utils.schedule.Schedule(self.opts.value, self.modules.value, ...
'Eval the schedule'
def action(self):
self.schedule.eval()
'Set up required objects and queues'
def _prepare(self):
pass
'Run once at enter'
def action(self):
kind = self.opts.value['__role'] if (kind not in kinds.APPL_KINDS): emsg = "Invalid application kind = '{0}' for manor lane.".format(kind) log.error((emsg + '\n')) raise ValueError(emsg) if (kind in [kinds.APPL_KIND_NAMES[kinds.applKinds.master], kinds.APPL_KIND_...
'Close uxd socket'
def action(self, **kwa):
if (self.stack.value and isinstance(self.stack.value, LaneStack)): self.stack.value.server.close()
'Process inboud queues'
def action(self):
self.road_stack.value.serviceAll()
'Process inboud queues'
def action(self):
self.road_stack.value.serviceAllRx()
'Process inbound queues'
def action(self):
self.road_stack.value.serviceAllTx()
'Process inboud queues'
def action(self):
self.lane_stack.value.serviceAllRx()
'Process outbound queues'
def action(self):
self.lane_stack.value.serviceAllTx()
'Send to the right queue msg is the message body dict sender is the unique name of the remote estate that sent the message'
def _process_road_rxmsg(self, msg, sender):
pass
'Send uxd messages tot he right queue or forward them to the correct yard etc. msg is message body dict sender is unique name of remote that sent the message'
def _process_lane_rxmsg(self, msg, sender):
pass
'Assign and return the name of the estate for the default master or empty if none If the default master is no longer available then selects one of the available masters If clustered is True then use load balancing algorithm to select master'
def _get_master_estate_name(self, clustered=False):
opts = self.opts.value master = self.road_stack.value.nameRemotes.get(self.master_estate_name.value) if ((not master) or (not master.alived)): available_masters = [remote for remote in six.Iterator(self.road_stack.value.remotes) if remote.alived] if available_masters: random_mast...
'Return set that is intersection of associated minion estates for roles in minions and the set of available minion estates.'
def _availablize(self, minions):
suffix = '_{0}'.format(kinds.APPL_KIND_NAMES[kinds.applKinds.minion]) return list((set(minions) & set((name.rstrip(suffix) for name in self.availables.value))))
'Process the messages!'
def action(self):
while self.road_stack.value.rxMsgs: (msg, sender) = self.road_stack.value.rxMsgs.popleft() self._process_road_rxmsg(msg=msg, sender=sender) while self.laters.value: (msg, sender) = self.laters.value.popleft() self.lane_stack.value.rxMsgs.append((msg, sender)) while self.lane_...
'Send to the right queue msg is the message body dict sender is the unique name of the remote estate that sent the message'
def _process_road_rxmsg(self, msg, sender):
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 (s_estate is None): return log.debug('**** Road ...
'Send uxd messages tot he right queue or forward them to the correct yard etc. msg is message body dict sender is unique name of remote that sent the message'
def _process_lane_rxmsg(self, msg, sender):
try: (s_estate, s_yard, s_share) = msg['route']['src'] (d_estate, d_yard, d_share) = msg['route']['dst'] except (ValueError, IndexError): log.error('Lane Router Received invalid message: {0}'.format(msg)) return if (s_yard is None): return if (s_est...
'Send to the right queue msg is the message body dict sender is the unique name of the remote estate that sent the message'
def _process_road_rxmsg(self, msg, sender):
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 (s_estate is None): return log.debug('**** Road ...
'Send uxd messages tot he right queue or forward them to the correct yard etc. msg is message body dict sender is unique name of remote that sent the message'
def _process_lane_rxmsg(self, msg, sender):
try: (s_estate, s_yard, s_share) = msg['route']['src'] (d_estate, d_yard, d_share) = msg['route']['dst'] except (ValueError, IndexError): log.error('Lane Router Received invalid message: {0}'.format(msg)) return if (s_yard is None): return if (s_est...
'Assign and return the name of the estate for the default master or empty if none If the default master is no longer available then selects one of the available masters'
def _get_master_estate_name(self, clustered=False):
opts = self.opts.value master = self.road_stack.value.nameRemotes.get(self.master_estate_name.value) if ((not master) or (not master.alived)): available_masters = [remote for remote in list(self.road_stack.value.remotes.values()) if remote.alived] if available_masters: random_mas...
'Return set that is intersection of associated minion estates for roles in minions and the set of available minion estates.'
def _availablize(self, minions):
suffix = '_{0}'.format(kinds.APPL_KIND_NAMES[kinds.applKinds.minion]) return list((set(minions) & set((name.rstrip(suffix) for name in self.availables.value))))
'register an incoming event request with the requesting yard id'
def _register_event_yard(self, msg):
self.event_yards.value.add(msg['route']['src'][1])
'Forward an event message to all subscribed yards Event message has a route'
def _forward_event(self, msg):
rm_ = [] if (msg.get('tag') == 'pillar_refresh'): self.pillar_refresh.value = True if (msg.get('tag') == 'module_refresh'): self.module_refresh.value = True for y_name in self.event_yards.value: if (y_name not in self.lane_stack.value.nameRemotes): rm_.append(y_name) ...
'Register event requests Iterate over the registered event yards and fire!'
def action(self):
while self.event_req.value: self._register_event_yard(self.event_req.value.popleft()) while self.event.value: self._forward_event(self.event.value.popleft())
'Forward an event message to all subscribed yards Event message has a route Also rebroadcast to all masters in cluster'
def _forward_event(self, msg):
super(SaltRaetEventerMaster, self)._forward_event(msg) if self.opts.value.get('cluster_mode'): if (msg.get('origin') is None): masters = (self.availables.value & set((remote.name for remote in list(self.road_stack.value.remotes.values()) if (remote.kind == kinds.applKinds.master)))) ...
'Forward an presence message to all subscribed yards Presence message has a route'
def _send_presence(self, msg):
y_name = msg['route']['src'][1] if (y_name not in self.lane_stack.value.nameRemotes): pass else: if (('data' in msg) and ('state' in msg['data'])): state = msg['data']['state'] else: state = None if (state in [None, 'available', 'present']): ...
'Register presence requests Iterate over the registered presence yards and fire!'
def action(self):
while self.presence_req.value: self._send_presence(self.presence_req.value.popleft())
'Forward a stats message to all subscribed yards Stats message has a route'
def _send_stats(self, msg):
pass
'Iterate over the registered stats requests and fire!'
def action(self):
while self.stats_req.value: self._send_stats(self.stats_req.value.popleft())
'Forward a stats message to all subscribed yards Stats message has a route'
def _send_stats(self, msg):
y_name = msg['route']['src'][1] if (y_name not in self.lane_stack.value.nameRemotes): return stats = self._get_stats(msg.get('tag')) if (stats is None): return route = {'dst': (None, None, 'event_fire'), 'src': (None, self.lane_stack.value.local.name, None)} repl = {'route': rout...
'Forward a stats message to all subscribed yards Stats message has a route'
def _send_stats(self, msg):
(s_estate, s_yard, s_share) = msg['route']['src'] if (s_estate not in self.road_stack.value.nameRemotes): return stats = self._get_stats(msg.get('tag')) if (stats is None): return route = {'dst': (s_estate, s_yard, 'event_fire'), 'src': (self.road_stack.value.name, self.lane_stack.va...
'Publish the message out to the targeted minions'
def _publish(self, pub_msg):
stack = self.stack.value pub_data = pub_msg['return'] minions = (self.availables.value & set((remote.name for remote in list(stack.remotes.values()) if (remote.kind in [kinds.applKinds.minion, kinds.applKinds.syndic])))) for minion in minions: uid = self.stack.value.fetchUidByName(minion) ...
'Pop the publish queue and publish the requests!'
def action(self):
while self.publish.value: self._publish(self.publish.value.popleft())
'Only call once, this will start the engine processes'
def action(self):
salt.engines.start_engines(self.opts.value, self.proc_mgr.value)
'Run the beacons'
def action(self):
self.beacon.value = salt.beacons.Beacon(self.opts.value, self.modules.value)
'Run the beacons'
def action(self):
if ('config.merge' in self.modules.value): b_conf = self.modules.value['config.merge']('beacons') if b_conf: try: events = self.beacon.value.process(b_conf) self.master_events.value.extend(events) self.event.value.extend(events) ...
'Takes a template and a job and fills the template with fake return data associated with the job'
def _fill_tmpl(self, pub):
msg = {'load': {'fun_args': [], 'jid': pub['return']['pub']['jid'], 'return': True, 'retcode': 0, 'success': True, 'cmd': '_return', 'fun': u'test.ping', 'id': 'silver'}, 'route': {'src': (u'silver_minion', u'jobber50e73ccefd052167c7', 'jid_ret'), 'dst': (u'silver_master_master', None, 'remote_cmd')}} log.debug...
'Map opts for convenience'
def _prepare(self):
self.opts = self.opts_store.value self.proc_dir = salt.minion.get_proc_dir(self.opts['cachedir']) self.serial = salt.payload.Serial(self.opts) self.executors.value = {}
'Setup and return the LaneStack and Yard used by the jobber yard to communicate with the minion manor yard'
def _setup_jobber_stack(self):
role = self.opts.get('id', '') if (not role): emsg = 'Missing role required to setup Jobber Lane.' log.error((emsg + '\n')) raise ValueError(emsg) kind = self.opts['__role'] if (kind not in kinds.APPL_KINDS): emsg = "Invalid application kind = ...
'Send the return data back via the uxd socket'
def _return_pub(self, msg, ret, stack):
route = {'src': (self.road_stack.value.local.name, stack.local.name, 'jid_ret'), 'dst': (msg['route']['src'][0], None, 'remote_cmd')} mid = self.opts['id'] ret['cmd'] = '_return' ret['id'] = mid try: oput = self.modules.value[ret['fun']].__outputter__ except (KeyError, AttributeError, Ty...
'Pull the queue for functions to execute'
def action(self):
while self.fun.value: msg = self.fun.value.popleft() data = msg.get('pub') match = getattr(self.matcher.value, '{0}_match'.format(data.get('tgt_type', 'glob')))(data['tgt']) if (not match): continue if ('user' in data): log.info('User {0[user]} E...
'Execute the run in a dedicated process'
def proc_run(self, msg):
data = msg['pub'] fn_ = os.path.join(self.proc_dir, data['jid']) self.opts['__ex_id'] = data['jid'] salt.utils.daemonize_if(self.opts) salt.transport.jobber_stack = stack = self._setup_jobber_stack() (src_estate, src_yard, src_share) = msg['route']['src'] salt.transport.jobber_estate_name = ...
'Assign self.opts'
def __init__(self, opts):
self.opts = opts self.preloads = explode_opts(self.opts) self.access_keys = salt.daemons.masterapi.access_keys(self.opts) self.preloads.append(('.salt.access_keys', dict(value=self.access_keys)))
'Start up ioflo port = self.opts[\'raet_port\']'
def start(self, behaviors=None):
if (behaviors is None): behaviors = [] behaviors.extend(['salt.daemons.flo']) console_logdir = self.opts.get('ioflo_console_logdir', '') if console_logdir: consolepath = os.path.join(console_logdir, 'master.log') else: consolepath = '' ioflo.app.run.start(name='master', p...
'Assign self.opts'
def __init__(self, opts):
self.opts = opts
'Start up ioflo port = self.opts[\'raet_port\']'
def tune_in(self, behaviors=None):
if (behaviors is None): behaviors = [] behaviors.extend(['salt.daemons.flo']) preloads = explode_opts(self.opts) console_logdir = self.opts.get('ioflo_console_logdir', '') if console_logdir: consolepath = os.path.join(console_logdir, 'minion.log') else: consolepath = '' ...
'Start up caller minion for salt-call when there is no local minion'
def call_in(self, behaviors=None):
if (behaviors is None): behaviors = [] behaviors.extend(['salt.daemons.flo']) preloads = explode_opts(self.opts) console_logdir = self.opts.get('ioflo_console_logdir', '') if console_logdir: consolepath = os.path.join(console_logdir, 'caller.log') else: consolepath = '' ...
'Spin up a worker, do this in s multiprocess'
def run(self):
behaviors = ['salt.daemons.flo'] preloads = [('.salt.opts', dict(value=self.opts))] console_logdir = self.opts.get('ioflo_console_logdir', '') if console_logdir: consolepath = os.path.join(console_logdir, 'maintenance.log') else: consolepath = '' ioflo.app.run.start(name='mainten...
'Set up the objects used in the maint process'
def action(self):
self.fileserver.value = salt.fileserver.Fileserver(self.opts.value) self.runners.value = salt.loader.runner(self.opts.value) self.ckminions.value = salt.utils.minions.CkMinions(self.opts.value) self.pillargitfs.value = salt.daemons.masterapi.init_git_pillar(self.opts.value)
'Clean!'
def action(self):
salt.daemons.masterapi.clean_fsbackend(self.opts.value)
'Clear out the old jobs cache'
def action(self):
salt.daemons.masterapi.clean_old_jobs(self.opts.value)
'Update!'
def action(self):
for pillargit in self.pillargitfs.value: pillargit.update() salt.daemons.masterapi.fileserver_update(self.fileserver.value)
'Spin up a worker, do this in multiprocess windex is worker index'
def run(self):
self.opts['__worker'] = True behaviors = ['salt.daemons.flo'] preloads = [('.salt.opts', dict(value=self.opts)), ('.salt.var.worker_verify', dict(value=self.worker_verify))] preloads.append(('.salt.var.fork.worker.windex', dict(value=self.windex))) preloads.append(('.salt.var.zmq.master_key', dict(v...
'Set up the uxd stack and behaviors'
def action(self):
name = 'worker{0}'.format(self.windex.value) kind = self.opts.value['__role'] if (kind not in kinds.APPL_KINDS): emsg = "Invalid application kind = '{0}' for Master Worker.".format(kind) log.error((emsg + '\n')) raise ValueError(emsg) if (kind in [kinds.APPL_...
'Read in a command and execute it, send the return back up to the main master process'
def action(self):
self.lane_stack.value.serviceAll() while self.lane_stack.value.rxMsgs: (msg, sender) = self.lane_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): ...
'Assign master key to .salt.var.zmq.master_key Copy opts[\'aes\'] to .salt.var.zmq.aes'
def action(self):
self.mkey.value = salt.crypt.MasterKeys(self.opts.value) self.aes.value = self.opts.value['aes']
'Start the ret port binding'
def run(self):
self.context = zmq.Context(self.opts['worker_threads']) self.uri = 'tcp://{interface}:{ret_port}'.format(**self.opts) log.info('ZMQ Ret port binding to {0}'.format(self.uri)) self.clients = self.context.socket(zmq.ROUTER) if ((self.opts['ipv6'] is True) and hasattr(zmq, 'IPV4ONLY')): ...
'Initializes zmq Put here so only runs initialization if we want multi-headed master'
def action(self):
self.crypticle.value = salt.crypt.Crypticle(self.opts.value, self.opts.value.get('aes'))
'Set up tracking value(s)'
def _prepare(self):
if (not HAS_ZMQ): return self.created = False self.serial = salt.payload.Serial(self.opts.value)
'Create the publish port if it is not available and then publish the messages on it'
def action(self):
if (not self.zmq_behavior): return if (not self.created): self.context = zmq.Context(1) self.pub_sock = self.context.socket(zmq.PUB) try: self.pub_sock.setsockopt(zmq.HWM, self.opts.value.get('pub_hwm', 1000)) except AttributeError: self.pub_sock.s...
'Create the initial seting value for the worker'
def _prepare(self):
self.created = False
'Create the master MWorker if it is not present, then iterate over the connection with the ioflo sequence'
def action(self):
if (not self.created): crypticle = salt.crypt.Crypticle(self.opts.value, self.aes.value) self.worker = salt.master.FloMWorker(self.opts.value, self.key.value) self.worker.setup() self.created = True log.info('Started ZMQ worker') self.worker.handle_request()
'Check if the specified filename has correct permissions'
def check_permissions(self, filename):
if salt.utils.platform.is_windows(): return True try: user = self.opts['user'] pwnam = pwd.getpwnam(user) uid = pwnam[2] gid = pwnam[3] groups = salt.utils.get_gid_list(user, include_default=False) except KeyError: log.error('Failed to determine ...
'Check a keyid for membership in a signing file'
def check_signing_file(self, keyid, signing_file):
if ((not signing_file) or (not os.path.exists(signing_file))): return False if (not self.check_permissions(signing_file)): message = 'Wrong permissions for {0}, ignoring content' log.warning(message.format(signing_file)) return False with salt.utils.files.fopen...
'Check a keyid for membership in a autosign directory.'
def check_autosign_dir(self, keyid):
autosign_dir = os.path.join(self.opts['pki_dir'], 'minions_autosign') expire_minutes = self.opts.get('autosign_timeout', 120) if (expire_minutes > 0): min_time = (time.time() - (60 * int(expire_minutes))) for (root, dirs, filenames) in os.walk(autosign_dir): for f in filenames: ...
'Checks if the specified keyid should automatically be rejected.'
def check_autoreject(self, keyid):
return self.check_signing_file(keyid, self.opts.get('autoreject_file', None))
'Checks if the specified keyid should automatically be signed.'
def check_autosign(self, keyid):
if self.opts['auto_accept']: return True if self.check_signing_file(keyid, self.opts.get('autosign_file', None)): return True if self.check_autosign_dir(keyid): return True return False
'Set the local file objects from the file server interface'
def __setup_fileserver(self):
fs_ = salt.fileserver.Fileserver(self.opts) self._serve_file = fs_.serve_file self._file_find = fs_._find_file self._file_hash = fs_.file_hash self._file_list = fs_.file_list self._file_list_emptydirs = fs_.file_list_emptydirs self._dir_list = fs_.dir_list self._symlink_list = fs_.symlin...
'Verify that the passed information authorized a minion to execute'
def __verify_minion_publish(self, load):
if ('peer' not in self.opts): return False if (not isinstance(self.opts['peer'], dict)): return False if any(((key not in load) for key in ('fun', 'arg', 'tgt', 'ret', 'id'))): return False if re.match('publish.*', load['fun']): return False perms = [] for match i...
'Return the master options to the minion'
def _master_opts(self, load):
mopts = {} file_roots = {} envs = self._file_envs() for saltenv in envs: if (saltenv not in file_roots): file_roots[saltenv] = [] mopts['file_roots'] = file_roots mopts['top_file_merging_strategy'] = self.opts['top_file_merging_strategy'] mopts['env_order'] = self.opts['e...
'Return the results from master_tops if configured'
def _master_tops(self, load, skip_verify=False):
if (not skip_verify): if ('id' not in load): log.error('Received call for external nodes without an id') return {} if (not salt.utils.verify.valid_id(self.opts, load['id'])): return {} opts = {} grains = {} ret = {} if ('opts' ...
'Gathers the data from the specified minions\' mine'
def _mine_get(self, load, skip_verify=False):
if (not skip_verify): if any(((key not in load) for key in ('id', 'tgt', 'fun'))): return {} if ('mine_get' in self.opts): if (not isinstance(self.opts['mine_get'], dict)): return {} perms = set() for match in self.opts['mine_get']: if re.match...
'Return the mine data'
def _mine(self, load, skip_verify=False):
if (not skip_verify): if (('id' not in load) or ('data' not in load)): return False if (self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False)): cbank = 'minions/{0}'.format(load['id']) ckey = 'mine' if (not load.get('clear', False)): ...
'Allow the minion to delete a specific function from its own mine'
def _mine_delete(self, load):
if (('id' not in load) or ('fun' not in load)): return False if (self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False)): cbank = 'minions/{0}'.format(load['id']) ckey = 'mine' try: data = self.cache.fetch(cbank, ckey) if (...
'Allow the minion to delete all of its own mine contents'
def _mine_flush(self, load, skip_verify=False):
if ((not skip_verify) and ('id' not in load)): return False if (self.opts.get('minion_data_cache', False) or self.opts.get('enforce_mine_cache', False)): return self.cache.flush('minions/{0}'.format(load['id']), 'mine') return True
'Allows minions to send files to the master, files are sent to the master file cache'
def _file_recv(self, load):
if any(((key not in load) for key in ('id', 'path', 'loc'))): return False if ((not self.opts['file_recv']) or os.path.isabs(load['path'])): return False if (os.path.isabs(load['path']) or ('../' in load['path'])): return False if (not salt.utils.verify.valid_id(self.opts, load['...
'Return the pillar data for the minion'
def _pillar(self, load):
if any(((key not in load) for key in ('id', 'grains'))): return False log.debug('Master _pillar using ext: {0}'.format(load.get('ext'))) pillar = salt.pillar.get_pillar(self.opts, load['grains'], load['id'], load.get('saltenv', load.get('env')), load.get('ext'), self.mminion.functions, p...
'Receive an event from the minion and fire it on the master event interface'
def _minion_event(self, load):
if ('id' not in load): return False if (('events' not in load) and (('tag' not in load) or ('data' not in load))): return False if ('events' in load): for event in load['events']: if ('data' in event): event_data = event['data'] else: ...
'Handle the return data sent from the minions'
def _return(self, load):
endtime = salt.utils.jid.jid_to_time(salt.utils.jid.gen_jid()) if any(((key not in load) for key in ('return', 'jid', 'id'))): return False if (load['jid'] == 'req'): prep_fstr = '{0}.prep_jid'.format(self.opts['master_job_cache']) load['jid'] = self.mminion.returners[prep_fstr](noca...
'Receive a syndic minion return and format it to look like returns from individual minions.'
def _syndic_return(self, load):
if any(((key not in load) for key in ('return', 'jid', 'id'))): return None if ('load' in load): fstr = '{0}.save_load'.format(self.opts['master_job_cache']) self.mminion.returners[fstr](load['jid'], load['load']) for (key, item) in six.iteritems(load['return']): ret = {'jid'...
'Execute a runner from a minion, return the runner\'s function data'
def minion_runner(self, load):
if ('peer_run' not in self.opts): return {} if (not isinstance(self.opts['peer_run'], dict)): return {} if any(((key not in load) for key in ('fun', 'arg', 'id'))): return {} perms = set() for match in self.opts['peer_run']: if re.match(match, load['id']): ...
'Request the return data from a specific jid, only allowed if the requesting minion also initialted the execution.'
def pub_ret(self, load, skip_verify=False):
if ((not skip_verify) and any(((key not in load) for key in ('jid', 'id')))): return {} else: auth_cache = os.path.join(self.opts['cachedir'], 'publish_auth') if (not os.path.isdir(auth_cache)): os.makedirs(auth_cache) jid_fn = os.path.join(auth_cache, load['jid']) ...
'Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt functions The config will look l...
def minion_pub(self, load):
if (not self.__verify_minion_publish(load)): return {} pub_load = {'fun': load['fun'], 'arg': salt.utils.args.parse_input(load['arg'], no_parse=load.get('no_parse', [])), 'tgt_type': load.get('tgt_type', 'glob'), 'tgt': load['tgt'], 'ret': load['ret'], 'id': load['id']} if ('tgt_type' in load): ...
'Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt functions The config will look l...
def minion_publish(self, load):
if (not self.__verify_minion_publish(load)): return {} pub_load = {'fun': load['fun'], 'arg': salt.utils.args.parse_input(load['arg'], no_parse=load.get('no_parse', [])), 'tgt_type': load.get('tgt_type', 'glob'), 'tgt': load['tgt'], 'ret': load['ret'], 'id': load['id']} if ('tmo' in load): t...
'Allow a minion to request revocation of its own key'
def revoke_auth(self, load):
if ('id' not in load): return False keyapi = salt.key.Key(self.opts) keyapi.delete_key(load['id'], preserve_minions=load.get('preserve_minion_cache', False)) return True