Ejemplo n.º 1
0
    def exit_with_exception(self, cause='General Failure'):
        """
        This will result in exiting the application and cause tasks to
        return with failure status.

        PARAMETER: cause
        """

        OUTPUT.error('Exiting with exception cause: {0}'.format(str(cause)))
        sys.exit(1)
Ejemplo n.º 2
0
 def _add_log(self, mylog, logtype='info'):
     """Add a log generated from this module"""
     if logtype == 'error':
         OUTPUT.error('{0}: {1}'.format(str(self.__class__.__name__),
                                        str(mylog)))
     elif logtype == 'warning':
         OUTPUT.warning('{0}: {1}'.format(str(self.__class__.__name__),
                                          str(mylog)))
     else:
         OUTPUT.info('{0}: {1}'.format(str(self.__class__.__name__),
                                       str(mylog)))
Ejemplo n.º 3
0
def change(whatif, element, value):
    """
    Set script configuration elements. These are saved for future script runs.
    """
    if element in CFG.values:
        if whatif:
            OUTPUT.info('Would have updated {0} to {1}'.format(
                CFG.values[element], value))
        else:
            OUTPUT.info('Updating {0} to {1}'.format(element, value))
            CFG.values[element] = value
            CFG.save()
    else:
        OUTPUT.error('No configuration element exists for {0}'.format(element))
Ejemplo n.º 4
0
    def show_monitors(self):
        """Prints information about current monitors to console"""
        try:
            OUTPUT.info('Loading and displaying monitors')

            outlines = []
            outlines.append([
                'name', 'thresholdtype', 'warn_thresh', 'alert_thresh',
                'enabled'
            ])
            for monitor in self.monitorjobs:
                outlines.append(monitor.show())

            col_width = max(len(word) for row in outlines for word in row) + 2
            # padding
            for row in outlines:
                OUTPUT.echo("".join(word.ljust(col_width) for word in row))

        except Exception as monitorexception:
            OUTPUT.error('Unable to print monitor output')
            raise monitorexception