mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-01 22:09:08 -07:00
Improve Fortios IPv4 policy with logging capabilities and use the backup_filename param (#23544)
* Improve Fortios IPv4 policy with logging capabilities. While there, fix typos in examples. forti_config: use the backup_filename param and dont enforce the the filename value. * forti-typos * Add version_added for new options in the documentation
This commit is contained in:
parent
92a425a532
commit
811eb66703
2 changed files with 37 additions and 5 deletions
|
@ -65,13 +65,17 @@ fortios_error_codes = {
|
|||
|
||||
def backup(module,running_config):
|
||||
backup_path = module.params['backup_path']
|
||||
backup_filename = module.params['backup_filename']
|
||||
if not os.path.exists(backup_path):
|
||||
try:
|
||||
os.mkdir(backup_path)
|
||||
except:
|
||||
module.fail_json(msg="Can't create directory {0} Permission denied ?".format(backup_path))
|
||||
tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time()))
|
||||
filename = '%s/%s_config.%s' % (backup_path, module.params['host'], tstamp)
|
||||
if 0 < len(backup_filename):
|
||||
filename = '%s/%s' % (backup_path, backup_filename)
|
||||
else:
|
||||
filename = '%s/%s_config.%s' % (backup_path, module.params['host'], tstamp)
|
||||
try:
|
||||
open(filename, 'w').write(running_config)
|
||||
except:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue