Adding file check and empty list return to freebsd_sysctl.py

This commit is contained in:
Gareth J. Greenaway 2018-11-07 15:59:50 -08:00
parent 469c090330
commit 95a7f125a7
No known key found for this signature in database
GPG Key ID: 10B62F8A7CAD7A41

View File

@ -6,6 +6,7 @@ Module for viewing and modifying sysctl parameters
# Import Python libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
import os
# Import salt libs
import salt.utils.files
@ -66,6 +67,10 @@ def show(config_file=False):
comps = ['']
if config_file:
# If the file doesn't exist, return an empty list
if not os.path.exists(config_file):
return []
try:
with salt.utils.files.fopen(config_file, 'r') as f:
for line in f.readlines():