Honor test=True across the state and module

This commit is contained in:
mickey 2013-09-05 09:08:48 -05:00
parent b5969ae571
commit 5b4eb5c172
2 changed files with 25 additions and 25 deletions

View File

@ -2113,11 +2113,15 @@ def mknod_chrdev(name,
minor,
mode))
try:
if os.mknod(name,
int(str(mode).lstrip('0'),8)|stat.S_IFCHR,
os.makedev(major,minor)) is None:
if __opts__['test']:
ret['changes'] = {'new' : 'Character device {0} created.'.format(name)}
ret['result'] = True
ret['result'] = None
else:
if os.mknod(name,
int(str(mode).lstrip('0'),8)|stat.S_IFCHR,
os.makedev(major,minor)) is None:
ret['changes'] = {'new' : 'Character device {0} created.'.format(name)}
ret['result'] = True
except OSError as exc:
#be happy it is already there....however, if you are trying to change the major/minor, you will need to unlink it first as os.mknod will not overwrite
if exc.errno != errno.EEXIST:
@ -2177,11 +2181,15 @@ def mknod_blkdev(name,
minor,
mode))
try:
if os.mknod(name,
int(str(mode).lstrip('0'),8)|stat.S_IFBLK,
os.makedev(major,minor)) is None:
if __opts__['test']:
ret['changes'] = {'new' : 'Block device {0} created.'.format(name)}
ret['result'] = True
ret['result'] = None
else:
if os.mknod(name,
int(str(mode).lstrip('0'),8)|stat.S_IFBLK,
os.makedev(major,minor)) is None:
ret['changes'] = {'new' : 'Block device {0} created.'.format(name)}
ret['result'] = True
except OSError as exc:
#be happy it is already there....however, if you are trying to change the major/minor, you will need to unlink it first as os.mknod will not overwrite
if exc.errno != errno.EEXIST:
@ -2236,9 +2244,13 @@ def mknod_fifo(name,
'result': False}
log.debug("Creating FIFO name:{0}".format(name))
try:
if os.mkfifo(name,int(str(mode).lstrip('0'),8)) is None:
if __opts__['test']:
ret['changes'] = {'new' : 'Fifo pipe {0} created.'.format(name)}
ret['result'] = True
ret['result'] = None
else:
if os.mkfifo(name,int(str(mode).lstrip('0'),8)) is None:
ret['changes'] = {'new' : 'Fifo pipe {0} created.'.format(name)}
ret['result'] = True
except OSError as exc:
#be happy it is already there
if exc.errno != errno.EEXIST:

View File

@ -2464,11 +2464,7 @@ def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'):
#if it is a character device
elif not __salt__['file.is_chrdev'](name):
if __opts__['test']:
ret['comment'] = "Test: file.mknod {0} {1} {2} {3} {4} {5} {6}".format(name, ntype, major, minor, user, group, mode)
ret['result'] = True
else:
ret = __salt__['file.mknod'](name, ntype, major, minor, user, group, mode)
ret = __salt__['file.mknod'](name, ntype, major, minor, user, group, mode)
#check the major/minor
else:
@ -2488,11 +2484,7 @@ def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'):
#if it is a block device
elif not __salt__['file.is_blkdev'](name):
if __opts__['test']:
ret['comment'] = "Test: file.mknod {0} {1} {2} {3} {4} {5} {6}".format(name, ntype, major, minor, user, group, mode)
ret['result'] = True
else:
ret = __salt__['file.mknod'](name, ntype, major, minor, user, group, mode)
ret = __salt__['file.mknod'](name, ntype, major, minor, user, group, mode)
#check the major/minor
else:
@ -2512,11 +2504,7 @@ def mknod(name, ntype, major=0, minor=0, user=None, group=None, mode='0600'):
#if it is a fifo
elif not __salt__['file.is_fifo'](name):
if __opts__['test']:
ret['comment'] = "Test: file.mknod {0} {1} {2} {3} {4}".format(name, ntype, user, group, mode)
ret['result'] = True
else:
ret = __salt__['file.mknod'](name, ntype, major, minor, user, group, mode)
ret = __salt__['file.mknod'](name, ntype, major, minor, user, group, mode)
#check the perms
else: