Merge "[CORD-2641] Converting M-CORD Subscriber to _decl and adding ue status"
diff --git a/xos/models/attic/header.py b/xos/models/attic/header.py
deleted file mode 100644
index ad5bb33..0000000
--- a/xos/models/attic/header.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License
-
-from django.db import models
-from core.models import ServiceInstance
-from django.db.models import *
-from core.models.xosbase import StrippedCharField
diff --git a/xos/models/header.py b/xos/models/header.py
deleted file mode 120000
index 721b5c0..0000000
--- a/xos/models/header.py
+++ /dev/null
@@ -1 +0,0 @@
-attic/header.py
\ No newline at end of file
diff --git a/xos/models/mcord.xproto b/xos/models/mcord.xproto
index b64aa65..bbbc84e 100644
--- a/xos/models/mcord.xproto
+++ b/xos/models/mcord.xproto
@@ -1,5 +1,6 @@
 option app_label = "mcord";
 option name = "mcord";
+option legacy = "True";
 
 message MCordSubscriberService (Service) {
      option verbose_name = "MCORD Service";
@@ -7,9 +8,10 @@
 }
 
 message MCordSubscriberInstance (ServiceInstance) {
-     option verbose_name = "MCORD Subscriber";
-     option description = "This model holds the informations of a Mobile Subscriber in CORD";
+    option verbose_name = "MCORD Subscriber";
+    option description = "This model holds the informations of a Mobile Subscriber in CORD";
 
-     required string imsi_number = 1 [max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
-     required string apn_number = 1 [max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
+    required string imsi_number = 1 [max_length = 30, content_type = "stripped", blank = False, null = False, db_index = False];
+    optional string apn_number = 2 [max_length = 30, content_type = "stripped", blank = True, null = True, db_index = False];
+    optional int32 ue_status = 3 [max_length = 30, choices = "(('0', 'Detached'), ('1', 'Attached'))", blank = True, null = True, db_index = False];
 }
diff --git a/xos/models/models.py b/xos/models/models.py
new file mode 100644
index 0000000..3a7ed58
--- /dev/null
+++ b/xos/models/models.py
@@ -0,0 +1,26 @@
+from xos.exceptions import XOSValidationError
+
+from models_decl import MCordSubscriberService_decl
+from models_decl import MCordSubscriberInstance_decl
+
+
+
+
+class MCordSubscriberService(MCordSubscriberService_decl):
+    class Meta:
+        proxy = True 
+
+
+class MCordSubscriberInstance(MCordSubscriberInstance_decl):
+    class Meta:
+        proxy = True
+
+    def save(self, *args, **kwargs):
+        # NOTE someone is setting owner_id, so just override it for now
+        try:
+            mcord_service = MCordSubscriberService.objects.all()[0]
+            self.owner_id = mcord_service.id
+        except IndexError:
+            raise XOSValidationError("Service MCORD cannot be found, please make sure that the model exists.")
+
+        super(MCordSubscriberInstance, self).save(*args, **kwargs)