add Vendor model to select flavor/image at Tenant creation

Change-Id: Ifde87eaa83b0559c83afd7010068dd5465125e37
diff --git a/xos/tosca/custom_types/vsgwu.m4 b/xos/tosca/custom_types/vsgwu.m4
index ef81b31..566715c 100644
--- a/xos/tosca/custom_types/vsgwu.m4
+++ b/xos/tosca/custom_types/vsgwu.m4
@@ -22,3 +22,19 @@
             VSGWU Tenant
         properties:
             xos_base_tenant_props
+
+    tosca.nodes.VSGWUVendor:
+        derived_from: tosca.nodes.Root
+        description: >
+            VSGWU 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.VSGWUTenant ]
+
diff --git a/xos/tosca/custom_types/vsgwu.yaml b/xos/tosca/custom_types/vsgwu.yaml
index b231cf3..5f81a89 100644
--- a/xos/tosca/custom_types/vsgwu.yaml
+++ b/xos/tosca/custom_types/vsgwu.yaml
@@ -92,3 +92,19 @@
                 type: string
                 required: false
                 description: Service specific ID opaque to XOS but meaningful to service
+
+    tosca.nodes.VSGWUVendor:
+        derived_from: tosca.nodes.Root
+        description: >
+            VSGWU 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.VSGWUTenant ]
+
diff --git a/xos/tosca/resources/vsgwuvendor.py b/xos/tosca/resources/vsgwuvendor.py
new file mode 100644
index 0000000..4fffecf
--- /dev/null
+++ b/xos/tosca/resources/vsgwuvendor.py
@@ -0,0 +1,32 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vsgwu.models import VSGWUVendor
+
+class XOSVSGWUVendor(XOSResource):
+    provides = "tosca.nodes.VSGWUVendor"
+    xos_model = VSGWUVendor
+    name_field = None
+    copyin_props = ( "name",)
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSVSGWUVendor, 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(XOSVSGWUVendor, self).can_delete(obj)
+