forked from packethost/ruby-junos-ez-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst_hosts.rb
33 lines (24 loc) · 920 Bytes
/
st_hosts.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'pry'
require 'pp'
require 'yaml'
require 'net/netconf/jnpr'
require 'junos-ez/stdlib'
# login information for NETCONF session
login = { :target => ARGV[0], :username => 'jeremy', :password => 'jeremy1', }
## create a NETCONF object to manage the device and open the connection ...
ndev = Netconf::SSH.new( login )
$stdout.print "Connecting to device #{login[:target]} ... "
ndev.open
$stdout.puts "OK!"
## Now bind providers to the device object.
## the 'Junos::Ez::Provider' must be first before all others
## this provider will setup the device 'facts'. The other providers
## allow you to define the instance variables; so this example
## is using 'l1_ports' and 'ip_ports', but you could name them
## what you like, yo!
Junos::Ez::Provider( ndev )
Junos::Ez::StaticHosts::Provider( ndev, :hosts )
pp ndev.hosts.list
pp ndev.hosts.catalog
binding.pry
ndev.close