Python modules to use Fortigate APIs
Project description
fortiosAPI Overview
Opensource python library to configure Fortigate/Fortios devices (Fortigate REST API)
Ready for config management.
Compare to the REST API there a few add-ons: In addition to get,put,post,delete methods there is a set which will try to post and if failing will put and collect the mkey directly. The lib will also find the mkey for you
Examples
You can find and propose examples here: https://github.com/fortinet-solutions-cse/fortiosapi-examples Separated to avoid cluttering those who integrate the fortiosapi module.
### New overlay configuration
You now have an overlayconfig call which can be pass a complex configuration change in yaml. Including multiple endpoints (name/path) as the simple example below shows:
antivirus:
profile:
apisettree:
"scan-mode": "quick"
'http': {"options": "scan avmonitor",}
"emulator": "enable"
firewall:
policy:
67:
'name': "Testfortiosapi"
'action': "accept"
'srcintf': [{"name": "port1"}]
'dstintf': [{"name": "port2"}]
'srcaddr': [{"name": "all"}]
'dstaddr': [{"name": "all"}]
'schedule': "always"
'service': [{"name": "HTTPS"}]
"utm-status": "enable"
"profile-type": "single"
'av-profile': "apisettree"
'profile-protocol-options': "default"
'ssl-ssh-profile': "certificate-inspection"
'logtraffic': "all"
The behaviour is to change the parameters at the higher level in the CMDB tree first then do a serie of set on the tables.
Will fail if one of the set fails.
Order in the yaml is preserved.
Login methods
User/password
Token (api key) documented in the Fortigate API Spec that you can find if having an account on http://fndn.fortinet.net/
Multi vdom
In multi vdom environment use vdom=global in the API call. As it is a reserved word the API will switch to use the global=1 and take care of the differences in the repsonses.
Schema
There is a get_schema call and an example to get the schema of the differents methods to ease writting them.
License (5.6)
A rest call to check and force license validation check starting with 5.6 See license. usage of schema and mkey for every call for 5.6
License validity is now checked at login
Versions
Test driven development
In tests folder you will find a tox based set of tests as examples. The test_fortiosapi_virsh need you to have virsh access, especially to the console. This allow to perform actions automatically from the CLI and check API calls actual results. Other tests are welcomed.
Files upload/download
You will find the calls to exchange files (config, logs, licenses) with Fortigate in this LIB
Known Usage
Fortiosapi library is used in Home-Assistant, Fortinet Ansible modules and in Cloudify plugins.
Maintained mainly by Fortinet employees.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fortiosapi-1.0.5.tar.gz
.
File metadata
- Download URL: fortiosapi-1.0.5.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37269d9dceeebeddfcf5b43932db9dc1f1f4f9b292e0931d2483e31949eb5099 |
|
MD5 | a74dd5b84678aca9a1187f39e77a1e2a |
|
BLAKE2b-256 | 88eb3bebe6506edfcf9bc7de5638728dcab09ad3c141e976cbeb883531c6f383 |
File details
Details for the file fortiosapi-1.0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: fortiosapi-1.0.5-py2.py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a39aee01a6fc7861330897f601ada3ad7024c1f84690656b7df99089e5c25f4c |
|
MD5 | 8955334f0ea6907bcbfb4b701666b7e0 |
|
BLAKE2b-256 | 403fc40b800c8ae8cb730528044cbb1175c229e17330a1503e9db063030215b9 |