- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
Enhanced Security Measures in Place: To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.
03-13-2021 02:01 PM
Hello all;
I have the following script:
#!/usr/bin/python3
import panos
from panos import base
from panos import firewall
from panos import panorama
from panos import policies
from panos import objects
from panos import network
from panos import device
from panos.policies import Rulebase, SecurityRule
fw = firewall.Firewall("192.168.122.5", "admin", "admin")
webserver = objects.AddressObject("Apache-webserver", "5.5.5.5", description="Company web server")
fw.add(webserver)
webserver.create()
fw.commit()
#Create a new rule
new_rule = panos.policies.SecurityRule("Madinah-Rule", description="Madinah")
#rule = Rulebase.add(SecurityRule("Madinah-Rule"))
Rulebase.add(new_rule)
new_rule.create()
fw.commit(Sync=True)
But when I run it using the command python3 script.py I am getting the error:
Traceback (most recent call last):
File "madinah-pan-os-script.py", line 22, in <module>
Rulebase.add(new_rule)
TypeError: add() missing 1 required positional argument: 'child'
Can someone please point me in the right direction. I guess it has something to do with difference in Python2 and Python3.
03-15-2021 09:44 AM
Hi there,
You need to create a rulebase object before you can add to it:
#Create a new rule
rulebase = fw.add(Rulebase())
new_rule = rulebase.add(panos.policies.SecurityRule("Madinah-Rule", description="Madinah"))
cheers,
Seb.
03-15-2021 09:44 AM
Hi there,
You need to create a rulebase object before you can add to it:
#Create a new rule
rulebase = fw.add(Rulebase())
new_rule = rulebase.add(panos.policies.SecurityRule("Madinah-Rule", description="Madinah"))
cheers,
Seb.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!