blob: cbc383731ad5f8415c7a930655f40189551a1f33 [file] [log] [blame]
Scott Baker8e6647a2016-06-20 17:16:20 -07001import os
2import pdb
3import sys
4import tempfile
5sys.path.append("/opt/tosca")
6from translator.toscalib.tosca_template import ToscaTemplate
7import pdb
8
9from core.models import User
10from services.volt.models import VOLTTenant, VOLTService, CordSubscriberRoot, VOLT_KIND
11
12from xosresource import XOSResource
13
14class XOSVOLTTenant(XOSResource):
15 provides = "tosca.nodes.VOLTTenant"
16 xos_model = VOLTTenant
17 copyin_props = ["service_specific_id", "s_tag", "c_tag"]
18 name_field = None
19
20 def get_xos_args(self, throw_exception=True):
21 args = super(XOSVOLTTenant, self).get_xos_args()
22
23 provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
24 if provider_name:
25 args["provider_service"] = self.get_xos_object(VOLTService, throw_exception=throw_exception, name=provider_name)
26
27 subscriber_name = self.get_requirement("tosca.relationships.BelongsToSubscriber")
28 if subscriber_name:
29 args["subscriber_root"] = self.get_xos_object(CordSubscriberRoot, throw_exception=throw_exception, name=subscriber_name)
30
31 return args
32
33 def get_existing_objs(self):
34 args = self.get_xos_args(throw_exception=False)
35 provider_service = args.get("provider_service", None)
36 service_specific_id = args.get("service_specific_id", None)
37 if (provider_service) and (service_specific_id):
38 existing_obj = self.get_xos_object(VOLTTenant, kind=VOLT_KIND, provider_service=provider_service, service_specific_id=service_specific_id, throw_exception=False)
39 if existing_obj:
40 return [ existing_obj ]
41 return []
42
43 def postprocess(self, obj):
44 pass
45
46 def can_delete(self, obj):
47 return super(XOSVOLTTenant, self).can_delete(obj)
48