Versions Compared

Key

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

...

4- PyEZ:   python facts.py


Code Block
titlefacts.py
collapsetrue
/project # more facts.py
import sys
from pprint import pprint
from jnpr.junos import Device
from jnpr.junos.exception import ConnectError

dev = Device(host='
192
172.
168
30.
99
95.
11
177',user='
ansible
Netbox',passwd='
ansible123
Netbox')
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)

dev.close()





Code Block
titlepython facts.py
collapsetrue
/project # python facts.py
#print everything

{'2RE': False,
 'HOME': '/var/home/ansible',
 'RE0': None,
 'RE1': None,
 'RE_hw_mi': None,
 'current_re': ['re0'],
 'domain': None,
 'fqdn': 'vMX1',
 'hostname': 'vMX1',
 'hostname_info': {'re0': 'vMX1'},
 'ifd_style': 'CLASSIC',
 'junos_info': {'re0': {'object': junos.version_info(major=(12, 1), type=R, minor=1, build=9),
                        'text': '12.1R1.9'}},
 'master': None,
 'model': 'OLIVE',
 'model_info': {'re0': 'OLIVE'},
 'personality': 'OLIVE',
 're_info': None,
 're_master': None,
 'serialnumber': None,
 'srx_cluster': None,
 'srx_cluster_id': None,
 'srx_cluster_redundancy_group': None,
 'switch_style': 'NONE',
 'vc_capable': False,
 'vc_fabric': None,
 'vc_master': None,
 'vc_mode': None,
 'version': '12.1R1.9',
 'version_RE0': '12.1R1.9',
 'version_RE1': None,
 'version_info': junos.version_info(major=(12, 1), type=R, minor=1, build=9),
 'virtual': True}