Skip to content

Uninett/telemator-NAV-integrasjon

Repository files navigation

nav-telemator

Contribution for Telemator additions in NAV

User-visible changes

New url <nav-url>/telemator

A new page is available at <nav-url>/telemator. The page contains a summary of registered Circuits and Customers.

New url <nav-url>/telemator/circuits

Presents a list of registered circuits

New url <nav-url>/telemator/circuits/<circuitid>

Show details about a given circuit

New url <nav-url>/telemator/cables/<cableid>

Show details about a given cable

New url <nav-url>/telemator/customers/

Presents a list of customers

New url <nav-url>/telemator/customers/<customerid>

Shows details about a given customer

New url <nav-url>/telemator/api/

Shows a list of API endpoints

New url <nav-url>/telemator/api/1.0/customer_circuits/<customerid>

REST API endpoint for all circuits for a given customer

New url <nav-url>telemator/owners/<ownerid>

Shows details about an owner a list of cables owned

Setting up development environment

Checkout a suitable NAV version

cd /local/src
git clone https://github.com/UNINETT/nav.git
cd nav
git checkout 4.9.x

Prepare the NAV source

For ease of development, we mount our current directory inside the NAV container. This is done by altering docker-compose.yml. Our current directory will then be available inside the container at ~/tmsource.

cd ~/src/telemator-NAV-integrasjon
pip install pyyaml
./fix-nav-docker.py /local/src/nav

Start NAV docker containers

Make sure access to docker is granted to your user, typically by adding yourselv to the docker group.

( cd /local/src/nav; docker-compose up )

Install ourselves into the NAV container

The ansible playbooks below will

  • install necessary packages (via apt and pip)
  • append ~/tmsource to pythons load path (by altering /etc/python2.7/sitecustomize.py)
  • generate the file /etc/nav/local_settings.py
cd ~/src/telemator-NAV-integrasjon
ansible-playbook ansible/install-roles.yml
ansible-playbook -i nav_nav_1, ansible/ansible-prepare.yml

Edit /etc/nav/local_settings.py

The database password for the Telemator database must be added to /etc/nav/local_settings.py

Installing for production

Note: The beginnings of a deploy script exists: deploy.sh

The following files needs to be added.

  • /etc/nav/python/local_settings.py
LOCAL_SETTINGS = True
from nav.django.settings import *

TEMPLATE_LOADERS = (
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.filesystem.Loader'
)

INSTALLED_APPS += (
    'navtelemator',
)
    
# Telemator search providers
SEARCHPROVIDERS += (
    'navtelemator.search.CableSearchProvider',
    'navtelemator.search.CircuitSearchProvider',
    'navtelemator.search.OwnerSearchProvider',
)

### Telemator Config ###
# Server to connect to
TM_HOST = ''
# Port number
TM_PORT = '1433'

# Username
TM_USER = ''
# Password
TM_PASSWORD = ''

# Name of database to use
TM_DBNAME = ''
  • /etc/nav/python/local_urls.py
from django.conf.urls import url, patterns, include
import navtelemator
urlpatterns = patterns(
    '',
    (r'^telemator/', include('navtelemator.urls')),
)

Build

apt-get install python-dev freetds-dev
python ./setup.py build sdist

Install

pip install dist/*

Remember to update the version number, or else pip will not do anything. You can also do

pip -v install --upgrade dist/*

to force the upgrade, but this will also upgrade dependencies already installed.

Uninstall

pip uninstall nav-contrib-telemator

Hacks

Because I couldn’t get local-files working, I instead added the values to their respective file.

The url include is added on the end of the list with the other includes, and navtelemator was added at the START of the installed apps (it caused a problem when added at the end). Propably because they are loaded in order.

Comparing databases

Every once in a while, the Telemator database will have updates. This may bring changes to the database schema. Currently, the database version is hardcoded into the program, and anything different from the hardcoded version will result in a red error message on all pages in /telemator. The database version is in the Settings table under Version::DBFversion.

When there is a new update to the schematics, a script found in navtelemator/misc/database_comparator.py will allow you to see the differences in the schema. Note that this should only be used for doing manual changes to models.py. A url to both the previous database and the new database is required. An HTML file will be produced to easily show differences.

About

Integration of Telemator and NAV

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •