blob: d9239f9138da2dbab3c9ffdbf5a0991921309848 [file] [log] [blame]
Scott Baker619de672016-06-20 12:49:38 -07001import importlib
2import os
3import pdb
4import sys
5import tempfile
6sys.path.append("/opt/tosca")
7from translator.toscalib.tosca_template import ToscaTemplate
8from core.models import Tenant, Service
9from services.exampleservice.models import ExampleTenant, SERVICE_NAME as EXAMPLETENANT_KIND
10
11from xosresource import XOSResource
12
13class XOSExampleTenant(XOSResource):
14 provides = "tosca.nodes.ExampleTenant"
15 xos_model = ExampleTenant
16 name_field = "service_specific_id"
17 copyin_props = ("tenant_message",)
18
19 def get_xos_args(self, throw_exception=True):
20 args = super(XOSExampleTenant, self).get_xos_args()
21
22 # ExampleTenant must always have a provider_service
23 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
24 if provider_name:
25 args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
26
27 return args
28
29 def get_existing_objs(self):
30 args = self.get_xos_args(throw_exception=False)
31 return ExampleTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
32 return []
33
34 def can_delete(self, obj):
35 return super(XOSExampleTenant, self).can_delete(obj)
36