Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Syslog Configuration support #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions FortigateApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,85 @@ def Exists(self, url, objects):
return True
return False
#

def AddSyslog(self, status, server, reliable, port, facility, source_ip, comment=''):
"""
Configure syslog parameters on the firewall, return ok if it already exists.

Parameters
----------
status: Logging enabled on the firewall (type string)
server: syslog server ip's (type string)
reliable: ??? (type string)
port : udp port used for syslog
facility: facility used to send logs (type string)
source-ip: source-ip used to send syslog messages (type string)
comment: (type string)

Returns
-------
Http status code: 200 if ok, 4xx if an error occurs
"""
status = str(status)
server = str(server)
reliable = str(reliable)
port = str(port)
facility = str(facility)
source_ip=str(source_ip)

payload = {'json':
{
'status': status,
'server': server,
'reliable': reliable,
'port': port,
'facility': facility,
'source-ip': source_ip,
'comments': comment
}
}
return self.ApiSet('cmdb/log.syslogd/setting/', payload)

def AddNtp(self, ntpsync, type, syncinterval, ntpserver, source_ip, server_mode, interface, comment=''):
"""
Configure NTP parameters on the firewall, return ok if it already exists.

Parameters
----------
ntpsync: active ntpsync (type string)
type: ntp server type (type string)
syncinterval: syncinterval in sec (type string)
ntpserver: ntpserver ip address (type [])
source_ip: ??? (type string)
server_mode : server mode (type string)
interface: interface (type string)
comment: (type string)

Returns
-------
Http status code: 200 if ok, 4xx if an error occurs
"""
ntpsync = str(ntpsync)
type = str(type)
syncinterval = str(syncinterval)
ntpserver = str(ntpserver)
server_mode = str(server_mode)
interface = str(interface)
source_ip=str(source_ip)
payload = {'json':
{
'ntpsync': ntpsync,
'type': type,
'syncinterval': syncinterval,
'ntpserver': ntpserver,
'server_mode': server_mode,
'interface': interface,
'source_ip': source_ip,
'comments': comment
}
}
return self.ApiSet('cmdb/system/ntp/', payload)

def GetVdom(self, name=''):
'''
Return the json vdom object, when the param name is defined it returns the selected object, without name: return all the objects.
Expand Down