IpsecTunnel api refresh

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

IpsecTunnel api refresh

L2 Linker

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 ? 

 

 

4 REPLIES 4

L2 Linker

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

Looks like the problem is that you haven't imported pandevice.network at all.  Once you do that, you should be ok.

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.

thank you for the additional guidance.. ill work on this more today and let you know my outcome.

  • 4764 Views
  • 4 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!