Murat Parlakisik | 66fde4d | 2016-09-22 13:28:13 -0700 | [diff] [blame^] | 1 | import importlib |
| 2 | import os |
| 3 | import pdb |
| 4 | import sys |
| 5 | import tempfile |
| 6 | sys.path.append("/opt/tosca") |
| 7 | from translator.toscalib.tosca_template import ToscaTemplate |
| 8 | from core.models import Tenant, Service |
| 9 | from services.vsgwservice.models import * |
| 10 | |
| 11 | from xosresource import XOSResource |
| 12 | |
| 13 | class 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 | |