diff --git a/.gitignore b/.gitignore index e767b82..87c655c 100644 --- a/.gitignore +++ b/.gitignore @@ -168,3 +168,5 @@ db.sqlite3 /network_inventory/lib64 /network_inventory/inventory/migrations .vagrant/ + +.vscode/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..96050e2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3 +ENV PYTHONUNBUFFERED 1 +ADD . /code +WORKDIR /code +RUN pip install wheel +RUN pip install -r requirements.txt +WORKDIR /code/network_inventory diff --git a/README.md b/README.md new file mode 100644 index 0000000..db81a53 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# network_inventory + +I started this project in order to have solution for keeping an +inventory over my various servers and other network equipment. + +## Setup + +1. Clone the repository +2. Run `./setup.sh` to setup the docker container. +3. Run `docker-compose up` to start the development server. You can access it at + http://localhost:8000 . You're now all set to start developing. + +If you need to run migrations you can create and apply them with the following +two commands. +``` +docker-compose run web python manage.py makemigrations inventory +docker-compose run web python manage.py migrate +``` + +## Todos +- [ ] Create an Apache configuration +- [ ] configure htaccess or something similar +- [ ] extend the CSS + - A more centered layout would be nice + - Maybe some colours +- [ ] include a RAID calculator + - + I would like to use this to show the usable space in a RAID system. +- [ ] calculate the used space on a host + Means calculate the size all the VMs would use if they were thick. +- [ ] Move the lists to their own page. Since I have more devices than I thought it would provide a better + overview than one big list. +- [ ] Add a Counter to the RAM Modules +- [ ] Create an abstract company class +- [ ] Create Customer and a Manufacturer sub class + Those two would be based on the company class. I'm currently not sure + how I should handle the case where a company is both a customer and a + manufacturer. +- [ ] Create a NET category where a device can live in. + This NET Category should display it's IP range, Subnet mask and show + it's DHCP range if one is configured. +- [ ] Create class DeviceInNet + This class shows the relationship between the device and a NET. An + attribute of a DeviceInNet should be an IP address. +- [ ] Recreate the RM in draw.io + The Dia RM is okay but not really that great. Draw.io would give a + better result. + +## Developemenet + +For a detailed documentation of the source have a look at the +[documentation](https://git.2li.ch/Nebucatnetzer/network_inventory/src/branch/master/docs/docs.org). \ No newline at end of file diff --git a/README.org b/README.org deleted file mode 100644 index 60e2b1d..0000000 --- a/README.org +++ /dev/null @@ -1,94 +0,0 @@ -* network_inventory - -I started this project in order to have solution for keeping an -inventory over my various servers and other network equipment. - -** Setup - -1. Clone the repository -2. Create a virtual environment inside of the repository for example - with: - -#+BEGIN_EXAMPLE -python3 -m venv /path/to/repository -#+END_EXAMPLE - -3. Cd into the repository and execute the setup.sh script. It will do - some clean up tasks, install some python dependencies into the - virtual environment, setup the database and a default user with the - login ~admin~ and the password ~password~. -4. Afterwards you can run: - -#+BEGIN_EXAMPLE -./manage.py runserver -#+END_EXAMPLE - - In order to run the developmenent server and access the application - at http://localhost:8000 - -** Todos - -*** TODO Setup an Ansible role - -**** NEXT Create an Apache configuration - -**** CANCELED move the database to mariadb -CLOSED: [2017-12-28 Thu 16:15] - -- I had massive problems with mysqlclient and python3.5 and therefore - dropped this. SQLite seems to work reasonably well. - -**** NEXT setup a server - -**** NEXT configure htaccess or something similar - -*** NEXT extend the CSS - -- A more centered layout would be nice -- Maybe some colours - -*** NEXT include a RAID calculator - -- https://thoughtworksnc.com/2017/08/30/writing-a-raid-calculator-in-python/ - -I would like to use this to show the usable space in a RAID system. - -*** NEXT calculate the used space on a host - -Means calculate the size all the VMs would use if they were thick. - -*** NEXT Move the lists to their own page - -- Since I have more devices than I thought it would provide a better - overview than one big list. - -*** NEXT Add a Counter to the RAM Modules - -*** NEXT Create an abstract company class - -*** NEXT Create Customer and a Manufacturer sub class - -Those two would be based on the company class. I'm currently not sure -how I should handle the case where a company is both a customer and a -manufacturer. - -*** NEXT Create a NET category where a device can live in. - -This NET Category should display it's IP range, Subnet mask and show -it's DHCP range if one is configured. - -*** NEXT Create class DeviceInNet - -This class shows the relationship between the device and a NET. An -attribute of a DeviceInNet should be an IP address. - -*** NEXT Recreate the RM in draw.io - -The Dia RM is okay but not really that great. Draw.io would give a -better result. - -** Developemenet - -For a detailed documentation of the source have a look at the -[[https://git.2li.ch/Nebucatnetzer/network_inventory/src/branch/master/docs/docs.org][documentation]]. - diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..377aef6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3' + +volumes: + db_data: + +services: + db: + image: postgres + environment: + - POSTGRES_DB=network_inventory + volumes: + - db_data:/var/lib/postgresql/data/ + + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - .:/code + ports: + - "8000:8000" + depends_on: + - db diff --git a/network_inventory/network_inventory/settings.py b/network_inventory/network_inventory/settings.py index a62d7dc..cc0de7e 100644 --- a/network_inventory/network_inventory/settings.py +++ b/network_inventory/network_inventory/settings.py @@ -77,8 +77,11 @@ WSGI_APPLICATION = 'network_inventory.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'postgres', + 'USER': 'postgres', + 'HOST': 'db', # set in docker-compose.yml + 'PORT': 5432 # default postgres port } } diff --git a/requirements.txt b/requirements.txt index 1037498..fe62381 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ +wheel Django==2.0 -wheel==0.30.0 -pyaml==17.12.1 -pytz==2017.3 -PyYAML==3.12 +pyaml +pytz +psycopg2 diff --git a/setup.sh b/setup.sh index 7f4293f..48a66a3 100755 --- a/setup.sh +++ b/setup.sh @@ -1,11 +1,3 @@ -rm /vagrant/network_inventory/inventory/migrations/*.py -python3 -m venv /vagrant/network_inventory -source /vagrant/network_inventory/bin/activate -pip3 install -r requirements.txt -python3 /vagrant/network_inventory/manage.py makemigrations inventory -python3 /vagrant/network_inventory/manage.py migrate -echo "from django.contrib.auth.models import User; \ - User.objects.filter(email='admin@example.com').delete(); \ - User.objects.create_superuser('admin', 'admin@example.com', 'password')" | - python3 /vagrant/network_inventory/manage.py shell -python3 /vagrant/network_inventory/manage.py loaddata inventory +docker-compose run web python manage.py migrate +docker-compose run web python manage.py loaddata inventory +docker-compose run web ./manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@example.com', 'password')" \ No newline at end of file