Add addressobject to specific device group through panorama via python

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

Add addressobject to specific device group through panorama via python

L2 Linker

Ok, i will first start by saying ive never attempted anything like this before. Im an old school network engineer but times are a changing and im trying to learn how to automate simple tasks. All I need to do is promt the user to enter and IP address and then add that IP Address to a specific device group with 1 tag on it.  for example i want to add 7.7.7.7 to my firewall with the tag SFTP. So once the object hits the firewall the name would be H-7.7.7.7 and description would simply be the ticket number of the request and the ip would be learned via input and then I would automatically include the tag. ive been reading forums and other items and came up with a little script below.  This is what I have so far, but im kinda stuck now. Ive only been messing around with this for a couple of days... 

 

#This defines the panorama device interface to connect to and the DeviceGroup
device = ["x.x.x.x"]
devicegroup = ["mydevice"]
auth_key = "<my-key>"

 

#This intitaties the panorama connection 
pano = panorama.Panorama(device, api_key=auth_key)

 

#This defines the device group we wil be connecting to
panogrp = panorama.DeviceGroup(devicegroup)
pano.add(panogrp)

 

#This will set the IP address of the SFTP source to add to the Firewall 
ip_address = input('Please enter the ip address you wish to add to the SFTP whitelist, (example x.x.x.x): ')

 

#This will set the description of the node to the Release Ticket number
description = input("Please enter the release ticket number: ")

 

#This formats the name to match the existing standards in the firewall
name = ("H-"+ip_address)

 

#declares an object to create

sftp_server = pandevice.objects.AddressObject()
panogrp.add(sftp_server)

 

any suggestions to make it better and or complete the adding of the node..im not sure im even on the right path so far... thanks for any insight ... 🙂

 

0 REPLIES 0
  • 2571 Views
  • 0 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!