Contribution for Telemator additions in NAV
A new page is available at <nav-url>/telemator. The page contains a summary of registered Circuits and Customers.
Presents a list of registered circuits
Show details about a given circuit
Show details about a given cable
Presents a list of customers
Shows details about a given customer
Shows a list of API endpoints
REST API endpoint for all circuits for a given customer
Shows details about an owner a list of cables owned
cd /local/src
git clone https://github.com/UNINETT/nav.git
cd nav
git checkout 4.9.x
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
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 )
The ansible playbooks below will
- install necessary packages (via
apt
andpip
) - 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
The database password for the Telemator database must be added to /etc/nav/local_settings.py
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')),
)
apt-get install python-dev freetds-dev
python ./setup.py build sdist
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.
pip uninstall nav-contrib-telemator
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.
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.