add Vendor model to select flavor/image at Tenant creation
Change-Id: I98b13d345b773ebaf8aff7f5294ce9bbf17d0960
diff --git a/xos/tosca/custom_types/vsm.m4 b/xos/tosca/custom_types/vsm.m4
index 1613c4f..16fc1ed 100644
--- a/xos/tosca/custom_types/vsm.m4
+++ b/xos/tosca/custom_types/vsm.m4
@@ -22,3 +22,19 @@
VSM Tenant
properties:
xos_base_tenant_props
+
+ tosca.nodes.VSMVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VSM Vendor
+ capabilities:
+ xos_bas_service_caps
+ properties:
+ name:
+ type: string
+ required: true
+
+ tosca.relationships.VendorOfTenant:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.VSMTenant ]
+
diff --git a/xos/tosca/custom_types/vsm.yaml b/xos/tosca/custom_types/vsm.yaml
index ff8ef88..a68d6dc 100644
--- a/xos/tosca/custom_types/vsm.yaml
+++ b/xos/tosca/custom_types/vsm.yaml
@@ -92,3 +92,19 @@
type: string
required: false
description: Service specific ID opaque to XOS but meaningful to service
+
+ tosca.nodes.VSMVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VSM Vendor
+ capabilities:
+ xos_bas_service_caps
+ properties:
+ name:
+ type: string
+ required: true
+
+ tosca.relationships.VendorOfTenant:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.VSMTenant ]
+
diff --git a/xos/tosca/resources/vsmvendor.py b/xos/tosca/resources/vsmvendor.py
new file mode 100644
index 0000000..46d3628
--- /dev/null
+++ b/xos/tosca/resources/vsmvendor.py
@@ -0,0 +1,32 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vsm.models import VSMVendor
+
+class XOSVSMVendor(XOSResource):
+ provides = "tosca.nodes.VSMVendor"
+ xos_model = VSMVendor
+ name_field = None
+ copyin_props = ( "name",)
+
+ def get_xos_args(self, throw_exception=True):
+ args = super(XOSVSMVendor, 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(XOSVSMVendor, self).can_delete(obj)
+