Exemplo n.º 1
0
def view_events():

    # Get a client connection.
    client = access_client()

    try:
        cfm_audits = system.get_audit_logs(client)
    except:
        error = "ERR-LOGIN - Failed to log into CFM controller"
        return error

    # Create a empty list for EVENTS
    event_data = []

    # Loop through cfm_audits and process EVENTS
    for event in cfm_audits:
        typex = event['record_type']
        if typex == 'EVENT':
            # Build dictionary to add to list
            out = [
                event['description'], event['data']['event_type'],
                event['data']['object_name'], event['severity'],
                event['data']['event_type'], event['record_type']
            ]
            event_data.append(out)

    return render_template('audits/events.html', e=event_data)
Exemplo n.º 2
0
def view_alarms():

    # Get a client connection.
    client = access_client()

    try:
        cfm_audits = system.get_audit_logs(client)
    except:
        error = "ERR-LOGIN - Failed to log into CFM controller"
        return error

    # Create a empty list for alarms
    alarm_data = []

    # Loop through cfm_audits and process ALARMS

    for alarm in cfm_audits:
        typex = alarm['record_type']
        if typex == 'ALARM':
            # Build dictionary to add to list
            out = [
                alarm['data']['event_type'], alarm['record_type'],
                alarm['severity'], alarm['description']
            ]
            alarm_data.append(out)

    return render_template('audits/alarms.html', a=alarm_data)
Exemplo n.º 3
0
    def run(self):
        afc_audits = system.get_audit_logs(self.client)
        if isinstance(afc_audits, list):
            # Create a empty list for alarms
            event_data = []
            # Loop through cfm_audits and process EVENTS
            for event in afc_audits:
                typex = event['record_type']
                if typex == 'EVENT':
                    created = int(event['log_date'] / 10)
                    # Build dictionary to add to list
                    out = {
                        'u_eventtype': event['data']['event_type'],
                        'u_typex': event['record_type'],
                        'u_sev': event['severity'],
                        'u_uuid': event['uuid'],
                        'u_desc': event['description'],
                        'u_name': event['data']['object_name'],
                        'u_created': created,
                        'u_typeo': event['data']['object_type']
                    }
                    event_data.append(out)

            return (True, event_data)
        return (False, afc_audits)
Exemplo n.º 4
0
 def test_get_audit_logs(self):
     """
     Test pyhpecfm.system.get_audit_logs function.
     """
     my_logs = system.get_audit_logs(cfm)
     my_attributes = [
         'description', 'record_type', 'log_date', 'uuid', 'stream_id',
         'data', 'severity'
     ]
     self.assertIs(type(my_logs), list)
     for i in my_logs[0].keys():
         self.assertIn(i, my_attributes)
Exemplo n.º 5
0
    def run(self):
        cfm_audits = system.get_audit_logs(self.client)
        if isinstance(cfm_audits, list):
            # Create a empty list for alarms
            alarm_data = []
            # Loop through cfm_audits and process ALARMS
            for alarm in cfm_audits:
                typex = alarm['record_type']
                if typex == 'ALARM':
                    # Build dictionary to add to list
                    out = {
                        'u_eventType': alarm['data']['event_type'],
                        'u_typex': alarm['record_type'],
                        'u_sev': alarm['severity'],
                        'u_desc': alarm['description']
                    }
                    alarm_data.append(out)

            return (True, alarm_data)
        return (False, cfm_audits)
Exemplo n.º 6
0
    def run(self):
        afc_audits = system.get_audit_logs(self.client)
        if isinstance(afc_audits, list):
            # Create a empty list for alarms
            alarm_data = []
            # Loop through cfm_audits and process ALARMS
            for alarm in afc_audits:
                typex = alarm['record_type']
                if typex == 'ALARM':
                    # Build dictionary to add to list
                    created = int(alarm['log_date'] / 10)
                    out = {
                        'u_eventtype': alarm['data']['event_type'],
                        'u_typex': alarm['record_type'],
                        'u_sev': alarm['severity'],
                        'u_uuid': alarm['uuid'],
                        'u_desc': alarm['description'],
                        'u_created': created,
                        'u_snowack': 'no'
                    }
                    alarm_data.append(out)

            return (True, alarm_data)
        return (False, afc_audits)