Kurt,
Firstly, thank you for your reply.
This was a good idea but unfortunately pyez doesn't recognize edit as a valid configuration format. The relevant parts of the script I wrote (I'm still very new at this, be gentle!):
import sys
from jnpr.junos.exception import *
from getpass import getpass
import socket
import time
#define credentials
userid = raw_input('username: ')
hidepass = getpass()
#define devices
devlist = ['router1', 'router2', 'router3']
dev = [Device(host, user=userid, password=hidepass) for host in devlist]
time = time.strftime("%d/%m/%Y")
# Open the device, handle exceptions
for d in dev:
try:
d.open()
except Exception as err:
print "Cannot connect to device:", err
#get abuse IP, check for validity
while True:
badip = raw_input('enter abuse IP: ')
try:
socket.inet_aton(badip)
break
except socket.error:
print "IP address is not valid, please enter valid IP address"
continue
#push abuse IP to temp abuse ACL
for d in dev:
print "device: {0}".format(d)
d.bind( cu=Config )
print "Loading configuration changes"
d.cu.load("set firewall family inet filter TEST_FILTER term temp_abuse_ips from source-address {abuseip}".format(abuseip=badip))
d.cu.load("edit firewall family inet filter TEST_FILTER term temp_abuse_ips from source-address {abuseip}".format(abuseip=badip))
d.cu.load("annotate \"blocked time by userid\"").format(time=time, userid=userid)
Edit isn't recognized as a value for the load method
Traceback (most recent call last):
File "filepath", line 42, in <module>
d.cu.load("edit firewall family inet filter TEST_FILTER term temp_abuse_ips from source-address {abuseip}".format(abuseip=badip))
File "/usr/lib/python2.6/site-packages/jnpr/junos/utils/config.py", line 338, in load
"Not able to resolve the config format "
RuntimeError: Not able to resolve the config format You must define the format of the contents explicitly to the function. Ex: format='set'