# 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/controller.py
# class Controller(BaseModel):
#     # Ip address
#     ip_address = models.CharField(max_length=50)
# 
#     # Port
#     listen_port = models.CharField(max_length=10)
# 
#     # Name
#     name = models.CharField(max_length=50)
# 
#     # Description
#     description = models.CharField(max_length=100)
# 
#     # Controller type
#     controller_type = models.CharField(max_length=1, choices=CONTROLLER_CHOICE)
# 
#     def __unicode__(self):
#         return self.name + " - " + self.description


from django.db import models
from sdn.models.base_model import BaseModel
from sdn.models.controller import Controller


# Create your models here.
class Configuration(BaseModel):
    # Polling Interval
    polling_interval = models.IntegerField()

    # Chart Update Interval
    chart_update_interval = models.IntegerField()

    # Foreign key to controller
    controller = models.ForeignKey(Controller)

    def sync(self, polling_interval, chart_update_interval):
        self.polling_interval = polling_interval

# 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/controller.py
# class Controller(BaseModel):
#     # Ip address
#     ip_address = models.CharField(max_length=50)
# 
#     # Port
#     listen_port = models.CharField(max_length=10)
# 
#     # Name
#     name = models.CharField(max_length=50)
# 
#     # Description
#     description = models.CharField(max_length=100)
# 
#     # Controller type
#     controller_type = models.CharField(max_length=1, choices=CONTROLLER_CHOICE)
# 
#     def __unicode__(self):
#         return self.name + " - " + self.description


# Path: sdn/models/configuration.py
from django.db import models
from sdn.models.base_model import BaseModel
from sdn.models.controller import Controller



# Create your models here.
class Configuration(BaseModel):
    # Polling Interval
    polling_interval = models.IntegerField()

    # Chart Update Interval
    chart_update_interval = models.IntegerField()

    # Foreign key to controller
    controller = models.ForeignKey(Controller)

    def sync(self, polling_interval, chart_update_interval):
        self.polling_interval = polling_interval

        self.chart_update_interval = chart_update_interval