Enhanced Security Measures in Place:   To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.

Error in simple policy creation script

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Error in simple policy creation script

L2 Linker

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.

1 accepted solution

Accepted Solutions

L3 Networker

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.

View solution in original post

1 REPLY 1

L3 Networker

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.

  • 1 accepted solution
  • 2147 Views
  • 1 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!