From cf61cf60feb2e81dbccb8f7b3b7c693739f4122f Mon Sep 17 00:00:00 2001 From: MaximeBuchet Date: Fri, 10 Aug 2018 15:45:25 +0200 Subject: [PATCH 1/3] Add syslog configuration Support --- FortigateApi.py => FortigateApi.py_addsyslog | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) rename FortigateApi.py => FortigateApi.py_addsyslog (98%) diff --git a/FortigateApi.py b/FortigateApi.py_addsyslog similarity index 98% rename from FortigateApi.py rename to FortigateApi.py_addsyslog index ec3e09b..dc40bea 100644 --- a/FortigateApi.py +++ b/FortigateApi.py_addsyslog @@ -122,6 +122,45 @@ 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 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. From 5715c27ae758bd0ab3b98d1a098b0f235ebcd4f7 Mon Sep 17 00:00:00 2001 From: MaximeBuchet Date: Fri, 10 Aug 2018 15:46:09 +0200 Subject: [PATCH 2/3] Rename --- FortigateApi.py_addsyslog => FortigateApi.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename FortigateApi.py_addsyslog => FortigateApi.py (100%) diff --git a/FortigateApi.py_addsyslog b/FortigateApi.py similarity index 100% rename from FortigateApi.py_addsyslog rename to FortigateApi.py From 66026474b55c1961d5ff573c59ba2fe5b38082a5 Mon Sep 17 00:00:00 2001 From: MaximeBuchet Date: Fri, 10 Aug 2018 17:50:25 +0200 Subject: [PATCH 3/3] Add Ntp configuration support --- FortigateApi.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/FortigateApi.py b/FortigateApi.py index dc40bea..3a72114 100644 --- a/FortigateApi.py +++ b/FortigateApi.py @@ -161,6 +161,46 @@ def AddSyslog(self, status, server, reliable, port, facility, source_ip, 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.