CORD-3143 Add service_instance field to Port object

Change-Id: I52586c8c5cbe55b953267c9af2deb909bd764f7d
diff --git a/xos/core/models/core.xproto b/xos/core/models/core.xproto
index 0c8da6f..1835994 100644
--- a/xos/core/models/core.xproto
+++ b/xos/core/models/core.xproto
@@ -384,12 +384,13 @@
 policy port_policy < *instance_policy(instance) & *network_policy(network) >
 
 message Port::port_policy (XOSBase) {
-     required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False, unique_with = "instance"];
-     optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True];
+     required manytoone network->Network:links = 1 [db_index = True, null = False, blank = False, unique_with = "instance", help_text = "Network bound to this port"];
+     optional manytoone instance->Instance:ports = 2 [db_index = True, null = True, blank = True, help_text = "Instance bound to this port"];
      optional string ip = 3 [max_length = 39, content_type = "ip", blank = True, help_text = "Instance ip address", null = True, db_index = False];
      optional string port_id = 4 [help_text = "Neutron port id", max_length = 256, null = True, db_index = False, blank = True];
      optional string mac = 5 [help_text = "MAC address associated with this port", max_length = 256, null = True, db_index = False, blank = True];
      required bool xos_created = 6 [default = False, null = False, db_index = False, blank = True];
+     optional manytoone service_instance->ServiceInstance:ports = 2 [db_index = True, null = True, blank = True, help_text = "ServiceInstance bound to this port"];
 }
 
 message Principal (XOSBase) {
diff --git a/xos/core/models/port.py b/xos/core/models/port.py
index 83ba7f8..9495498 100644
--- a/xos/core/models/port.py
+++ b/xos/core/models/port.py
@@ -27,4 +27,9 @@
                 (not self.network.permit_all_slices):
                 raise XOSValidationError("Slice is not allowed to connect to network")
 
+        if self.instance and self.service_instance:
+            raise XOSValidationError("Only one of (instance, service_instance) may be set,"
+                                      "port=%s, network=%s, instance=%s, service_instance=%s" %
+                                     (self, self.network, self.instance, self.service_instance))
+
         super(Port, self).save(*args, **kwargs)