TECHZEN Zenoss User Community ARCHIVE  

Zenoss Core 6.3.2 ZenPack install with service and external dependency

Subject: Zenoss Core 6.3.2 ZenPack install with service and external dependency
Author: Matt
Posted: 2020-07-16 14:23

Hello,

I am trying to install a ZenPack, which I have developed myself, in Zenoss Core 6.3.2. I have last used the ZenPack in Zenoss Core 5. My ZenPack includes a custom service and this service depends on a python module. The python module is located in the lib folder of my ZenPack as an egg file. I have also added the following to the install script of my ZenPack:
libDir = os.path.join(os.path.dirname(__file__), 'lib')
if os.path.isdir(libDir):
    for file in os.listdir(libDir):
        if file.endswith('.egg'):
            sys.path.append(os.path.join(libDir, file))​

Unfortunately, the ZenPack install fails because the python module needed by the service is missing. I have already tried to manually install the module in the zope and zenhub containers. The installation still fails. How do I install the python module during the deployment of the ZenPack? Or, alternatively, which docker container do I have to manually modify to satisfy the dependency? Considering that the service will run in its own container, I might not be able to modify the container before the ZenPack is installed...

Any help would be greatly appreciated!


Subject: RE: Zenoss Core 6.3.2 ZenPack install with service and external dependency
Author: Laurent Hemeryck
Posted: 2022-02-18 02:10

Hello Matt, 

You don't have to "install" the library. Just see the ZenPack as its own environment. You can copy the library within the lib folder. 
When you need to call this library from one of your Python modules, just import it as this:

from ZenPacks.community.MyZenPack.lib.mylibrary import myfunction
​


You can find an example here: 
https://github.com/Hemie143/ZenPacks.community.ActiveMQ

Cheers, 

Laurent



------------------------------
Laurent Hemeryck
Monitoring Engineer
FedNot
------------------------------


< Previous
How can I graph data from an external source
  Next
Qnap NAS - SNMP monitoring disk status
>