def update_image_2(self, container_name, image_name):
        """
        update a container's image,
        :param container_name: `class`:`str`, container name
        :param image_name: `class`:`str`, the full image name, like alpine:3.3
        :return: `class`:`bool`, True if success, otherwise False.
        """
        code, container = self.get_container(container_name)
        if code == httplib.NOT_FOUND:
            raise ContainerNotFound(container_name)
        elif code != httplib.OK:
            raise GeneralError(code)

        _, old_image_name, _ = utils.parse_image_name(container.image)
        repository, name, version = utils.parse_image_name(image_name)
        if not repository or repository.lower() != DOCKER_NEG:
            image_name = '{0}/{1}:{2}'.format(DOCKER_NEG, name, version)

        if not repo.image_exists(name, tag=version):
            raise ImageNotFound("{0} do not location in docker.neg repository.".format(image_name))

        if old_image_name.lower() != name.lower():
            raise ImageConflict("{0} is not be same with container's Image.".format(image_name))

        code, result = self.pull_image(name, version)
        if code != httplib.OK:
            raise GeneralError(
                'pull image {0}:{1} failure, status code {2}, result: {3}'.format(name, version, code, result))

        code, result = self.update(container_name, tag=version)
        if code != httplib.OK:
            raise GeneralError(
                'Update container {0} failure, status code {1}, result: {2}'.format(container_name, code, result))

        return True
def update_image_2 ( self , container_name , image_name ) : code , container = self . get_container ( container_name ) if code == httplib . NOT_FOUND : raise ContainerNotFound ( container_name ) elif code != httplib . OK : raise GeneralError ( code ) _ , old_image_name , _ = utils . parse_image_name ( container . image ) repository , name , version = utils . parse_image_name ( image_name ) if not repository or repository . lower ( ) != DOCKER_NEG : image_name = '{0}/{1}:{2}' . format ( DOCKER_NEG , name , version ) if not repo . image_exists ( name , tag = version ) : raise ImageNotFound ( "{0} do not location in docker.neg repository." . format ( image_name ) ) if old_image_name . lower ( ) != name . lower ( ) : raise ImageConflict ( "{0} is not be same with container's Image." . format ( image_name ) ) code , result = self . pull_image ( name , version ) if code != httplib . OK : raise GeneralError ( 'pull image {0}:{1} failure, status code {2}, result: {3}' . format ( name , version , code , result ) ) code , result = self . update ( container_name , tag = version ) if code != httplib . OK : raise GeneralError ( 'Update container {0} failure, status code {1}, result: {2}' . format ( container_name , code , result ) ) return True
update a container's image,
        :param container_name: `class`:`str`, container name
        :param image_name: `class`:`str`, the full image name, like alpine:3.3
        :return: `class`:`bool`, True if success, otherwise False.