New to Python:Having issues with pandevice

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

New to Python:Having issues with pandevice

L1 Bithead

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

1 accepted solution

Accepted Solutions

L5 Sessionator

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

3 REPLIES 3

L3 Networker

@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 

L5 Sessionator

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”)

 

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

 

  • 1 accepted solution
  • 5465 Views
  • 3 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!