This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ipaddress import IPv4Network | |
# mock link data | |
g_links = [ | |
{'local': dict(name='leaf-1', ifname='swp1'), | |
'remote': dict(name='rtr-1', ifname='eth1/1')}, | |
{'local': dict(name='leaf-1', ifname='swp2'), | |
'remote': dict(name='rtr-2', ifname='eth2/1')}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for hosts wtih _os = 'junos' | |
--- | |
eth_nei_table: | |
rpc: get-lldp-neighbors-information | |
item: lldp-neighbor-information | |
key: lldp-local-interface | |
view: eth_nei_record | |
eth_nei_record: | |
fields: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> dev | |
Device(srx210) | |
# import the filesystem library and bind it to the device (dev) | |
>>> from jnpr.junos.utils.fs import * | |
>>> fs = FS(dev) | |
# use the 'cat' function to dump the content of the file | |
>>> print fs.cat('/var/log/dcd') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 1999-2011, Juniper Networks Inc. | |
# All rights reserved. | |
# Author: Jeremy Schulman | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from ncclient import manager as ncclient | |
from ncclient.operations.rpc import RPCError | |
from lxml import etree | |
### --------------------------------------------------------------------------- | |
### unix invocation: | |
### $ python change_interface_admin.py <hostname> <portname> [up|down] | |
### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#domain-needed | |
bogus-priv | |
expand-hosts | |
addn-hosts=/var/lib/dnsmasq/hosts | |
# interfaces ... | |
interface=eth1 | |
# DCHP configs ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/netconf/jnpr' | |
require 'junos-ez/stdlib' | |
require 'junos-ez/srx' | |
login = { :target => 'vsrx', :username => 'jeremy', :password => 'jeremy1', } | |
### open a NETCONF session to the SRX device | |
ndev = Netconf::SSH.new( login ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'highline/import' | |
require 'net/netconf/jnpr' | |
target = ARGV[0] || begin | |
puts "You must specify a starting target device" | |
exit 1 | |
end | |
dst_route = ARGV[1] || begin | |
puts "You need to specify a destination route" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'highline/import' | |
require 'net/netconf/jnpr' | |
start_at = ARGV[0] || begin | |
puts "You need to specify a starting target ip/host" | |
exit 1 | |
end | |
my_username = ENV["USER"] | |
puts "login: #{my_username}" |