Omar Abdelkader | 6e806dc | 2017-08-30 23:56:48 -0600 | [diff] [blame] | 1 | from xosresource import XOSResource |
| 2 | from core.models import Tenant, Service |
| 3 | from services.vepc.models import VEPCTenant |
| 4 | |
| 5 | class XOSVEPCTenant(XOSResource): |
| 6 | provides = "tosca.nodes.VEPCTenant" |
| 7 | xos_model = VEPCTenant |
| 8 | name_field = None |
| 9 | copyin_props = ("description", "has_vhss", "has_vmme", "has_vmm", "has_vsm", "has_vsgwc", "has_vsgwu", "has_vpgwc", "has_vpgwu",) |
| 10 | |
| 11 | def get_xos_args(self, throw_exception=True): |
| 12 | args = super(XOSVEPCTenant, self).get_xos_args() |
| 13 | |
| 14 | provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=throw_exception) |
| 15 | if provider_name: |
| 16 | args["provider_service"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name) |
| 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(XOSVEPCTenant, self).can_delete(obj) |