Technical Tip: How to add a model device to FortiManager using the API
Description
This article describes how to add a model device to FortiManager using the FortiManager API.
Â
Scope
FortiManager.
Â
Solution
Use the following API call to create a Model Devices under the Device Manager database.
Â
{
"method": "exec",
"params": [
{
"data": {
"adom": "<ADOM>",
"device": {
"device action": "add_model",
"name": "<Model_Device_Name>",
"mgmt_mode": "fmg",
"os_ver": "7.0",
"mr": 4,
"os_type": "fos",
"sn": "<Serial Number of FortiGate>"
},
"flags": [
"none"
]
},
"url": "/dvm/cmd/add/device"
}
],
"session": "<SESSION_ID>",
"id": 2
}Here, 'os_ver'Â is the version and 'mr' is the patch; in this case, the version of the model device will be v7.4.
Optional Flags can be used:
Flag | Action |
|---|---|
linked_to_model | Automatically Link to Real Device |
need_reset | ZTP Factory Reset |
sdwan_management | Managmenet through SDWAN Manager (v7.6 and higher) |
override_management_intf | Enforce Device Configuration |
Add model HA cluster:
Under the 'device' part of the API call, use the following options:
"ha_mode": "AP",
"ha_group_name": "ha_cluster",
"ha_group_id": 1,
"ha_slave": [
{
"idx": 0,
"sn": "<Primary Serial>",
"psk": "",
"name": "<Model Device Name>",
"role": "master",
"prio": 1
},
{
"sn": "<Secondary Serial>",
"psk": "",
"idx": 1,
"name": "<Device Name for Secondary>",
"role": "slave",
"prio": 0
}
]ha-mode: 'AA' for Active-Active and 'AP' for Active Passive.
name: For primary the name should match the Model Device Name.
idx: Index - start from 0.
psk: Set only if using Pre-Shared Key option instead of Serial Number.
prio: Prority, Primary should have higher value.
Add Model Device Using Blueprint:
Under the 'device' part of the API call, use the following option:
"device blueprint": "<Blueprint Name>",
Note: Make sure the Blueprint exists in FortiManager. See Using device blueprints for model devices.
Verify device creation:
{
"method": "get",
"params": [
{
"url": "/dvmdb/adom/<ADOM_NAME>/device"
}
],
"session": "<SESSION_ID>",
"id": 3
}
Troubleshooting:
The following commands can be used on the FortiManager CLI to debug the API Calls:
diagnose debug service httpd 255
diagnose debug service main 255
diagnose debug enableÂ
Related articles:
