Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

https://www.juniper.net/documentation/en_US/junos-pyez/topics/task/program/junos-pyez-program-device-connecting.html


Widget Connector
urlhttps://www.youtube.com/watch?v=53rEwb7Va6g

Code Block
titlefacts with pyez
collapsetrue
import sys
import json
import yaml
from pprint import pprint
from jnpr.junos import Device
from jnpr.junos.exception import ConnectError

dev = Device(host='192.168.99.11',user='ansible',passwd='ansible123')
try:
    dev.open()
except ConnectError as err:
    print ("Cannot connect to device: {0}".format(err))
    sys.exit(1)

#print("#print everything\n")
#pprint (dev.facts)

#print("\n#print only the version")
#pprint (dev.facts['version'])

print (yaml.dump(dev.facts))

#print (json.dumps(dev.facts))

dev.close()

...