blob: 29ea5f60d059c37a461114e0a2e5ed3ee103d324 [file] [log] [blame]
Murat Parlakisik66fde4d2016-09-22 13:28:13 -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.vsgwservice.models import *
10
11from xosresource import XOSResource
12
13class XOSVSGWTenant(XOSResource):
14 provides = "tosca.nodes.ExampleTenant"
15 xos_model = VSGWTenant
16 name_field = "service_specific_id"
17 copyin_props = ("tenant_message",)
18
19 def get_xos_args(self, throw_exception=True):
20 args = super(XOSVSGWTenant, 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 VSGWTenant.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(XOSVSGWTenant, self).can_delete(obj)
36