def _git_commit(filelist, message): """ If config.git_commit_changes is enabled, then commit "filelist" to the repository using message """ if config.git_commit_changes != '1': return if 'git' not in globals(): from pynag.Utils import GitRepo git = GitRepo(directory=os.path.dirname(config.nagios_config), auto_init=False, author_name="okconfig") else: git = globals()['git'] git.commit(message=message, filelist=filelist)
def update_eventhandlers(request): """ Iterates through all pynag eventhandler and informs them who might be making a change """ remote_user = request.META.get('REMOTE_USER', 'anonymous') for i in pynag.Model.eventhandlers: i.modified_by = remote_user # if okconfig is installed, make sure okconfig is notified of git # settings try: from pynag.Utils import GitRepo import okconfig okconfig.git = GitRepo(directory=os.path.dirname( adagios.settings.nagios_config), auto_init=False, author_name=remote_user) except Exception: pass
def check_git(request): """ Notify user if there is uncommited data in git repository """ nagiosdir = os.path.dirname(pynag.Model.config.cfg_file) if settings.enable_githandler == True: try: git = pynag.Model.EventHandlers.GitEventHandler( nagiosdir, 'adagios', 'adagios') uncommited_files = git.get_uncommited_files() if len(uncommited_files) > 0: add_notification( level="warning", notification_id="uncommited", message="There are %s uncommited files in %s" % (len(uncommited_files), nagiosdir)) else: clear_notification(notification_id="uncommited") clear_notification(notification_id="git_missing") except pynag.Model.EventHandlers.EventHandlerError, e: if e.errorcode == 128: add_notification( level="warning", notification_id="git_missing", message= "Git Handler is enabled but there is no git repository in %s. Please init a new git repository." % nagiosdir) # if okconfig is installed, make sure okconfig is notified of git # settings try: author = request.META.get('REMOTE_USER', 'anonymous') from pynag.Utils import GitRepo import okconfig okconfig.git = GitRepo(directory=os.path.dirname( adagios.settings.nagios_config), auto_init=False, author_name=author) except Exception: pass