Yeela Kaplan has uploaded a new change for review.
Change subject: misc: remove rotateFiles ......................................................................
misc: remove rotateFiles
After removing the last usage of rotateFiles that was in sd setMetadata we can now remove this unused method.
Change-Id: I1abd244253ba9be64e8eee6daaeb785a18a150f0 Signed-off-by: Yeela Kaplan ykaplan@redhat.com --- M tests/miscTests.py M vdsm/storage/misc.py 2 files changed, 0 insertions(+), 101 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/77/48577/1
diff --git a/tests/miscTests.py b/tests/miscTests.py index 37f0ea0..e445b54 100644 --- a/tests/miscTests.py +++ b/tests/miscTests.py @@ -204,55 +204,6 @@ self.assertRaises(ValueError, misc.itmap(int, data, 0).next)
-class RotateFiles(TestCaseBase): - - def testNonExistingDir(self, persist=False): - """ - Tests that the method fails correctly when given a non existing dir. - """ - self.assertRaises(OSError, misc.rotateFiles, "/I/DONT/EXIST", "prefix", - 2, persist=persist) - - def testEmptyDir(self, persist=False): - """ - Test that when given an empty dir the rotator works correctly. - """ - prefix = "prefix" - with namedTemporaryDir() as dir: - misc.rotateFiles(dir, prefix, 0, persist=persist) - - def testFullDir(self, persist=False): - """ - Test that rotator does it's basic functionality. - """ - # Prepare - prefix = "prefix" - stubContent = ('"Multiple exclamation marks", ' - 'he went on, shaking his head, ' - '"are a sure sign of a diseased mind."') - # (C) Terry Pratchet - Small Gods - with namedTemporaryDir() as dir: - gen = 10 - - expectedDirContent = [] - for i in range(gen): - fname = "%s.txt.%d" % (prefix, i + 1) - expectedDirContent.append("%s.txt.%d" % (prefix, i + 1)) - f = open(os.path.join(dir, fname), "wb") - f.write(stubContent) - f.flush() - f.close() - - # Rotate - misc.rotateFiles(dir, prefix, gen, persist=persist) - - # Test result - currentDirContent = os.listdir(dir) - expectedDirContent.sort() - currentDirContent.sort() - self.assertEquals(currentDirContent, expectedDirContent) - - class ParseHumanReadableSize(TestCaseBase):
def testValidInput(self): diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py index d35c7a6..4422e39 100644 --- a/vdsm/storage/misc.py +++ b/vdsm/storage/misc.py @@ -466,58 +466,6 @@ return (size + SECTOR_SIZE - 1) / SECTOR_SIZE
-def rotateFiles(directory, prefixName, gen, cp=False, persist=False): - log.debug("dir: %s, prefixName: %s, versions: %s" % - (directory, prefixName, gen)) - gen = int(gen) - files = os.listdir(directory) - files = glob.glob("%s*" % prefixName) - fd = {} - for fname in files: - name = fname.rsplit('.', 1) - try: - ind = int(name[1]) - except ValueError: - name[0] = fname - ind = 0 - except IndexError: - ind = 0 - except: - continue - if ind < gen: - fd[ind] = {'old': fname, 'new': name[0] + '.' + str(ind + 1)} - - keys = fd.keys() - keys.sort(reverse=True) - log.debug("versions found: %s" % (keys)) - - for key in keys: - oldName = os.path.join(directory, fd[key]['old']) - newName = os.path.join(directory, fd[key]['new']) - if utils.isOvirtNode() and persist and not cp: - try: - utils.unpersist(oldName) - utils.unpersist(newName) - except: - pass - try: - if cp: - execCmd([constants.EXT_CP, oldName, newName], sudo=True) - if (utils.isOvirtNode() and - persist and not os.path.exists(newName)): - utils.persist(newName) - - else: - os.rename(oldName, newName) - except: - pass - if utils.isOvirtNode() and persist and not cp: - try: - utils.persist(newName) - except: - pass - - def parseHumanReadableSize(size): # FIXME : Maybe use a regex -> ^(?P<num>\d+)(?P<sizeChar>[KkMmGgTt])$ # FIXME : Why not support B and be done with it?
gerrit-hooks has posted comments on this change.
Change subject: misc: remove rotateFiles ......................................................................
Patch Set 1:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
gerrit-hooks has posted comments on this change.
Change subject: misc: remove rotateFiles ......................................................................
Patch Set 2:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
gerrit-hooks has posted comments on this change.
Change subject: misc: remove rotateFiles ......................................................................
Patch Set 1:
* propagate_review_values: OK
Nir Soffer has posted comments on this change.
Change subject: misc: remove rotateFiles ......................................................................
Patch Set 2: Code-Review-1
Please reverse the order of the patches.
1. remove rotateFiles - we can merge it now since it does not do anything useful for copule of years 2. This setMetadata and the backup directory - need more thinking
The first patch should remove the rotateFiles function, the single call to it, and the broken tests.
The second patch should do the rest.
vdsm-patches@lists.fedorahosted.org