Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 1 | from xosresource import XOSResource |
Omar Abdelkader | 2c16284 | 2017-08-07 19:41:59 -0600 | [diff] [blame] | 2 | from core.models import Tenant, Service |
| 3 | from services.vmme.models import VMMETenant |
Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 4 | |
| 5 | class XOSVMMETenant(XOSResource): |
| 6 | provides = "tosca.nodes.VMMETenant" |
| 7 | xos_model = VMMETenant |
Omar Abdelkader | 2c16284 | 2017-08-07 19:41:59 -0600 | [diff] [blame] | 8 | name_field = None |
Omar Abdelkader | e7cae95 | 2017-08-23 18:21:43 -0600 | [diff] [blame] | 9 | copyin_props = () |
Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 10 | |
| 11 | def get_xos_args(self, throw_exception=True): |
| 12 | args = super(XOSVMMETenant, self).get_xos_args() |
| 13 | |
Omar Abdelkader | 2c16284 | 2017-08-07 19:41:59 -0600 | [diff] [blame] | 14 | provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=throw_exception) |
Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 15 | if provider_name: |
Omar Abdelkader | 2c16284 | 2017-08-07 19:41:59 -0600 | [diff] [blame] | 16 | args["provider_service"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name) |
Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 17 | |
| 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 Abdelkader | 41fa535 | 2017-08-25 12:52:40 -0600 | [diff] [blame^] | 32 | |