from django.db import models
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _

from mike.lib.mike_object import MikeObject
from mike.lib.objects.switch import Switch


class Port(MikeObject):
    '''
    {
        "uuid": UUID,
        "name": string,
        "number": integer,
        "switch": reference,
    }
    '''
    name = models.CharField(max_length=16, null=False, blank=True)
    number = models.IntegerField(null=True)
    state = models.IntegerField(null=False)

    class Meta:
        unique_together = (('switch', 'number'), ('switch', 'name'))
        abstract = True

    def clean(self):
        if not self.name and not self.number:
            raise ValidationError(_("this taple is not unique"))

    def __unicode__(self):
        return self.uuid

@@ -133,52 +133,61 @@
 s _%0A
-%0A
 from 
-mike.lib.mike_object import MikeObject
+ryu.ofproto.ofproto_v1_3 import OFPPS_LINK_DOWN%0A
 %0Afro
@@ -201,36 +201,37 @@
 lib.
+mike_
 object
-s.switch import Switch
+ import MikeObject
 %0A%0A%0Ac
@@ -522,24 +522,49 @@
 ntegerField(
+default=OFPPS_LINK_DOWN, 
 null=False)%0A

add port state