(self, provider, credentials, target, image_id, template, parameters, my_image_id)
TODO: Docstring for push_image_to_provider

        @param image TODO
        @param provider TODO
        @param credentials TODO
        @param provider_params TODO 

        @return TODO
TODO: Docstring for push_image_to_provider
TODO : Docstring for push_image_to_provider
def push_image_to_provider(self, provider, credentials, target, image_id, template, parameters, my_image_id):
        """
        TODO: Docstring for push_image_to_provider

        @param image TODO
        @param provider TODO
        @param credentials TODO
        @param provider_params TODO 

        @return TODO
        """

        # If operating as a secondary we will have the provider_image ID dictated to us - otherwise it is None and it is created
        self.provider_image = ProviderImage(image_id = my_image_id) 
        self.provider_image.provider = provider
        self.provider_image.credentials = credentials
        self.provider_image.target_image_id = image_id
        self.provider_image.template = template
        self.pim.add_image(self.provider_image)
        if parameters and ('callbacks' in parameters):
            # This ensures we have workers in place before any potential state changes
            self._init_callback_workers(self.provider_image, parameters['callbacks'], self._provider_image_cbws)

        if(image_id and (not template)):
            self.target_image = self.pim.image_with_id(image_id)
            if not self.target_image:
                raise ImageFactoryException("Unable to retrieve target image with id (%s) from storage" % (image_id))
            # If we are being called as a secondary do not try to look up the base image
            if not my_image_id:
                self.base_image = self.pim.image_with_id(self.target_image.base_image_id)
                if not self.base_image:
                    raise ImageFactoryException("Unable to retrieve base image with id (%s) from storage" % (image_id))
            template = self.target_image.template
            self.provider_image.template = template
        elif template and image_id:
            raise ImageFactoryException("Must specify either a template or a TargetImage ID, not both")
        elif template:
            self.customize_image_for_target(target=target , image_id=None, template=template, parameters=parameters)
            # Populate the target_image value of our provider image properly
            # (The ID value is always available immediately after the call above)
            # self.base_image is created in cascading fashion from the above call
            image_id = self.target_image.identifier
            self.provider_image.target_image_id = self.target_image.identifier
        else:
            raise ImageFactoryException("Asked to create a ProviderImage without a TargetImage or a template")

        thread_name = str(uuid.uuid4())[0:8]
        thread_kwargs = {'provider':provider, 'credentials':credentials, 'target':target, 'image_id':image_id, 'template':template, 'parameters':parameters}
        self.push_thread = Thread(target=self._push_image_to_provider, name=thread_name, args=(), kwargs=thread_kwargs)
        self.push_thread.start()
def push_image_to_provider ( self , provider , credentials , target , image_id , template , parameters , my_image_id ) : # If operating as a secondary we will have the provider_image ID dictated to us - otherwise it is None and it is created self . provider_image = ProviderImage ( image_id = my_image_id ) self . provider_image . provider = provider self . provider_image . credentials = credentials self . provider_image . target_image_id = image_id self . provider_image . template = template self . pim . add_image ( self . provider_image ) if parameters and ( 'callbacks' in parameters ) : # This ensures we have workers in place before any potential state changes self . _init_callback_workers ( self . provider_image , parameters [ 'callbacks' ] , self . _provider_image_cbws ) if ( image_id and ( not template ) ) : self . target_image = self . pim . image_with_id ( image_id ) if not self . target_image : raise ImageFactoryException ( "Unable to retrieve target image with id (%s) from storage" % ( image_id ) ) # If we are being called as a secondary do not try to look up the base image if not my_image_id : self . base_image = self . pim . image_with_id ( self . target_image . base_image_id ) if not self . base_image : raise ImageFactoryException ( "Unable to retrieve base image with id (%s) from storage" % ( image_id ) ) template = self . target_image . template self . provider_image . template = template elif template and image_id : raise ImageFactoryException ( "Must specify either a template or a TargetImage ID, not both" ) elif template : self . customize_image_for_target ( target = target , image_id = None , template = template , parameters = parameters ) # Populate the target_image value of our provider image properly # (The ID value is always available immediately after the call above) # self.base_image is created in cascading fashion from the above call image_id = self . target_image . identifier self . provider_image . target_image_id = self . target_image . identifier else : raise ImageFactoryException ( "Asked to create a ProviderImage without a TargetImage or a template" ) thread_name = str ( uuid . uuid4 ( ) ) [ 0 : 8 ] thread_kwargs = { 'provider' : provider , 'credentials' : credentials , 'target' : target , 'image_id' : image_id , 'template' : template , 'parameters' : parameters } self . push_thread = Thread ( target = self . _push_image_to_provider , name = thread_name , args = ( ) , kwargs = thread_kwargs ) self . push_thread . start ( )