vladimirs-git / fortigate-api

Python package for configuring Fortigate (Fortios) devices using REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copying Policy

zephyr2k7 opened this issue · comments

Hi I'm trying to user the API to read policies from one firewall and create the very same on another.
reading work perfectly but when I create the policy i get error 500.

I read all policies
for policy in oldfgt.policy.get():
if policy["status"] == "enable":
policies.append(policy)

the filter on which i want i my array then:

for policy in policies:
print("create "+policy['name']);
if confirm_choice() == 'c':
try:
response = newfgt.policy.create(data=policy)
print("policy.create", response)
except:
print("exception "+policy['name'])
else:
print("skip "+policy['name'])

Should I remove some filed on the object?
policyid and uuid ar e then as read from the source, mut I remove those fields?

Thanks in advance

please start logging DEBUG messages at the top of your code.
This will show you more verbose reason of 500 error

import logging

logging.getLogger().setLevel(logging.DEBUG)

Before creating the policy, you need to create the addresses and all other objects related to policy

Removing uuid and other unsupported keys is not required, the new firewall will simply ignore them

Hi,
thanks very much with the complete log it was clear it was a missing object causing this errors, not the policy import script is working fine