Common install script and file structure for 3rd party NAV tools

Registered by Ole Martin Bjørndalen

At UiT, we have developed a number of custom NAV tools. They can be tricky to install, so I have written libinst.py, which discovers everything it needs to know from inspecting nav, so all you have to do is type "./install.py".

I propose this as a standard module in NAV. This way you could just set up the standard file structure, and write a small install.py like this (a real example from our DHCP module):

    from nav.uit.toolinst import install_tool

    install_tool(
        name='dhcp',
        title='DHCP',
        description='Add MAC-address to DHCP-service.')

The installer will discover and install all necessary files, as long as the package follows this structure (again using dhcp as an example):

    bin/ (all executable scripts here will be installed in NAVPREFIX/bin/
    src/ (contains urls.py, views.py and other code. If models.py is not found, an empty file will be installed instead.)
    images/dhcp.png (will be used as the tool's icon in the toolbox)
    templates/*.html

The tool file will be created, preserving the current priority in the toolbox if the tool file is already installed.

The TooInstaller can also be instantiated directly for more detailed control over the installation process. Here, the installer is used to expand a NAV variable to get the destination directory for a file copy:

    from nav.uit.toolinst import Installer

    inst = Installer(
        name='xymon',
        title='Xymon',
        description='Monitors servers, applications and networks.')
    inst.install()

    # Copy apache config. (Can't generate this, since it's not a Python
    # tool.)
    shutil.copy('xymon.conf', inst.exp('$sysconfdir/apache/subsystems/'))

Toolinst will not create the db schema or install config files.

The current implementation can be seen here:

    https://heimdal.uit.no/hg/navuitbase/file/tip/lib/uit/toolinst.py

Examples of use:

   https://heimdal.uit.no/hg/dhcp/file/tip/install.py
   https://heimdal.uit.no/hg/portkart/file/tip/install.py
   https://heimdal.uit.no/hg/xymon/file/tip/install.py
   https://heimdal.uit.no/hg/xymon/file/tip/install.py

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
Ole Martin Bjørndalen
Direction:
Needs approval
Assignee:
Ole Martin Bjørndalen
Definition:
Discussion
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.