Esempio n. 1
0
def classify_su(tickets, sus=emi_3rd_level_su.keys()):
    
    su_classification = {}
    
    for su in sus:
        su_classification[su] = []
    
    for t in tickets:
        su = ticket_su(t)
        su_classification[su].append(t)
        
    return su_classification
Esempio n. 2
0
def print_sla_report(start_date, end_date=datetime.now(), su_list=None, print_seconds=False):
    print >> stderr, "Print SLA status report for period %s -> %s. " % (start_date, end_date)
    print >> stderr, "The report prints the average SLA violation delay in seconds per SU and ticket priority."
    
    if su_list:
        sus = sorted(su_list, key=str.lower)
    else:
        sus = sorted(emi_3rd_level_su.keys(), key=str.lower)
    
    first_line = "su,%s" % ','.join(priorities)
    template_line = "%s,%s" % ('%s', ','.join(['%s' for i in range(len(priorities))]))
    
    tickets_total = 0
    print first_line
    
    for su in sus:
        tickets = []
        try:
            tickets = get_tickets(open_tickets_for_su_in_period(su, start_date, end_date))
        except WebFault:
            print >> stderr, "No open tickets found for SU %s in period (%s,%s)" % (su, start_date, end_date)
            continue
        
        tickets_total = tickets_total + len(tickets)
        priority_classification = {}
        priority_averages = {}
        
        for i in priorities:
            priority_classification[i] = []
            priority_averages[i] = timedelta(hours=0)       
        
        for t in tickets:
            prio = ticket_priority(t)
            priority_classification[prio].append(ticket_resolution_delay(t))
        
        
        for i in priorities:
            accum = timedelta(hours=0)
            
            for d in priority_classification[prio]:
                accum = accum + d
            
            if len(priority_classification[prio]) > 0:
                accum = accum / len(priority_classification[prio])
            
            priority_averages[prio] = accum
        
        if print_seconds:
            print template_line % (su,
                                   td_seconds(priority_averages[priorities[0]]),
                                   td_seconds(priority_averages[priorities[1]]),
                                   td_seconds(priority_averages[priorities[2]]),
                                   td_seconds(priority_averages[priorities[3]])
                                   )
        else:
            print template_line % (su,
                                   priority_averages[priorities[0]],
                                   priority_averages[priorities[1]],
                                   priority_averages[priorities[2]],
                                   priority_averages[priorities[3]]
                                   )