[MCORD-183] Fix instance creation from UI

Change-Id: I500c574d8912238c4a6bc009f099b6dc604328c7
diff --git a/xos/header.py b/xos/header.py
index a2f8bd7..2e60747 100644
--- a/xos/header.py
+++ b/xos/header.py
@@ -13,11 +13,3 @@
 from xos.config import Config
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.fields import GenericForeignKey
-
-class ConfigurationError(Exception):
-    pass
-
-VSM_KIND = "vEPC"
-
-CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
-
diff --git a/xos/models.py b/xos/models.py
new file mode 100644
index 0000000..b52029c
--- /dev/null
+++ b/xos/models.py
@@ -0,0 +1,40 @@
+from core.models.plcorebase import *
+from models_decl import VSMService_decl
+from models_decl import VSMTenant_decl
+
+class VSMService(VSMService_decl):
+   class Meta:
+        proxy = True 
+
+class VSMTenant(VSMTenant_decl):
+   class Meta:
+        proxy = True 
+
+   def __init__(self, *args, **kwargs):
+       vsmservice = VSMService.get_service_objects().all()
+       if vsmservice:
+           self._meta.get_field(
+                   "provider_service").default = vsmservice[0].id
+       super(VSMTenant, self).__init__(*args, **kwargs)
+
+   def save(self, *args, **kwargs):
+       super(VSMTenant, self).save(*args, **kwargs)
+       # This call needs to happen so that an instance is created for this
+       # tenant is created in the slice. One instance is created per tenant.
+       model_policy_vsmtenant(self.pk)
+
+   def delete(self, *args, **kwargs):
+       # Delete the instance that was created for this tenant
+       self.cleanup_container()
+       super(VSMTenant, self).delete(*args, **kwargs)
+
+def model_policy_vsmtenant(pk):
+    # This section of code is atomic to prevent race conditions
+    with transaction.atomic():
+        # We find all of the tenants that are waiting to update
+        tenant = VSMTenant.objects.select_for_update().filter(pk=pk)
+        if not tenant:
+            return
+        # Since this code is atomic it is safe to always use the first tenant
+        tenant = tenant[0]
+        tenant.manage_container()
\ No newline at end of file
diff --git a/xos/vsm.xproto b/xos/vsm.xproto
index 179a494..41dd1e0 100644
--- a/xos/vsm.xproto
+++ b/xos/vsm.xproto
@@ -1,13 +1,13 @@
 option name = "vsm";
 option app_label = "vsm";
-option verbose_name = "vsM Service";
+option verbose_name = "vSM Service";
 option kind = "vEPC";
+option legacy = "True";
 
 message VSMService (Service){
     required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
 }
 
-
 message VSMTenant (TenantWithContainer){
      option name = "vsmtenant";
      option verbose_name = "vSM Tenant";