blob: 4ef27ab4c79f5e23f0fd9fd83bb2cd1f5d08b90f [file] [log] [blame]
Saleil Bhat1c5593d2017-01-06 15:25:57 -08001from xosresource import XOSResource
Omar Abdelkader2c162842017-08-07 19:41:59 -06002from core.models import Tenant, Service
3from services.vmme.models import VMMETenant
Saleil Bhat1c5593d2017-01-06 15:25:57 -08004
5class XOSVMMETenant(XOSResource):
6 provides = "tosca.nodes.VMMETenant"
7 xos_model = VMMETenant
Omar Abdelkader2c162842017-08-07 19:41:59 -06008 name_field = None
Omar Abdelkadere7cae952017-08-23 18:21:43 -06009 copyin_props = ()
Saleil Bhat1c5593d2017-01-06 15:25:57 -080010
11 def get_xos_args(self, throw_exception=True):
12 args = super(XOSVMMETenant, self).get_xos_args()
13
Omar Abdelkader2c162842017-08-07 19:41:59 -060014 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=throw_exception)
Saleil Bhat1c5593d2017-01-06 15:25:57 -080015 if provider_name:
Omar Abdelkader2c162842017-08-07 19:41:59 -060016 args["provider_service"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name)
Saleil Bhat1c5593d2017-01-06 15:25:57 -080017
18 return args
19
20 def get_existing_objs(self):
21 args = self.get_xos_args(throw_exception=False)
22 provider_service = args.get("provider", None)
23 if provider_service:
24 return [ self.get_xos_object(provider_service=provider_service) ]
25 return []
26
27 def postprocess(self, obj):
28 pass
29
30 def can_delete(self, obj):
31 return super(XOSVMMETenant, self).can_delete(obj)
Omar Abdelkader41fa5352017-08-25 12:52:40 -060032