Topic: tech juniper ijaut prev next
tech juniper ijaut > 06: Python Fundamentals
Junos PyEZ (jnpr.junos) provides similar capabilities to the Junos CLI.
This script uses PyEZ to upgrade the firmware on a remote device.
from jnpr.junos import Device
from jnpr.junos.utils.scp import SCP
dev = Device('172.25.11.1')
with SCP(dev, progress=True) as scp:
scp.put('/home/lab/jinstall-ppc-20.2R2.11-signed.tgz', remote_path='/var/tmp')
Verify that the software image was copied
from jnpr.junos.utils.start_shell import StartShell
dev = Device('172.25.11.1')
ss = StartShell(dev)
softwareimage = ss.run("ls -al /var/tmp/jinstall*")
print(softwareimage[1])
ss.close()
from jnpr.junos import Device
from pprint import print
dev = Device('172.25.11.1')
dev.open()
pprint(dev.facts)
dev.close();
from jnpr.junos import Device
from jnpr.junos.utils.start_shell import StartShell
dev = Device('172.25.11.1')
ss = StartShell(dev)
command = ss.run('cli -c "show system uptime"')
print(command[1])
ss.close()