Hello everybody,
I have a fortimanager with several ADOMs, and inside each ADOM there are devices that have a device name, what I would like to do is export the names of all the ADOMs and all the devices inside the ADOMs but I haven't found anything about it .
Do you happen to think of anything useful about it?
BR.
Solved! Go to Solution.
Hello GiuseppeB,
All the info you ask about is available in the cli with the output from the following command :
# diag dvm device list
You may need to do some manipulation to put it in the format you require with this data, should not be too hard !
Hello GiuseppeB,
All the info you ask about is available in the cli with the output from the following command :
# diag dvm device list
You may need to do some manipulation to put it in the format you require with this data, should not be too hard !
Hello Fredery,
the goal is do it with a call from API python, but im stuck to some error in the script, maybe you can give me some advise to repair the problem,
The script
import requests
import json
import urllib3
# Disable SSL verification warning
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# FortiManager API endpoint and credentials
url = "https://192.168.178.120/jsonrpc"
username = "admin"
password = "admin"
# FortiManager API method to get the list of devices
method = "getDeviceList"
# JSON-RPC request payload
payload = {
"id": 1,
"method": method,
"params": [{}],
"session": requests.session().headers.get("Cookie"),
}
# Send the JSON-RPC request to FortiManager API endpoint
response = requests.post(url, json=payload, auth=(username, password), verify=False)
# Parse the JSON response
response_json = json.loads(response.text)
if isinstance(response_json, list): # response is a list of JSON objects
devices = []
for obj in response_json:
devices.append(obj.get("name"))
else: # response is a single JSON object
devices = response_json.get("result", {}).get("data", [])
# Print the list of devices
for device in devices:
print(device)
And the error is
C:\Users\elimi\Python310>python fmg.py
Traceback (most recent call last):
File "C:\Users\elimi\Python310\fmg.py", line 35, in <module>
devices = response_json.get("result", {}).get("data", [])
AttributeError: 'list' object has no attribute 'get'
Select Forum Responses to become Knowledge Articles!
Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.
User | Count |
---|---|
1740 | |
1108 | |
752 | |
447 | |
240 |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2024 Fortinet, Inc. All Rights Reserved.