ZenPacks, JSON API, and Integrations

Expand all | Collapse all

Zenoss 4.2.5 - install extra libraries for use in a zenpack

  • 1.  Zenoss 4.2.5 - install extra libraries for use in a zenpack

    Posted 02-22-2019 09:14 AM
    I'm attempting to add some code to a zenpack that will allow me to use some decryption on some config values read out from a file.

    The code we're using to do this uses the python cryptography library.

    I can get this working as root user on my zenoss 4.2.5 centos box by installing the library via pip in some standalone python scripts with code like this.
    from cryptography.fernet import Fernet
    f = Fernet(encryptionKey)
    unencryptedvalue = f.decrypt(encryptedvalue)

    but i'm struggling to get it to work once i add it as part of my zenpack code.
    I get errors that the module cryptography.fernet cannot be import - i.e. it can't see my packages.

    I'm not sure if the issue is when i installed as root the libraries end up in the out of the box python26 area but zenoss is actually using the /opt/zenoss/lib/python and python2.7 area to pick up its packages.

    I did do some experimenting with various attempts to install the packages (cryptography pulls in some dependencies - six, idna, pyasn1, enum34, ipaddress, pycparser, cffi) in the python27 area as the zenoss user via either manually running the setup.py files for each packages or running a pip explicitly using the /opt/zenoss/bin/python like this:
    /opt/zenoss/bin/python -m pip install cryptography

    but doing this seems to get me in a mess each time with zenoss itself starting to throw problems up when i restart the daemons. (Fixed by reverting to my pre install attempt snapshot of the VM)

    So i'm not quite sure how i'm supposed to install the libraries so that they work with the zenpack and not break zenoss in the process!
    The six library seems to cause issues as there now seem to be vaiours versions of it spread across various directories...

    Could i solve this by adding the libraries directly to my zenpack so that only that zenpack code uses them? (similar to the advice in this thread - How to add required Python module to ZenPack)

    Any advice appreciated



  • 2.  RE: Zenoss 4.2.5 - install extra libraries for use in a zenpack

    Posted 03-14-2019 09:42 AM
    I have certainly had success with the link that you quoted.  You will need to add all the packages that you need, including any pre-reqs / co-reqs.

    Jane Curry
    Skills 1st United Kingdom

  • 3.  RE: Zenoss 4.2.5 - install extra libraries for use in a zenpack

    Posted 03-20-2019 05:22 AM
    I gave the 'include libraries in the zenpack' a go but did not quite get it working as still ran into some issues where code was pulling in the wrong version of things, mostly the six.py stuff.

    Eventually rewoked the code to use a different encryption library and found a cleaner solution that needed less dependencies/ dependencies that did not interfer with the existing zenoss code (essentially using pycryptodome library instead of cryptography)

    Pheripheral Pheripheral

  • 4.  RE: Zenoss 4.2.5 - install extra libraries for use in a zenpack

    Posted 04-03-2019 07:23 AM
    I always add my libs to my ZenPack under a directory lib, then import that copy. Then I never have to worry about the lib being installed or not, everything needed is contained in the ZenPack.

    For example, if I needed python requests, I would snag the repo and then add it to ZenPacks.jstanley.MyZenPack/ZenPacks/jstanley/MyZenPack/lib