<s> import os <EOL> import pdb <EOL> import sys <EOL> import tempfile <EOL> sys . path . append ( "<STR_LIT>" ) <EOL> from translator . toscalib . tosca_template import ToscaTemplate <EOL> import pdb <EOL> from core . models import Service , User , CoarseTenant , AddressPool <EOL> from xosresource import XOSResource <EOL> class XOSService ( XOSResource ) : <EOL> provides = "<STR_LIT>" <EOL> xos_model = Service <EOL> copyin_props = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def postprocess ( self , obj ) : <EOL> for provider_service_name in self . get_requirements ( "<STR_LIT>" ) : <EOL> provider_service = self . get_xos_object ( Service , name = provider_service_name ) <EOL> existing_tenancy = CoarseTenant . get_tenant_objects ( ) . filter ( provider_service = provider_service , subscriber_service = obj ) <EOL> if existing_tenancy : <EOL> self . info ( "<STR_LIT>" % ( str ( obj ) , str ( provider_service ) ) ) <EOL> else : <EOL> tenancy = CoarseTenant ( provider_service = provider_service , <EOL> subscriber_service = obj ) <EOL> tenancy . save ( ) <EOL> self . info ( "<STR_LIT>" % ( str ( obj ) , str ( provider_service ) ) ) <EOL> for ap_name in self . get_requirements ( "<STR_LIT>" ) : <EOL> ap = self . get_xos_object ( AddressPool , name = ap_name ) <EOL> ap . service = obj <EOL> ap . save ( ) <EOL> def can_delete ( self , obj ) : <EOL> if obj . slices . exists ( ) : <EOL> self . info ( "<STR_LIT>" % obj . name ) <EOL> return False <EOL> return super ( XOSService , self ) . can_delete ( obj ) </s>
