(self, target, image_id=None, template=None, parameters=None)
TODO: Docstring for customize_image_for_target

        @param factory_image TODO
        @param target TODO 
        @param target_params TODO

        @return TODO
TODO: Docstring for customize_image_for_target
TODO : Docstring for customize_image_for_target
def customize_image_for_target(self, target, image_id=None, template=None, parameters=None):
        """
        TODO: Docstring for customize_image_for_target

        @param factory_image TODO
        @param target TODO 
        @param target_params TODO

        @return TODO
        """

        self.target_image = TargetImage()
        self.target_image.target = target
        self.target_image.base_image_id = image_id
        self.target_image.template = template
        if parameters:
            self.target_image.parameters = parameters
        self.pim.add_image(self.target_image)        
        if parameters and ('callbacks' in parameters):
            # This ensures we have workers in place before any potential state changes
            self._init_callback_workers(self.target_image, parameters['callbacks'], self._target_image_cbws)

        if(image_id and (not template)):
            self.base_image = self.pim.image_with_id(image_id)
            template = self.base_image.template
            self.target_image.template = template
        elif template:
            self.build_image_from_template(template, parameters)
            # Populate the base_image property of our target image correctly
            # (The ID value is always available immediately after the call above)
            image_id = self.base_image.identifier
            self.target_image.base_image_id = self.base_image.identifier
        elif template and image_id:
            raise ImageFactoryException("Must specify either a template or a BaseImage ID, not both")
        else:
            raise ImageFactoryException("Asked to create a TargetImage without a BaseImage or a template")

        # Both base_image and target_image exist at this point and have IDs and status
        # We can now launch our thread and return to the caller
        
        thread_name = str(uuid.uuid4())[0:8]
        thread_kwargs = {'target':target, 'image_id':image_id, 'template':template, 'parameters':parameters}
        self.target_thread = Thread(target=self._customize_image_for_target, name=thread_name, args=(), kwargs=thread_kwargs)
        self.target_thread.start()
def customize_image_for_target ( self , target , image_id = None , template = None , parameters = None ) : self . target_image = TargetImage ( ) self . target_image . target = target self . target_image . base_image_id = image_id self . target_image . template = template if parameters : self . target_image . parameters = parameters self . pim . add_image ( self . target_image ) if parameters and ( 'callbacks' in parameters ) : # This ensures we have workers in place before any potential state changes self . _init_callback_workers ( self . target_image , parameters [ 'callbacks' ] , self . _target_image_cbws ) if ( image_id and ( not template ) ) : self . base_image = self . pim . image_with_id ( image_id ) template = self . base_image . template self . target_image . template = template elif template : self . build_image_from_template ( template , parameters ) # Populate the base_image property of our target image correctly # (The ID value is always available immediately after the call above) image_id = self . base_image . identifier self . target_image . base_image_id = self . base_image . identifier elif template and image_id : raise ImageFactoryException ( "Must specify either a template or a BaseImage ID, not both" ) else : raise ImageFactoryException ( "Asked to create a TargetImage without a BaseImage or a template" ) # Both base_image and target_image exist at this point and have IDs and status # We can now launch our thread and return to the caller thread_name = str ( uuid . uuid4 ( ) ) [ 0 : 8 ] thread_kwargs = { 'target' : target , 'image_id' : image_id , 'template' : template , 'parameters' : parameters } self . target_thread = Thread ( target = self . _customize_image_for_target , name = thread_name , args = ( ) , kwargs = thread_kwargs ) self . target_thread . start ( )