PyEz jnpr.junos.utils.sw install function

163 views
Skip to first unread message

Michelle Zhang

unread,
Nov 17, 2015, 12:03:57 PM11/17/15
to Junos Python EZ
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 

Nitin Kumar

unread,
Nov 18, 2015, 1:22:25 AM11/18/15
to Michelle Zhang, Junos Python EZ
Hi Michelle,

Can you share the script part which is being used to download the package. You can unicast me too.

Thanks
Nitin Kr

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at http://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/c4f760da-cb7e-4d8f-a230-9d635b992e7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michelle Zhang

unread,
Nov 18, 2015, 3:52:29 PM11/18/15
to Junos Python EZ, cher.ch...@gmail.com, nit...@juniper.net
Hi Nitin,

I just started to use google group and not so familiar with the functions it provided, can you tell me how to unicast you? do you mean a juniper email or something?

Best,
Michelle
Reply all
Reply to author
Forward
0 new messages