add Vendor model to select flavor/image at Tenant creation
Change-Id: Ifde87eaa83b0559c83afd7010068dd5465125e37
diff --git a/xos/models.py b/xos/models.py
index d6fcdcd..1a109d8 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,5 +1,6 @@
from core.models.plcorebase import *
from models_decl import VSGWUService_decl
+from models_decl import VSGWUVendor_decl
from models_decl import VSGWUTenant_decl
from django.db import models
@@ -25,6 +26,10 @@
t.save()
return t
+class VSGWUVendor(VSGWUVendor_decl):
+ class Meta:
+ proxy = True
+
class VSGWUTenant(VSGWUTenant_decl):
class Meta:
proxy = True
@@ -36,6 +41,17 @@
"provider_service").default = vsgwuservice[0].id
super(VSGWUTenant, self).__init__(*args, **kwargs)
+ @property
+ def image(self):
+ if not self.vsgwu_vendor:
+ return super(VSGWUTenant, self).image
+ return self.vsgwu_vendor.image
+
+ def save_instance(self, instance):
+ if self.vsgwu_vendor:
+ instance.flavor = self.vsgwu_vendor.flavor
+ super(VSGWUTenant, self).save_instance(instance)
+
def save(self, *args, **kwargs):
if not self.creator:
if not getattr(self, "caller", None):