epc-as-a-service functionality added

Change-Id: I85e9c725575df0044236e20b7900008755029ab2
diff --git a/xos/models.py b/xos/models.py
index 56350a7..f8d4c16 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -15,13 +15,16 @@
 import traceback
 from xos.exceptions import *
 from xos.config import Config
-from django.contrib.contenttypes.models import ContentType
-from django.contrib.contenttypes.fields import GenericForeignKey
 
 class VSMService(VSMService_decl):
    class Meta:
         proxy = True 
 
+   def create_tenant(self, **kwargs):
+       t = VSMTenant(kind="vEPC", provider_service=self, connect_method="na", **kwargs)
+       t.save()
+       return t
+
 class VSMTenant(VSMTenant_decl):
    class Meta:
         proxy = True 
@@ -34,6 +37,13 @@
        super(VSMTenant, self).__init__(*args, **kwargs)
 
    def save(self, *args, **kwargs):
+       if not self.creator:
+           if not getattr(self, "caller", None):
+               raise XOSProgrammingError("VSMTenant's self.caller was not set")
+           self.creator = self.caller
+           if not self.creator:
+               raise XOSProgrammingError("VSMTenant's self.creator was not set")
+
        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.