-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupgrade-junos.py
26 lines (22 loc) · 949 Bytes
/
upgrade-junos.py
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
# usage:
# download the Junos packages ```openconfig``` and ```network agent``` from Juniper download website and save them locally
# vi data.yml
# python ./upgrade-junos.py
from yaml import load
from jnpr.junos.utils.sw import SW
from jnpr.junos import Device
f=open('data.yml', 'r')
data=load(f.read())
devices_list = data['telegraf']['openconfig']['hosts']
username = data['telegraf']['openconfig']['username']
password = data['telegraf']['openconfig']['password']
f.close()
pkgs_list = ['network-agent-x86-32-18.2R1-S3.2-C1.tgz', 'junos-openconfig-x86-32-0.0.0.10-1.tgz']
for pkg in pkgs_list:
for item in devices_list:
print 'adding the package ' + pkg + ' to the device ' + item
device=Device (host=item, user=username, password=password)
device.open()
sw = SW(device)
sw.install(package=pkg, validate=False, no_copy=False, progress=True, remote_path="/var/home/jcluser")
device.close()