# Path: sdn/models/switch.py
# class Switch(BaseModel):
#     # Buffers
#     buffers = models.IntegerField()
# 
#     # Description
#     software = models.CharField(max_length=100)
#     hardware = models.CharField(max_length=100)
#     manufacturer = models.CharField(max_length=100)
#     serial_num = models.CharField(max_length=100)
#     datapath = models.CharField(max_length=100)
# 
#     # Capabilities
#     capabilities = models.IntegerField()
# 
#     # Inet Address
#     inet_address = models.CharField(max_length=100)
# 
#     # Connected Since
#     connected_since = models.BigIntegerField()
# 
#     # DPID
#     dpid = models.CharField(max_length=100, db_index=True)
# 
#     # Foreign key to controller
#     controller = models.ForeignKey(Controller)
# 
# Path: sdn/models/base_model.py
# class BaseModel(models.Model):
#     class Meta:
#         # Makes django recognize model in split modules
#         app_label = 'sdn'
#         # Turns this into an abstract model (does not create table for it)
#         abstract = True
# 
#     # Default exception for models in manager
#     class ModelException(Exception):
#         # Get an instance of a logger
#         logger = logging.getLogger(__name__)
# 
#         def __init__(self, msg):
#             self.msg = msg
#             self.logger.warning(msg)
# 
#         def __str__(self):
#             return repr(self.msg)


from django.db import models
from sdn.models.switch import Switch
from sdn.models.base_model import BaseModel
                            if 'ICMP' in msg_subsubtype:
                                message_subsubtype = 'L4_ICMP'
                            elif 'UDP' in msg_subsubtype:
                                message_subsubtype = 'L4_UDP'
                    list_counters.append({'dpid':switch_dpid,'msg_subtype':message_subtype,'msg_subsubtype':message_subsubtype,'counter_packets':value})

        new_list_counters = {}
        for row in list_counters:
            switch = row['dpid']
            msg_subtype = row['msg_subtype']
            msg_subsubtype = row['msg_subsubtype']
            if switch in new_list_counters:
                new_list_counters[switch][str(msg_subtype)+'_'+str(msg_subsubtype)] += row['counter_packets']
            else:
                new_list_counters[switch] = {}
                new_list_counters[switch]['PACKET_IN_None'] = 0
                new_list_counters[switch]['PACKET_IN_unicast'] = 0
                new_list_counters[switch]['PACKET_IN_broadcast'] = 0
                new_list_counters[switch]['PACKET_IN_L3_ARP'] = 0
                new_list_counters[switch]['PACKET_IN_L3_8942'] = 0
                new_list_counters[switch]['PACKET_IN_L3_IPv4'] = 0
                new_list_counters[switch]['PACKET_IN_L3_LLDP'] = 0
                new_list_counters[switch]['PACKET_IN_L4_ICMP'] = 0
                new_list_counters[switch]['PACKET_IN_L4_UDP'] = 0
                new_list_counters[switch]['PACKET_OUT_None'] = 0
                new_list_counters[switch]['MODIFY_STATE_None'] = 0

        #logger.debug(new_list_counters)

        for key, value in list(new_list_counters.items()):

# Path: sdn/models/switch.py
# class Switch(BaseModel):
#     # Buffers
#     buffers = models.IntegerField()
# 
#     # Description
#     software = models.CharField(max_length=100)
#     hardware = models.CharField(max_length=100)
#     manufacturer = models.CharField(max_length=100)
#     serial_num = models.CharField(max_length=100)
#     datapath = models.CharField(max_length=100)
# 
#     # Capabilities
#     capabilities = models.IntegerField()
# 
#     # Inet Address
#     inet_address = models.CharField(max_length=100)
# 
#     # Connected Since
#     connected_since = models.BigIntegerField()
# 
#     # DPID
#     dpid = models.CharField(max_length=100, db_index=True)
# 
#     # Foreign key to controller
#     controller = models.ForeignKey(Controller)
# 
# Path: sdn/models/base_model.py
# class BaseModel(models.Model):
#     class Meta:
#         # Makes django recognize model in split modules
#         app_label = 'sdn'
#         # Turns this into an abstract model (does not create table for it)
#         abstract = True
# 
#     # Default exception for models in manager
#     class ModelException(Exception):
#         # Get an instance of a logger
#         logger = logging.getLogger(__name__)
# 
#         def __init__(self, msg):
#             self.msg = msg
#             self.logger.warning(msg)
# 
#         def __str__(self):
#             return repr(self.msg)


# Path: sdn/models/openflow_message_counter1_0.py
from django.db import models
from sdn.models.switch import Switch
from sdn.models.base_model import BaseModel

                            if 'ICMP' in msg_subsubtype:
                                message_subsubtype = 'L4_ICMP'
                            elif 'UDP' in msg_subsubtype:
                                message_subsubtype = 'L4_UDP'
                    list_counters.append({'dpid':switch_dpid,'msg_subtype':message_subtype,'msg_subsubtype':message_subsubtype,'counter_packets':value})

        new_list_counters = {}
        for row in list_counters:
            switch = row['dpid']
            msg_subtype = row['msg_subtype']
            msg_subsubtype = row['msg_subsubtype']
            if switch in new_list_counters:
                new_list_counters[switch][str(msg_subtype)+'_'+str(msg_subsubtype)] += row['counter_packets']
            else:
                new_list_counters[switch] = {}
                new_list_counters[switch]['PACKET_IN_None'] = 0
                new_list_counters[switch]['PACKET_IN_unicast'] = 0
                new_list_counters[switch]['PACKET_IN_broadcast'] = 0
                new_list_counters[switch]['PACKET_IN_L3_ARP'] = 0
                new_list_counters[switch]['PACKET_IN_L3_8942'] = 0
                new_list_counters[switch]['PACKET_IN_L3_IPv4'] = 0
                new_list_counters[switch]['PACKET_IN_L3_LLDP'] = 0
                new_list_counters[switch]['PACKET_IN_L4_ICMP'] = 0
                new_list_counters[switch]['PACKET_IN_L4_UDP'] = 0
                new_list_counters[switch]['PACKET_OUT_None'] = 0
                new_list_counters[switch]['MODIFY_STATE_None'] = 0

        #logger.debug(new_list_counters)

        for key, value in list(new_list_counters.items()):

            sw = Switch.objects.get(dpid=key)