Hi,
I am doing a project in PyEz, but I encountered one issue with sw.install function. The main logic of this project is to upgrade a srx box with PyEz, so the project reach out to download needed Junos version from online, store it locally and use sw.install() function followed by a sw.reboot() function to upgrade srx. Below is a snippet of my code:
def install_process(dev, msg):
print("{}:{}".format(dev.hostname, msg))
sw = SW(device)
print(path) # where Junos version is stored after downloading
try:
ok = sw.install(package=path, progress = install_progress)
except Exception as err:
print("Install error")
print("err")
If ok is True:
print("Software installation complete, rebooting ...")
sw.reboot()
The case is if I download Junos version in my program, this codes with end up with error and quit, output is like these:
Downloading now, please don't click anything
it'll automatically move on once it's done
https://..../software/junos/12.1X46-D35.1/junos-srxsme-12.1X46-D35.1-domestic.tgz....
junos/junos-srxsme-12.1X46-D35.1-domestic.tgz
Install error
proper value either package or pkg_set is missing
Traceback (most recent call last):
line 189, in junos_auto_install
if ok is True:
UnboundLocalError: local variable 'ok' referenced before assignment
If I run my exact same scripts with a downloaded Junos version beforehand (program will do the local storage check), it will run pretty smoothly, like these:
Found local proper installation package
junos/junos-srxsme-12.1X46-D35.1-domestic.tgz
xx.xx.xx.xx:computing local checksum on: junos/junos-srxsme-12.1X46-D35.1-domestic.tgz
xx.xx.xx.xx:cleaning filesystem ...
junos-srxsme-12.1X46-D35.1-domestic.tgz: 14761984 / 147584680 (10%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 29523968 / 147584680 (20%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 44285952 / 147584680 (30%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 59047936 / 147584680 (40%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 73793536 / 147584680 (50%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 88555520 / 147584680 (60%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 103317504 / 147584680 (70%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 118079488 / 147584680 (80%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 132841472 / 147584680 (90%)
xx.xx.xx.xx:junos-srxsme-12.1X46-D35.1-domestic.tgz: 147584680 / 147584680 (100%)
...
So any ideas or comments on how this can be improved? Or this is a bug that haven't been covered yet?
Best,
Michelle