Reply
L1 Bithead

New to Python:Having issues with pandevice

Getting below error when connecting to firewall:

 

>>> import pandevice

>>> fw = Firewall("137.117.105.197", “firewall”, “firewall@123”)

  File "<stdin>", line 1

    fw = Firewall("137.117.105.197", “firewall”, “firewall@123”)

                                              ^

SyntaxError: invalid character in identifier

>>> print fw.op("show system info")

  File "<stdin>", line 1

    print fw.op("show system info")

          ^

SyntaxError: invalid syntax


Accepted Solutions
Highlighted
L4 Transporter

Re: New to Python:Having issues with pandevice

This is a python syntax problem, you just need to fix your imports.  You need to do either this:

 

import pandevice

fw = pandevice.firewall.Firewall("137.117.105.197", “firewall”, “firewall@123”)

 

or this (recommended):

 

from pandevice.firewall import Firewall

fw = Firewall("137.117.105.197", “firewall”, “firewall@123”)

 

View solution in original post


All Replies
Highlighted
L2 Linker

Re: New to Python:Having issues with pandevice

@ansmittal 

 

I have never used pandevice module. But as an alternative, you get the system info by using either one of the below options.

 

1. By using PA API, requests module (to make API call) & xml.etree.ElementTree module (to parse the xml output of API call).

 

or

 

2. By using netmiko library. It allow to do SSH to multiple networking vendor devices. You can find more info here.

 

https://pynet.twb-tech.com/blog/automation/netmiko.html 

Highlighted
L4 Transporter

Re: New to Python:Having issues with pandevice

This is a python syntax problem, you just need to fix your imports.  You need to do either this:

 

import pandevice

fw = pandevice.firewall.Firewall("137.117.105.197", “firewall”, “firewall@123”)

 

or this (recommended):

 

from pandevice.firewall import Firewall

fw = Firewall("137.117.105.197", “firewall”, “firewall@123”)

 

View solution in original post

Highlighted
L1 Bithead

Re: New to Python:Having issues with pandevice

Thanks.I got that figured out.I had another question, I am running below script

import pandevice
from pandevice import base
from pandevice import firewall
from pandevice import panorama
from pandevice import policies
from pandevice import objects
from pandevice import network
from pandevice import device
fw = firewall.Firewall("40.71.172.9", api_username= "Pa-pan", api_password= "firewall@123")
baseAddressA = "10.1.1."

for x in range(10):
AddressA = baseAddressA + str(x)
AddressAName = "AddressA-" + str(x)
fw.add(objects.AddressObject(AddressAName,AddressA)).create()

 

I am expecting objects between 1-9 to be  created but I only see one object getting created i.e AddressA-9=10.1.1.9

 

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 Live Community as a whole!

The Live Community thanks you for your participation!