change setup to docker
This commit is contained in:
parent
cd9253f80d
commit
adf4bdbc11
|
@ -168,3 +168,5 @@ db.sqlite3
|
|||
/network_inventory/lib64
|
||||
/network_inventory/inventory/migrations
|
||||
.vagrant/
|
||||
|
||||
.vscode/
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
- <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.
|
||||
- [ ] 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).
|
94
README.org
94
README.org
|
@ -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]].
|
||||
|
|
@ -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
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
14
setup.sh
14
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')"
|
Loading…
Reference in New Issue