Revision 17c61836
b/lib/hypervisor/hv_base.py | ||
---|---|---|
49 | 49 |
# _CHECK values |
50 | 50 |
|
51 | 51 |
# must be afile |
52 |
_FILE_CHECK = (utils.IsNormAbsPath, "must be an absolute normal path", |
|
52 |
_FILE_CHECK = (utils.IsNormAbsPath, "must be an absolute normalized path",
|
|
53 | 53 |
os.path.isfile, "not found or not a file") |
54 | 54 |
|
55 | 55 |
# must be a directory |
56 |
_DIR_CHECK = (utils.IsNormAbsPath, "must be an absolute normal path", |
|
56 |
_DIR_CHECK = (utils.IsNormAbsPath, "must be an absolute normalized path",
|
|
57 | 57 |
os.path.isdir, "not found or not a directory") |
58 | 58 |
|
59 | 59 |
# nice wrappers for users |
b/lib/utils.py | ||
---|---|---|
1786 | 1786 |
raise |
1787 | 1787 |
|
1788 | 1788 |
def IsNormAbsPath(path): |
1789 |
"""Check whether a path is absolute and also "normal".
|
|
1789 |
"""Check whether a path is absolute and also normalized
|
|
1790 | 1790 |
|
1791 | 1791 |
This avoids things like /dir/../../other/path to be valid. |
1792 | 1792 |
|
b/test/ganeti.utils_unittest.py | ||
---|---|---|
975 | 975 |
def _pathTestHelper(self, path, result): |
976 | 976 |
if result: |
977 | 977 |
self.assert_(IsNormAbsPath(path), |
978 |
"Path %s should be absolute and normal" % path)
|
|
978 |
"Path %s should result absolute and normalized" % path)
|
|
979 | 979 |
else: |
980 | 980 |
self.assert_(not IsNormAbsPath(path), |
981 |
"Path %s should not be absolute and normal" % path)
|
|
981 |
"Path %s should not result absolute and normalized" % path)
|
|
982 | 982 |
|
983 | 983 |
def testBase(self): |
984 | 984 |
self._pathTestHelper('/etc', True) |
Also available in: Unified diff