Merge pull request #5571 from jamesalbert/patch-2

Added rename function
This commit is contained in:
Thomas S Hatch 2013-06-16 20:09:50 -07:00
commit 4e93830df9

View File

@ -925,6 +925,22 @@ def symlink(src, link):
raise CommandExecutionError('Could not create "{0}"'.format(link))
return False
def rename(src, dst):
'''
Rename a file or directory
CLI Example
salt '*' file.rename /path/to/src /path/to/dst
'''
if not os.path.isabs(src):
raise SaltInvocationError('File path must be absolute.')
try:
os.rename(src, dst)
return True
except OSError:
raise CommandExecutionError('Could not rename "{0}" to "{1}"'.format(src, dst))
return False
def stats(path, hash_type='md5', follow_symlink=False):
'''
Return a dict containing the stats for a given file