Sei sulla pagina 1di 3

This recipe:

LLDP for device auto-discovery

LLDP for auto-discovery


Multi-core processing for concurrent compute & Recursive functions
PyEZ Tables & Views

Network gear
RE( Routing Engine) in MX960 (Say, Fxp0)

>> To provide the Fault-tolerance and redundancy on the Network

>> We would create a CSV file or Duplicate IP log file

Later, Python will parse through the file and retrive necessary fields
and populate a hash or relevant Data Structure

/var/log Directory on the Junos OS router

--> Parse the log file (Starting to find mappings for IP, VLAN and MAC)
Python & Perl doesnt support true parallelism (run Processes & Threads)

import argparse
import socket
import multiprocessing
import json
import os

#Flat structure like Tuples is more faster (Take up more memory)


run joins on than a dictionary

MySQL Table will store the operational data


and provide and interface that can later
be utilized by other scripts/monitoring tools

known_hosts = [] #hosts finished provisioning


new_hsots = []

>> Track down the IP Conflicts

A Table is associated with a View (Multipel fields with in View),


which is used to access fields in the Table items.
Line #54 in book (yml)

crontab -l
/usr/bin/python /home/anpradeep <..py 2>&1 > /dev/null

PyEZ Tables & Views

--> Take the input from a CSV file or an SQL DB

Parallelization of automation tasks on multiple devices is a very natural idea.

Inject the deactivate/delete/enable statements into the ACX Router


f

import multiprocessing
import time
from jnpr.junos.utils.fs import FS
from jnpr.junos.exception import *
import socket
import os, errno
import os.path

Worker Threads --> For Parallel & Expedited execution

with multiprocessing.pool(processes=NUM_PROCESSES) as process_pool:


process_pool.map(check_directory_usage, DEVICES)
process_pool.close()
process_pool.join()

from lxml import etree

user => root


password => Embe1mpls

from jnpr.junos import Device


from pprint import pprint

dev = Device(host='192.168.1.2', user='automation', password='juniper')


dev.open()
pprint(dev.facts)

dev.close()

impor getpass
from jnpr.junos import Device

host = None
uname = None
pw = None
if host == None
host = input("IP"

getpass.getpass()

Device(host='',

===
Lets pass an input file With all relevant details & Parse the arguments
from there
Receipes:

import getpass
from jnpr.junos import Device
import sys
import argparse

import time
import getpass import getpass

import os

fname = None
hname = None
uname = None

if filename == None:
fname = input("Enter Filename:")
if uname == None:

with open(filename) as f:
for line in f:
host = line.rstrip(os.linesep)

Potrebbero piacerti anche