add Vendor model to select flavor/image at Tenant creation
Change-Id: I48343e55d24d5d298174f96886674cd75553fc41
diff --git a/xos/tosca/custom_types/vmme.m4 b/xos/tosca/custom_types/vmme.m4
index ee511ee..217af2d 100644
--- a/xos/tosca/custom_types/vmme.m4
+++ b/xos/tosca/custom_types/vmme.m4
@@ -22,3 +22,19 @@
VMME Tenant
properties:
xos_base_tenant_props
+
+ tosca.nodes.VMMEVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VMME 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.VMMETenant ]
+
diff --git a/xos/tosca/custom_types/vmme.yaml b/xos/tosca/custom_types/vmme.yaml
index 1f8aa77..20cf99f 100644
--- a/xos/tosca/custom_types/vmme.yaml
+++ b/xos/tosca/custom_types/vmme.yaml
@@ -92,3 +92,19 @@
type: string
required: false
description: Service specific ID opaque to XOS but meaningful to service
+
+ tosca.nodes.VMMEVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VMME 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.VMMETenant ]
+
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)