<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 User <EOL> from services . cord . models import CordSubscriberRoot <EOL> from xosresource import XOSResource <EOL> class XOSCORDUser ( XOSResource ) : <EOL> provides = "<STR_LIT>" <EOL> def get_model_class_name ( self ) : <EOL> return "<STR_LIT>" <EOL> def get_subscriber_root ( self , throw_exception = True ) : <EOL> sub_name = self . get_requirement ( "<STR_LIT>" , throw_exception = throw_exception ) <EOL> sub = self . get_xos_object ( CordSubscriberRoot , name = sub_name , throw_exception = throw_exception ) <EOL> return sub <EOL> def get_existing_objs ( self ) : <EOL> result = [ ] <EOL> sub = self . get_subscriber_root ( throw_exception = False ) <EOL> if not sub : <EOL> return [ ] <EOL> for user in sub . users : <EOL> if user [ "<STR_LIT:name>" ] == self . obj_name : <EOL> result . append ( user ) <EOL> return result <EOL> def get_xos_args ( self ) : <EOL> args = { "<STR_LIT:name>" : self . obj_name , <EOL> "<STR_LIT>" : self . get_property ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" : self . get_property ( "<STR_LIT>" ) } <EOL> return args <EOL> def create ( self ) : <EOL> xos_args = self . get_xos_args ( ) <EOL> sub = self . get_subscriber_root ( ) <EOL> sub . create_user ( ** xos_args ) <EOL> sub . save ( ) <EOL> self . info ( "<STR_LIT>" % ( self . obj_name , sub . name ) ) <EOL> def update ( self , obj ) : <EOL> pass <EOL> def delete ( self , obj ) : <EOL> if ( self . can_delete ( obj ) ) : <EOL> self . info ( "<STR_LIT>" % obj [ "<STR_LIT:name>" ] ) <EOL> sub = self . get_subscriber_root ( ) <EOL> sub . delete_user ( obj [ "<STR_LIT:id>" ] ) <EOL> sub . save ( ) <EOL> def can_delete ( self , obj ) : <EOL> return True </s>
