add_model_device
Adds a model device for offline provisioning, enabling policies, templates, and per-device values to be prepared before the FortiGate connects.
Instructions
Add a model device for offline provisioning.
Model devices allow pre-configuring policies and settings before the actual device connects to FortiManager. Useful for zero-touch provisioning workflows.
With device_blueprint the new device inherits what the blueprint
defines (template group, policy package, groups, enforced firmware...),
and meta_variables supplies the per-device values its templates
reference as $(name) -- the same fields the GUI "Add Model Device"
dialog sends. Nothing is pushed to a real FortiGate: a model device is
a placeholder until a FortiGate with this serial registers.
API coverage: device blueprint, patch and the HA attributes
(ha_mode, ha_group_name, ha_slave) are in the bundled dvmcmd
schema (7.2 to 8.0), the HA ones flagged internal; a model HA cluster
was verified on FortiManager 8.0.2. The meta variables key is not in
the bundled API reference: it is what the 8.0 GUI sends, verified on
FortiManager 8.0.2, where each entry becomes a "global" per-device
mapping and a name the ADOM does not have yet is created as a new
metadata variable with an empty default (so a misspelt name leaves a
stray variable behind; check names with list_metadata_variables).
The add is refused if the ADOM already has a device with this name or
serial number. Safety: a blueprint that sets a firmware template or
prefer-img-ver binds the device to a firmware version FortiManager
can install on the FortiGate when it registers (a reboot), so under
FMG_FIRMWARE_SAFETY=strict (default) it needs confirm=True, as
upgrade_device_firmware does. So does a saved blueprint that cannot be
read to check.
Args:
adom: ADOM name where device will be added
name: Device display name
serial_number: Device serial number (e.g., "FGVM020000123456");
checked against the FortiGate/Fortinet serial format
platform: Platform type (default: "FortiGate-VM64")
os_version: FortiOS version, "7.4" or with patch "7.4.12"
(default: "7.0")
description: Device description
device_blueprint: Name of a saved device blueprint, or an inline
blueprint object (what the GUI sends with the blueprint option
unchecked), e.g. {"pkg": "branch_pkg",
"prov-type": "template-group", "template-group": "branch_templates",
"dev-group": ["emea_spokes"], "prerun-cliprof": "bootstrap"}.
Attributes follow fmg/device/blueprint; every object it names
(package, template group, device groups, templates, CLI and
authorization templates, firmware template) is looked up first
and the add is refused if one does not exist. A saved blueprint
name is checked the same way.
meta_variables: Per-device meta-variable values, e.g.
{"hostname": "b1", "branch_id": "1", "port3": "192.0.2.1/24"}.
Values are strings or numbers, at most 255 characters, with no
newlines or other control characters and none of ", \,
#, {{, {%, {# or $( (templates paste them into
CLI as is). Password-type values are masked in the result
groups: Device group names to add the device to (root VDOM)
ha_mode: Declare a model HA cluster: "AP" (active-passive) or "AA".
name/serial_number are then the primary member and the
cluster's device name in FMG.
ha_group_name: HA cluster group name (required with ha_mode, max 36
characters)
ha_priority: HA priority of the primary member (default 128)
ha_members: Secondary members, each
{"name": "branch3-1", "serial_number": "FGVM...", "priority": 100}
flags: dvm/cmd/add/device flags, e.g. ["create_task"] (the GUI sends
["create_task", "nonblocking"]); the task ID is returned
confirm: Must be True to add from a blueprint that enforces a
firmware version, under FMG_FIRMWARE_SAFETY=strict (default).
Ignored when FMG_FIRMWARE_SAFETY=disabled.
Returns: dict: Add result with keys: - status: "success" or "error" - device: Added device information - message: Status or error message
Example: >>> result = await add_model_device( ... adom="root", ... name="FGT-NewBranch", ... serial_number="FGVM02TM12345678", ... platform="FortiGate-60F", ... os_version="7.4" ... )
>>> # From a blueprint, with the variables its templates use
>>> result = await add_model_device(
... adom="demo",
... name="branch1",
... serial_number="FGVM020000123456",
... platform="FortiGate-VM64-KVM",
... os_version="7.4.12",
... device_blueprint="branch_standalone_blueprint",
... meta_variables={"hostname": "branch1", "branch_id": "1"},
... )
>>> # A two-member active-passive model cluster
>>> result = await add_model_device(
... adom="demo",
... name="branch3",
... serial_number="FGVM020000123457",
... platform="FortiGate-VM64-KVM",
... os_version="7.4.12",
... device_blueprint="branch_cluster_blueprint",
... ha_mode="AP",
... ha_group_name="branch3_cluster",
... ha_priority=200,
... ha_members=[{"name": "branch3-1",
... "serial_number": "FGVM020000123458", "priority": 100}],
... )
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"adom": "<adom>",
"name": "<name>",
"serial_number": "<serial_number>"
},
"name": "add_model_device"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| adom | Yes | ||
| name | Yes | ||
| flags | No | ||
| groups | No | ||
| confirm | No | ||
| ha_mode | No | ||
| platform | No | FortiGate-VM64 | |
| ha_members | No | ||
| os_version | No | 7.0 | |
| description | No | ||
| ha_priority | No | ||
| ha_group_name | No | ||
| serial_number | Yes | ||
| meta_variables | No | ||
| device_blueprint | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||