It doesn' t look like the decision on which real integer is used to store the policy in configuration is made until ' end' commits it to the running or startup config. Look at the output when the CLI debug level is set to 8:
McFortiGate # di de reset
McFortiGate # di de en
McFortiGate # di de cli 8
McFortiGate # conf firewall policy
McFortiGate (policy) # edit 0
new entry ' 0' added
McFortiGate (0) # set srcintf FortiLAN
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set dstintf wan1
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set srcaddr all
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set dstaddr all
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set schedule always
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set service ALL
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set action accept
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # set nat en
path=firewall, objname=policy, size=1388, sz_attr=1
McFortiGate (0) # end
cmd_clean_context 0, abort=0
McFortiGate # write config file success, prepare to save in flash
[__create_file_new_version:560] the new version config file ' /data/./config/vd_root_firewall_policy.gz.v000000076' is created
[symlink_config_file:627] a new version of ' /data/./config/vd_root_firewall_policy.gz' is created: /data/./config/vd_root_firewall_policy.gz.v000000076
[symlink_config_file:670] the old version ' /data/./config/vd_root_firewall_policy.gz.v000000075' is deleted
[symlink_config_file:673] ' /data/./config/vd_root_firewall_policy.gz' has been symlink' ed to the new version ' /data/./config/vd_root_firewall_policy.gz.v000000076' . The old version ' /data/./config/vd_root_firewall_policy.gz.v000000075' has been deleted
zip config file /data/./config/vd_root_firewall_policy.gz success!
The context of policy 0 is ' cleaned' after typing ' end' , and the rest of the output notes that a new file has replaced the old file. It looks like it would be *theoretically* possible to try piping the output of the new file created to another container, and by script, parse the file to see the diff between the old and new configs, and pull the policy ID from that file at the bottom of the ' config firewall policy' section, if you really wanted to know right away. Even here, though, it' s after ' end' is typed. I don' t think the kernel handles the process of policy creation in a way that it could note the real number before the full policy is committed.
Regards,
Chris McMullan
Fortinet Ottawa