def resize(self, index, old, new):

        log.info("Resizing RRA %d in %s from %d to %d rows" %
                (index, self._rrafile, old, new))

        assert old != new
        diff = abs(old - new)
        if new > old:
            dir = "GROW"
        else:
            dir = "SHRINK"

        # resize *always* writes to ./resize.rrd which isn't
        # particularly helpful but we can work with it.
        cwd = os.getcwd()
        tmp = tempfile.mkdtemp(dir=self._rradir)
        try:
            os.chdir(tmp)
            rrdtool.resize(self._rrafile, str(index), dir, str(diff))
            shutil.copymode(self._rrafile, "resize.rrd")
            os.rename("resize.rrd", self._rrafile)
        finally:
            os.chdir(cwd)
            os.rmdir(tmp)
Wrapper around rrdtool resize to add/remove rows from an RRA
dataset/ETHPy150Open marineam/nagcat/python/nagcat/trend.py/Trend.resize