def displayDistSearch(**kwargs): """ called for distributed search stuff """ if kwargs['cmd'] == 'enable' and kwargs['obj'] == 'dist-search': print DIST_SEARCH_ENABLE print RESTART_SPLUNK elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'dist-search': print DIST_SEARCH_DISABLE print RESTART_SPLUNK elif kwargs['cmd'] == 'display' and kwargs['obj'] == 'dist-search': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) for entry in atomFeed: if entry.title == 'distributedSearch': d = nodeToPrimitive(entry.rawcontents) if not util.normalizeBoolean(d['disabled']): print DIST_SEARCH_DISPLAY_ENABLED return print DIST_SEARCH_DISPLAY_DISABLED elif kwargs['cmd'] == 'add': print SEARCH_SERVER_ADD elif kwargs['cmd'] == 'remove': print SEARCH_SERVER_REMOVE elif kwargs['cmd'] == 'edit': print DIST_SEARCH_EDIT elif kwargs['cmd'] == 'list' and kwargs['obj'] == 'search-server': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) servers_present = False for entry in atomFeed: d = nodeToPrimitive(entry.rawcontents) if d.has_key('status'): servers_present = True print DIST_SEARCH_LIST % (entry.title, d['status'], d['peerType']) if not servers_present: print DIST_SEARCH_LIST_NONE elif kwargs['cmd'] == 'display' and kwargs['obj'] == 'discoverable': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) for entry in atomFeed: d = nodeToPrimitive(entry.rawcontents) if d.has_key('autoAddServers') and util.normalizeBoolean(d['autoAddServers']): print DISPLAY_DISCOVERABLE_ENABLED else: print DISPLAY_DISCOVERABLE_DISABLED break elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'discoverable': print ENABLE_DISCOVERABLE print RESTART_SPLUNK elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'discoverable': print DISABLE_DISCOVERABLE print RESTART_SPLUNK
def displaySyncSearch(**kwargs): """ called for displaying sync search results. """ if kwargs.has_key('detach') and util.normalizeBoolean(kwargs['detach']): return displayAsyncSearch(**kwargs) job = kwargs['searchjob'] if job.messages: for mtype in job.messages: for msg in job.messages[mtype]: print >> sys.stderr, "%s: %s" % (mtype.upper(), msg) if not job.resultCount: return format = kwargs.get('output', job.reportSearch and 'table' or 'rawevents') time_format = kwargs.get('time_format', '%+') if format == 'rawevents' and '_raw' in job.results.fieldOrder: job.setFetchOptions(fieldList='_raw') for result in job.results: print unicode(result['_raw']) return if format == 'raw': first = True for result in job.results: if not first: print '-'*80 first = False for field in result: print "\t%s = %s" % (field, result[field]) return fields = filter((lambda x: x[0] != '_' or x == '_raw' or x == '_time'), job.results.fieldOrder) job.setFetchOption(fieldList=fields, time_format=time_format) if format == 'csv': print job.getFeed('results', outputMode='csv') return hasHeader = util.normalizeBoolean(kwargs.get('header', 'true')) if hasHeader: results = [fields] else: results = [] for result in job.results: resultLine = [unicode(result.get(field, None)) for field in fields] results.append(resultLine) print indent(rows=results, hasHeader=hasHeader, separateRows=False)
def savedSearchJSONIsAlert(savedSearchJSON): content = savedSearchJSON['entry'][0]['content'] is_scheduled = util.normalizeBoolean(content['is_scheduled']) alert_type = content['alert_type'] alert_track = util.normalizeBoolean(content['alert.track']) actions = util.normalizeBoolean(content.get('actions')) isRealtime = content['dispatch.earliest_time'].startswith('rt') and content['dispatch.latest_time'].startswith('rt') return is_scheduled and ((alert_type != 'always') or alert_track or (isRealtime and actions))
def savedSearchJSONIsAlert(savedSearchJSON): content = savedSearchJSON['entry'][0]['content'] is_scheduled = util.normalizeBoolean(content['is_scheduled']) alert_type = content['alert_type'] alert_track = util.normalizeBoolean(content['alert.track']) actions = util.normalizeBoolean(content.get('actions')) isRealtime = content['dispatch.earliest_time'].startswith( 'rt') and content['dispatch.latest_time'].startswith('rt') return is_scheduled and ((alert_type != 'always') or alert_track or (isRealtime and actions))
def displayApp(**kwargs): """ called for displaying applications stuff. """ if kwargs['cmd'] == 'display': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) print '\n' for atomEntry in atomFeed: d = nodeToPrimitive(atomEntry.rawcontents) appName = atomEntry.title enabled = 'DISABLED' if util.normalizeBoolean( d['disabled']) else 'ENABLED' visible = 'VISIBLE' if util.normalizeBoolean( d['visible']) else 'INVISIBLE' configured = 'CONFIGURED' if util.normalizeBoolean( d['configured']) else 'UNCONFIGURED' print ' %-25s %-8s %-9s %-12s\n' % (appName, enabled, visible, configured) elif kwargs['cmd'] == 'enable': print APP_ENABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'disable': print APP_DISABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'remove': print APP_REMOVED % kwargs['eaiArgsList']['name'] elif kwargs['cmd'] == 'create': print APP_CREATED % kwargs['eaiArgsList']['name'] elif kwargs['cmd'] == 'edit': print APP_EDITED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'package': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = nodeToPrimitive(atomFeed[0].rawcontents) print APP_PACKAGED % (d['name'], d['path']) elif kwargs['cmd'] == 'install': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = nodeToPrimitive(atomFeed[0].rawcontents) print APP_INSTALLED % (d['name'], d['status'])
def displayReceiver(**kwargs): """ called for displaying receiver configuration stuff. """ atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if kwargs['cmd'] == 'display' and kwargs['obj'] == 'listen': at_least_one = False try: if len(atomFeed): for ele in atomFeed: d = nodeToPrimitive(ele.rawcontents) if not util.normalizeBoolean(d['disabled']): print TCP_RECEIVE % ele.title at_least_one = True if not at_least_one: print TCP_RECEIVE_NONE else: print TCP_RECEIVE_NONE except IndexError: print TCP_RECEIVE_NONE elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'listen': print TCP_RECEIVE_ADD % kwargs['eaiArgsList']['name'] elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'listen': if len(atomFeed): print TCP_RECEIVE_DISABLE % atomFeed[0].title else: print TCP_RECEIVE_REMOVE
def displayApp(**kwargs): """ called for displaying applications stuff. """ if kwargs['cmd'] == 'display': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) print '\n' for atomEntry in atomFeed: d = nodeToPrimitive(atomEntry.rawcontents) appName = atomEntry.title enabled = 'DISABLED' if util.normalizeBoolean(d['disabled']) else 'ENABLED' visible = 'VISIBLE' if util.normalizeBoolean(d['visible']) else 'INVISIBLE' configured = 'CONFIGURED' if util.normalizeBoolean(d['configured']) else 'UNCONFIGURED' print ' %-25s %-8s %-9s %-12s\n' % (appName, enabled, visible, configured) elif kwargs['cmd'] == 'enable': print APP_ENABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'disable': print APP_DISABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'remove': print APP_REMOVED % kwargs['eaiArgsList']['name'] elif kwargs['cmd'] == 'create': print APP_CREATED % kwargs['eaiArgsList']['name'] elif kwargs['cmd'] == 'edit': print APP_EDITED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'package': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = nodeToPrimitive(atomFeed[0].rawcontents) print APP_PACKAGED % (d['name'], d['path']) elif kwargs['cmd'] == 'install': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = nodeToPrimitive(atomFeed[0].rawcontents) print APP_INSTALLED % (d['name'], d['status'])
def displayMonitor(**kwargs): """ called for displaying all monitor related commands. """ if kwargs['cmd'] == 'remove': print MONITOR_REMOVE % kwargs['eaiArgsList'] elif kwargs['cmd'] == 'add': print MONITOR_ADD % kwargs['eaiArgsList'] elif kwargs['cmd'] == 'edit': print MONITOR_EDIT % kwargs['eaiArgsList'] elif kwargs['cmd'] == 'list': atom = rest.format.parseFeedDocument(kwargs['serverContent']) dir_entries = '' file_entries = '' for entry in atom: d = nodeToPrimitive(entry.rawcontents) # entry.links is a list of tuples, link name->href. if len([x for x in entry.links if x[0] == 'members']) > 0: dir_entries += '\n\t%s' % entry.title dir_files = extractTitleFeed(filter( lambda t: t[0] == 'members', entry.links), sessionKey=kwargs['sessionKey']) if dir_files: for f in dir_files: dir_entries += '\n\t\t%s' % f else: dir_entries += '\n\t\t[No files in this directory monitored.]' else: if kwargs['eaiArgsList'].has_key( 'show-hidden') and util.normalizeBoolean( kwargs['eaiArgsList']['show-hidden']): file_entries += '\t%s\n' % entry.title elif not isInternalTail(entry.title): file_entries += '\t%s\n' % entry.title if not file_entries: file_entries = 'Monitored Files:\n\t\t[No files monitored.]' else: file_entries = 'Monitored Files:\n' + file_entries.encode('utf-8') if not dir_entries: dir_entries = 'Monitored Directories:\n\t\t[No directories monitored.]' else: dir_entries = 'Monitored Directories:' + dir_entries.encode( 'utf-8') display = '%s\n%s' % (dir_entries, file_entries) print display
def displayMonitor(**kwargs): """ called for displaying all monitor related commands. """ if kwargs['cmd'] == 'remove': print MONITOR_REMOVE % kwargs['eaiArgsList'] elif kwargs['cmd'] == 'add': print MONITOR_ADD % kwargs['eaiArgsList'] elif kwargs['cmd'] == 'edit': print MONITOR_EDIT % kwargs['eaiArgsList'] elif kwargs['cmd'] == 'list': atom = rest.format.parseFeedDocument(kwargs['serverContent']) dir_entries = '' file_entries = '' for entry in atom: d = nodeToPrimitive(entry.rawcontents) # entry.links is a list of tuples, link name->href. if len([x for x in entry.links if x[0] == 'members']) > 0: dir_entries += '\n\t%s' % entry.title dir_files = extractTitleFeed(filter(lambda t: t[0] == 'members', entry.links), sessionKey=kwargs['sessionKey']) if dir_files: for f in dir_files: dir_entries += '\n\t\t%s' % f else: dir_entries += '\n\t\t[No files in this directory monitored.]' else: if kwargs['eaiArgsList'].has_key('show-hidden') and util.normalizeBoolean(kwargs['eaiArgsList']['show-hidden']): file_entries += '\t%s\n' % entry.title elif not isInternalTail(entry.title): file_entries += '\t%s\n' % entry.title if not file_entries: file_entries = 'Monitored Files:\n\t\t[No files monitored.]' else: file_entries = 'Monitored Files:\n' + file_entries.encode('utf-8') if not dir_entries: dir_entries = 'Monitored Directories:\n\t\t[No directories monitored.]' else: dir_entries = 'Monitored Directories:' + dir_entries.encode('utf-8') display = '%s\n%s' % (dir_entries, file_entries) print display
def getJobForSavedSearch(label, useHistory=None, namespace=None, sessionKey=None, ignoreExpired=True, owner=None, ignoreRunning=True, sortKey='createTime', sortDir='desc', search=None, hostPath=None, **kw): ''' Retrieve the last job run for a saved search. == WARNING == This is meant to be a convenience method for accessing jobs from saved searches that are typically run by the splunkd scheduler. As such dispatching a job from a saved search and then attempting to immediately call getJobForSavedSearch with the param ignoreRunning == True will result in a second job being dispatched. == / WARNING == useHistory dictates how getJobForSavedSearch attempts to fetch a job. useHistory=None implies that if the saved search has a history of jobs relevant to the saved search, it will return the last run saved search. If no jobs can be found a new one will be dispatched and returned. useHistory=True implies that the last run job for the saved search will be returned. If no jobs exist None will be returned instead. useHistory=False is effectively the same as calling dispatchSavedSearch(label) in that it does not check for a previously run job, and instead forces a new job to be created and returned. This option is left for convenience. ''' job = None useHistory = util.normalizeBoolean(useHistory) if isinstance(useHistory, basestring): #verified while fixing SPL-47422 #pylint: disable=E1103 if useHistory.lower() in ('none', 'auto'): useHistory = None else: raise ValueError, 'Invalid option passed for useHistory: %s' % useHistory logger.debug('getJobForSavedSearch - label=%s namespace=%s owner=%s' % (label, namespace, owner)) # Attempt to get the saved search history if useHistory == None or useHistory == True: history = getSavedSearchHistory(label, namespace=namespace, sessionKey=sessionKey, ignoreExpired=ignoreExpired, owner=owner, ignoreRunning=ignoreRunning, sortKey=sortKey, sortDir=sortDir, search=search, hostPath=hostPath, uri=kw.get('historyURI')) if len(history) > 0: job = splunk.search.getJob(history.keys()[0], hostPath=hostPath, sessionKey=sessionKey) logger.debug('getJobForSavedSearch - found job artifact sid=%s' % job.id) # Dispatch a new search if there is no history for the search if (useHistory == False) or (useHistory == None and job == None): logger.debug('getJobForSavedSearch - no artifact found; dispatching new job') job = dispatchSavedSearch(label, sessionKey=sessionKey, namespace=namespace, owner=owner, hostPath=hostPath, **kw) # If the user specified useHistory = yes and no history was found, this may return None return job
def getJobForSavedSearch(label, useHistory=None, namespace=None, sessionKey=None, ignoreExpired=True, owner=None, ignoreRunning=True, sortKey='createTime', sortDir='desc', search=None, hostPath=None, **kw): ''' Retrieve the last job run for a saved search. == WARNING == This is meant to be a convenience method for accessing jobs from saved searches that are typically run by the splunkd scheduler. As such dispatching a job from a saved search and then attempting to immediately call getJobForSavedSearch with the param ignoreRunning == True will result in a second job being dispatched. == / WARNING == useHistory dictates how getJobForSavedSearch attempts to fetch a job. useHistory=None implies that if the saved search has a history of jobs relevant to the saved search, it will return the last run saved search. If no jobs can be found a new one will be dispatched and returned. useHistory=True implies that the last run job for the saved search will be returned. If no jobs exist None will be returned instead. useHistory=False is effectively the same as calling dispatchSavedSearch(label) in that it does not check for a previously run job, and instead forces a new job to be created and returned. This option is left for convenience. ''' job = None useHistory = util.normalizeBoolean(useHistory) if isinstance(useHistory, basestring): if useHistory.lower() in ('none', 'auto'): useHistory = None else: raise ValueError, 'Invalid option passed for useHistory: %s' % useHistory logger.debug('getJobForSavedSearch - label=%s namespace=%s owner=%s' % (label, namespace, owner)) # Attempt to get the saved search history if useHistory == None or useHistory == True: history = getSavedSearchHistory(label, namespace=namespace, sessionKey=sessionKey, ignoreExpired=ignoreExpired, owner=owner, ignoreRunning=ignoreRunning, sortKey=sortKey, sortDir=sortDir, search=search, hostPath=hostPath, uri=kw.get('historyURI')) if len(history) > 0: job = splunk.search.getJob(history.keys()[0], hostPath=hostPath, sessionKey=sessionKey) logger.debug('getJobForSavedSearch - found job artifact sid=%s' % job.id) # Dispatch a new search if there is no history for the search if (useHistory == False) or (useHistory == None and job == None): logger.debug('getJobForSavedSearch - no artifact found; dispatching new job') job = dispatchSavedSearch(label, sessionKey=sessionKey, namespace=namespace, owner=owner, hostPath=hostPath, **kw) # If the user specified useHistory = yes and no history was found, this may return None return job
def displayIndex(**kwargs): """ called for displaying all index related commands. """ if kwargs['cmd'] == 'add': print 'Index "%s" added' % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'edit': print 'Index "%s" edited' % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'remove': print 'Index "%s" removed' % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'disable': print INDEX_DISABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'enable': print INDEX_ENABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'list': atom = rest.format.parseFeedDocument(kwargs['serverContent']) display = '' for entry in atom: d = nodeToPrimitive(entry.rawcontents) if d['defaultDatabase'] == entry.title: display += '%s * Default *' % entry.title else: display += '%s' % entry.title #SPL-27068 if util.normalizeBoolean(d['disabled']): display += ' * Disabled *' display += '\n' if not kwargs['eaiArgsList']['name']: display += '\t%s\n\t%s\n\t%s\n' % (d['homePath_expanded'], d['coldPath_expanded'], d['thawedPath_expanded']) else: #we have asked about a specific index, so show everything for k in d.keys(): display += '\t%s : %s\n' % (k, d[k]) print INDEX_LIST print display
def displayIndex(**kwargs): """ called for displaying all index related commands. """ if kwargs['cmd'] == 'add': print 'Index "%s" added' % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'edit': print 'Index "%s" edited' % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'remove': print 'Index "%s" removed' % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'disable': print INDEX_DISABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'enable': print INDEX_ENABLED % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'list': atom = rest.format.parseFeedDocument(kwargs['serverContent']) display = '' for entry in atom: d = nodeToPrimitive(entry.rawcontents) if d['defaultDatabase'] == entry.title: display += '%s * Default *' % entry.title else: display += '%s' % entry.title #SPL-27068 if util.normalizeBoolean(d['disabled']): display += ' * Disabled *' display += '\n' if not kwargs['eaiArgsList']['name']: display += '\t%s\n\t%s\n\t%s\n' % (d['homePath_expanded'], d['coldPath_expanded'], d['thawedPath_expanded']) else: #we have asked about a specific index, so show everything for k in d.keys(): display += '\t%s : %s\n' % (k,d[k]) print INDEX_LIST print display
def displayForwardServer(**kwargs): """ called for displaying forward-server stuff. """ if kwargs['cmd'] == 'display' and kwargs['obj'] == 'local-index': local_index = extractLevel1Feed(serverContent=kwargs['serverContent'], filter=['indexAndForward']) local_index = util.normalizeBoolean(local_index) if not local_index: print LOCAL_INDEX_NONE elif local_index: print LOCAL_INDEX_ENABLE elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'local-index': print LOCAL_INDEX_ENABLE print FORWARD_COND print RESTART_SPLUNK elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'local-index': print LOCAL_INDEX_DISABLE print FORWARD_COND print RESTART_SPLUNK elif kwargs['cmd'] == 'list': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) ok_list = nok_list = '' for entry in atomFeed: d = nodeToPrimitive(entry.rawcontents) if d.has_key('status') and d['status'] == 'connect_done': ok_list += '\n\t%s' % entry.title else: nok_list += '\n\t%s' % entry.title print FORWARD_SERVER_LIST % (ok_list, nok_list) elif kwargs['cmd'] == 'add': display = FORWARD_SERVER_ADD % kwargs['eaiArgsList']['name'] print display print RESTART_SPLUNK elif kwargs['cmd'] == 'remove': print FORWARD_SERVER_REMOVE % kwargs['eaiArgsList']['name'] print RESTART_SPLUNK elif kwargs['cmd'] == 'edit': print RESTART_SPLUNK
def displayDeployment(**kwargs): """ called for displayin deployment client/server stuff """ if kwargs['cmd'] == 'refresh' and kwargs['obj'] == 'deploy-clients': print REFRESH_DEPL_CLIENTS_REMOVED elif kwargs['cmd'] == 'show' and kwargs['obj'] == 'deploy-poll': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOY_POLL_SHOW_NONE else: d = {} for entry in atomFeed: if entry.title == 'deployment-client': d = nodeToPrimitive(entry.rawcontents) try: print DEPLOY_POLL_SHOW % d['targetUri'] except KeyError: print DEPLOY_POLL_SHOW_NONE break elif kwargs['cmd'] == 'list' and kwargs['obj'] == 'deploy-clients': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOYMENT_CLIENT_NONE else: for entry in atomFeed: print "\nDeployment client: %s" % entry.title d = nodeToPrimitive(entry.rawcontents) for k in d.keys(): if k.startswith('eai:acl'): continue print "\t\t %s: %s" % (k, d[k]) elif kwargs['cmd'] == 'reload' and kwargs['obj'] == 'deploy-server': print RELOAD_DEPLOY_SERVER atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print 'empty atomFeed; BUG!' sys.exit(21) else: for entry in atomFeed: # there will be only 1 entry d = nodeToPrimitive(entry.rawcontents) for k in d.keys(): if k == 'requireRestart': print RESTART_SPLUNK elif kwargs['cmd'] == 'set' and kwargs['obj'] == 'deploy-poll': print 'Configuration updated.' elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_ENABLED elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_DISABLED elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'deploy-client': print DEPLOYMENT_CLIENT_ENABLED elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'deploy-client': print DEPLOYMENT_CLIENT_DISABLED elif kwargs['cmd'] == 'display': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = {} for entry in atomFeed: if kwargs['obj'] == 'deploy-server' and entry.title == 'default': d = nodeToPrimitive(entry.rawcontents) try: if not util.normalizeBoolean(d['disabled']): print DEPLOYMENT_SERVER_ENABLED return except: break if kwargs['obj'] == 'deploy-client' and entry.title == 'default': d = nodeToPrimitive(entry.rawcontents) try: if not util.normalizeBoolean(d['disabled']): print DEPLOYMENT_CLIENT_ENABLED return except: break if kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_DISABLED elif kwargs['obj'] == 'deploy-clients': print DEPLOYMENT_CLIENT_DISABLED
def displayDeployment(**kwargs): """ called for displayin deployment client/server stuff """ if kwargs['cmd'] == 'refresh' and kwargs['obj'] == 'deploy-clients': print REFRESH_DEPL_CLIENTS elif kwargs['cmd'] == 'show' and kwargs['obj'] == 'deploy-poll': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOY_POLL_SHOW_NONE else: d = {} for entry in atomFeed: if entry.title == 'deployment-client': d = nodeToPrimitive(entry.rawcontents) try: print DEPLOY_POLL_SHOW % d['targetUri'] except KeyError: print DEPLOY_POLL_SHOW_NONE break elif kwargs['cmd'] == 'list' and kwargs['obj'] == 'server-class': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOYMENT_SERVER_NO_SERVER_CLASS else: print DEPLOYMENT_SERVER_CLASS for entry in atomFeed: print '\t%s' % entry.title elif kwargs['cmd'] == 'list' and kwargs['obj'] == 'deploy-clients': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOYMENT_CLIENT_NONE else: for entry in atomFeed: print "\nDeployment client: %s" % entry.title d = nodeToPrimitive(entry.rawcontents) for k in d.keys(): if k.startswith('eai:acl'): continue print "\t\t %s: %s" % (k,d[k]) elif kwargs['cmd'] == 'reload' and kwargs['obj'] == 'deploy-server': print RELOAD_DEPLOY_SERVER elif kwargs['cmd'] == 'set' and kwargs['obj'] == 'deploy-multicast': print '"set deploy-multicast" is currently not supported. Use "set deploy-poll" instead.' elif kwargs['cmd'] == 'set' and kwargs['obj'] == 'deploy-poll': print 'Configuration updated.' elif kwargs['cmd'] == 'show' and kwargs['obj'] == 'deploy-multicast': print 'Only deploy-poll is supported currently.' elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_ENABLED elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_DISABLED elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'deploy-client': print DEPLOYMENT_CLIENT_ENABLED elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'deploy-client': print DEPLOYMENT_CLIENT_DISABLED elif kwargs['cmd'] == 'display': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = {} for entry in atomFeed: if kwargs['obj'] == 'deploy-server' and entry.title == 'default': d = nodeToPrimitive(entry.rawcontents) try: if not util.normalizeBoolean(d['disabled']): print DEPLOYMENT_SERVER_ENABLED return except: break if kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_DISABLED elif kwargs['obj'] == 'deploy-clients': print DEPLOYMENT_CLIENT_DISABLED
def displayDeployment(**kwargs): """ called for displayin deployment client/server stuff """ if kwargs['cmd'] == 'refresh' and kwargs['obj'] == 'deploy-clients': print REFRESH_DEPL_CLIENTS_REMOVED elif kwargs['cmd'] == 'show' and kwargs['obj'] == 'deploy-poll': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOY_POLL_SHOW_NONE else: d = {} for entry in atomFeed: if entry.title == 'deployment-client': d = nodeToPrimitive(entry.rawcontents) try: print DEPLOY_POLL_SHOW % d['targetUri'] except KeyError: print DEPLOY_POLL_SHOW_NONE break elif kwargs['cmd'] == 'list' and kwargs['obj'] == 'deploy-clients': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print DEPLOYMENT_CLIENT_NONE else: for entry in atomFeed: print "\nDeployment client: %s" % entry.title d = nodeToPrimitive(entry.rawcontents) for k in d.keys(): if k.startswith('eai:acl'): continue print "\t\t %s: %s" % (k,d[k]) elif kwargs['cmd'] == 'reload' and kwargs['obj'] == 'deploy-server': print RELOAD_DEPLOY_SERVER atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) if not atomFeed.entries: print 'empty atomFeed; BUG!' sys.exit(21) else: for entry in atomFeed: # there will be only 1 entry d = nodeToPrimitive(entry.rawcontents) for k in d.keys(): if k == 'requireRestart': print RESTART_SPLUNK elif kwargs['cmd'] == 'set' and kwargs['obj'] == 'deploy-poll': print 'Configuration updated.' elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_ENABLED elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_DISABLED elif kwargs['cmd'] == 'enable' and kwargs['obj'] == 'deploy-client': print DEPLOYMENT_CLIENT_ENABLED elif kwargs['cmd'] == 'disable' and kwargs['obj'] == 'deploy-client': print DEPLOYMENT_CLIENT_DISABLED elif kwargs['cmd'] == 'display': atomFeed = rest.format.parseFeedDocument(kwargs['serverContent']) d = {} for entry in atomFeed: if kwargs['obj'] == 'deploy-server' and entry.title == 'default': d = nodeToPrimitive(entry.rawcontents) try: if not util.normalizeBoolean(d['disabled']): print DEPLOYMENT_SERVER_ENABLED return except: break if kwargs['obj'] == 'deploy-client' and entry.title == 'default': d = nodeToPrimitive(entry.rawcontents) try: if not util.normalizeBoolean(d['disabled']): print DEPLOYMENT_CLIENT_ENABLED return except: break if kwargs['obj'] == 'deploy-server': print DEPLOYMENT_SERVER_DISABLED elif kwargs['obj'] == 'deploy-clients': print DEPLOYMENT_CLIENT_DISABLED