- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-02-2019 06:43 AM - edited 08-02-2019 08:33 AM
im trying to get a list of ipsec tunnels from each template stack i have. but anytime i attempt to use the class pandevice.network.IpsecTunnel i receive an error that pandevice doesnt have an attribute network.... according to the documentation here:
https://pandevice.readthedocs.io/en/latest/module-network.html
it does have a class pandevice.network.IpsecTunnel do i need to define something before i can reference this class ?
08-02-2019 08:36 AM
import sys
import io
import json
import pandevice
from pandevice import base
from pandevice import firewall
from pandevice import panorama
from pandevice import objects
from pandevice import policies
from pandevice.panorama import Panorama
devices = [ device1, device2, device3 ]
templates = [Temp1, Temp2, Temp3, Temp4]
auth_key = "mykey"
fw = firewall.Firewall()
#to define which panorama you will connect to
for device in devices:
pano = panorama.Panorama(device, api_key=auth_key)
# when you need to fetch objects in the Device Group
for temp in templates:
tempgrp = pandevice.panorama.Template(temp)
pano.add(tempgrp)
ipsecgrp = pandevice.network.IpsecTunnel.refreshall(panogrp)
pano.add(ipsecgrp)
objects_list = []
for object_element in ipsec_object_list:
obj = {
'name': object_element.name,
'tunnel_interface': object_element.tunnel_interface,
'type': object_element.type,
}
objects_list.append(obj)
for object in objects_list:
print (object)
print()
08-05-2019 09:07 AM
Looks like the problem is that you haven't imported pandevice.network
at all. Once you do that, you should be ok.
08-05-2019 09:13 AM
Two other comments:
First is that you shouldn't do pano.add(ipsecgrp)
after the refresh. The objects are already in the pandevice object tree (as children of the template), so you don't need to add them in again.
If you want to print out details of an object, you can use the .about()
function that all pandevice objects have. If you just want to see a few params and not everything, then making a separate dict and printing that is fine.
08-05-2019 09:22 AM
thank you for the additional guidance.. ill work on this more today and let you know my outcome.
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!