add Vendor model to select flavor/image at Tenant creation
Change-Id: Iaca169d8773617dae2b37fd8f49fc0a281a914b7
diff --git a/xos/tosca/custom_types/vpgwu.m4 b/xos/tosca/custom_types/vpgwu.m4
index 5e90bd6..5d04f1c 100644
--- a/xos/tosca/custom_types/vpgwu.m4
+++ b/xos/tosca/custom_types/vpgwu.m4
@@ -22,3 +22,19 @@
CORD - The vPGWU Tenant
properties:
xos_base_tenant_props
+
+ tosca.nodes.VPGWUVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VPGWU 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.VPGWUTenant ]
+
diff --git a/xos/tosca/custom_types/vpgwu.yaml b/xos/tosca/custom_types/vpgwu.yaml
index cb4c0a9..de0b884 100644
--- a/xos/tosca/custom_types/vpgwu.yaml
+++ b/xos/tosca/custom_types/vpgwu.yaml
@@ -90,3 +90,19 @@
type: string
required: false
description: Service specific ID opaque to XOS but meaningful to service
+
+ tosca.nodes.VPGWUVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VPGWU 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.VPGWUTenant ]
+
diff --git a/xos/tosca/resources/vpgwuvendor.py b/xos/tosca/resources/vpgwuvendor.py
new file mode 100644
index 0000000..f8160b7
--- /dev/null
+++ b/xos/tosca/resources/vpgwuvendor.py
@@ -0,0 +1,32 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vpgwu.models import VPGWUVendor
+
+class XOSVPGWUVendor(XOSResource):
+ provides = "tosca.nodes.VPGWUVendor"
+ xos_model = VPGWUVendor
+ name_field = None
+ copyin_props = ( "name",)
+
+ def get_xos_args(self, throw_exception=True):
+ args = super(XOSVPGWUVendor, 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(XOSVPGWUVendor, self).can_delete(obj)
+