Hi All,
I am not sure if am doing something different, it would be great if someone can suggest some ideas/solution. I am facing some issues when passing argument from file, its getting passed correctly but am not able to connect to the device,Not sure if am missing something.
However am not seeing the issue when am giving directly giving the host name into the script either as a single value or as an array[without using file]. Thanks
[regress@kvmsrv12 ~]$ python test4.py device.txt
Cannot connect to device: ConnectUnknownHostError('vsrx66.spglab.juniper.net')
[regress@kvmsrv12 ~]$ vim test4.py
from jnpr.junos import Device
from jnpr.junos.exception import *
from jnpr.junos.utils.sw import SW
import sys
import urllib
file=open(sys.argv[1], 'r')
line=file.readline()
#line='vsrx66.spglab.juniper.net';
print line
dev = Device(host=line, user="root", passwd="Embe1mpls")
try:
dev.open()
except Exception as err:
sys.stderr.write('Cannot connect to device: {0}\n'.format(err))
sys.exit(1)
print dev.facts
dev.close()
[regress@kvmsrv12 ~]$ ping vsrx66.spglab.juniper.net
PING vsrx66-ge-000.spglab.juniper.net (10.157.78.2) 56(84) bytes of data.
64 bytes from 10.157.78.2: icmp_seq=1 ttl=64 time=3.77 ms
64 bytes from 10.157.78.2: icmp_seq=2 ttl=64 time=1.77 ms
^C
--- vsrx66-ge-000.spglab.juniper.net ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1478ms
rtt min/avg/max/mdev = 1.770/2.770/3.771/1.001 ms
[regress@kvmsrv12 ~]$ nslookup vsrxx6.spglab.juniper.net
^C
[regress@kvmsrv12 ~]$ nslookup vsrx66.spglab.juniper.net
Server: 10.155.191.252
Address: 10.155.191.252#53
vsrx66.spglab.juniper.net canonical name = vsrx66-ge-000.spglab.juniper.net.
Name: vsrx66-ge-000.spglab.juniper.net
Address: 10.157.78.2
[regress@kvmsrv12 ~]$