blob: 82158a14c9028ca81e4e53d5df838aa1bfd61b02 [file] [log] [blame]
Scott Baker8e6647a2016-06-20 17:16:20 -07001from core.models import User
Scott Bakerc15556d2017-05-06 09:55:01 -07002from services.volt.models import VOLTTenant, VOLTService, VOLT_KIND
3from services.rcord.models import CordSubscriberRoot
Scott Baker8e6647a2016-06-20 17:16:20 -07004
5from xosresource import XOSResource
6
7class XOSVOLTTenant(XOSResource):
8 provides = "tosca.nodes.VOLTTenant"
9 xos_model = VOLTTenant
10 copyin_props = ["service_specific_id", "s_tag", "c_tag"]
11 name_field = None
12
13 def get_xos_args(self, throw_exception=True):
14 args = super(XOSVOLTTenant, self).get_xos_args()
15
16 provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
17 if provider_name:
18 args["provider_service"] = self.get_xos_object(VOLTService, throw_exception=throw_exception, name=provider_name)
19
20 subscriber_name = self.get_requirement("tosca.relationships.BelongsToSubscriber")
21 if subscriber_name:
22 args["subscriber_root"] = self.get_xos_object(CordSubscriberRoot, throw_exception=throw_exception, name=subscriber_name)
23
24 return args
25
26 def get_existing_objs(self):
27 args = self.get_xos_args(throw_exception=False)
28 provider_service = args.get("provider_service", None)
29 service_specific_id = args.get("service_specific_id", None)
30 if (provider_service) and (service_specific_id):
31 existing_obj = self.get_xos_object(VOLTTenant, kind=VOLT_KIND, provider_service=provider_service, service_specific_id=service_specific_id, throw_exception=False)
32 if existing_obj:
33 return [ existing_obj ]
34 return []
35
36 def postprocess(self, obj):
37 pass
38
39 def can_delete(self, obj):
40 return super(XOSVOLTTenant, self).can_delete(obj)
41