vladimirs-git / fortigate-api

Python package for configuring Fortigate (Fortios) devices using REST API
Apache License 2.0
61 stars 18 forks source link

How to get license status of passive firewall in HA Cluster mode via API ? #33

Closed FrancisPrakash closed 1 month ago

vladimirs-git commented 2 months ago

Using the following example, you can get HA and license statuses

from pprint import pprint

from fortigate_api import FortiGate

HOST = "host"
USERNAME = "username"
PASSWORD = "password"

fgt = FortiGate(host=HOST, username=USERNAME, password=PASSWORD)

# Get HA master/slave status
response = fgt.get(url="api/v2/monitor/system/ha-checksums")
print(f"GET {response}", )  # POST <Response [200]>
result = response.json()["results"]
pprint(result)
# GET <Response [200]>
# [{'checksum': {'all': 'd626cc36457249e24d66cc69003363a7',
# ...
#   'is_manage_master': 0,
#   'is_root_master': 0,
# ...
#   'is_manage_master': 1,
#   'is_root_master': 1,
# ...

# Get license status
response = fgt.get(url="api/v2/monitor/license/status")
print(f"GET {response}", )  # POST <Response [200]>
result = response.json()["results"]
pprint(result)
# GET <Response [200]>
# {'antispam': {'entitlement': 'SPAM',
#               'status': 'no_license',
#               'type': 'live_fortiguard_service'},
#  'antivirus': {'db_status': 'db_type_extended',
#   ...
FrancisPrakash commented 2 months ago

The suggested script doesn't connect to passive firewall in cluster and get license details..