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