add Vendor model to select flavor/image at Tenant creation
Change-Id: I48343e55d24d5d298174f96886674cd75553fc41
diff --git a/xos/tosca/resources/vmmeservice.py b/xos/tosca/resources/vmmeservice.py
index 3001eac..dc51c47 100644
--- a/xos/tosca/resources/vmmeservice.py
+++ b/xos/tosca/resources/vmmeservice.py
@@ -5,3 +5,4 @@
provides = "tosca.nodes.VMMEService"
xos_model = VMMEService
copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
+
diff --git a/xos/tosca/resources/vmmetenant.py b/xos/tosca/resources/vmmetenant.py
index 4c6f2f7..4ef27ab 100644
--- a/xos/tosca/resources/vmmetenant.py
+++ b/xos/tosca/resources/vmmetenant.py
@@ -29,3 +29,4 @@
def can_delete(self, obj):
return super(XOSVMMETenant, self).can_delete(obj)
+
diff --git a/xos/tosca/resources/vmmevendor.py b/xos/tosca/resources/vmmevendor.py
new file mode 100644
index 0000000..7a4d84c
--- /dev/null
+++ b/xos/tosca/resources/vmmevendor.py
@@ -0,0 +1,31 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vmme.models import VMMEVendor
+
+class XOSVMMEVendor(XOSResource):
+ provides = "tosca.nodes.VMMEVendor"
+ xos_model = VMMEVendor
+ name_field = None
+ copyin_props = ( "name",)
+
+ def get_xos_args(self, throw_exception=True):
+ args = super(XOSVMMEVendor, self).get_xos_args()
+
+ tenant_name = self.get_requirement("tosca.relationships.VendorOfTenant", throw_exception=throw_exception)
+ if tenant_name:
+ args["provider_tenant"] = self.get_xos_object(Tenant, throw_exception=throw_exception, name=tenant_name)
+
+ return args
+
+ def get_existing_objs(self):
+ args = self.get_xos_args(throw_exception=False)
+ provider_tenant = args.get("provider", None)
+ if provider_tenant:
+ return [ self.get_xos_object(provider_tenant=provider_tenant) ]
+ return []
+
+ def postprocess(self, obj):
+ pass
+
+ def can_delete(self, obj):
+ return super(XOSVMMEVendor, self).can_delete(obj)