diff --git a/.gitignore b/.gitignore index e8ff56275..e769694ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.pyc configuration.py .idea -*.sh +/*.sh +!upgrade.sh fabfile.py - diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..01fb25d8f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: python +python: + - "2.7" +install: + - pip install -r requirements.txt + - pip install pep8 +script: + - ./scripts/cibuild.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d5e9bd38e..ec5b48801 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,3 +48,19 @@ Even if it's not quite right for NetBox, we may be able to point you to a tool b * A use case for the feature; who would use it and what value it would add to NetBox * A rough description of any changes necessary to the database schema (if applicable) * Any third-party libraries or other resources which would be involved + +## Submitting Pull Requests + +* Be sure to open an issue before starting work on a pull request, and discuss your idea with the NetBox maintainers +before beginning work. This will help prevent wasting time on something that might we might not be able to implement. +When suggesting a new feature, also make sure it won't conflict with any work that's already in progress. + +* When submitting a pull request, please be sure to work off of branch `develop`, rather than branch `master`. +In NetBox, the `develop` branch is used for ongoing development, while `master` is used for tagging new +stable releases. + +* All code submissions should meet the following criteria (CI will enforce these checks): + + * Python syntax is valid + * All tests pass when run with `./manage.py test netbox/` + * PEP 8 compliance is enforced, with the exception that lines may be greater than 80 characters in length diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..ad73acce3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:14.04 + +RUN apt-get update && apt-get install -y \ + python2.7 \ + python-dev \ + git \ + python-pip \ + libxml2-dev \ + libxslt1-dev \ + libffi-dev \ + graphviz \ + libpq-dev \ + build-essential \ + gunicorn \ + --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir -p /opt/netbox \ + && cd /opt/netbox \ + && git clone --depth 1 https://github.com/digitalocean/netbox.git -b master . \ + && pip install -r requirements.txt \ + && apt-get purge -y --auto-remove git build-essential + +ADD docker/docker-entrypoint.sh /docker-entrypoint.sh + +ENTRYPOINT [ "/docker-entrypoint.sh" ] diff --git a/README.md b/README.md index ba736fee8..cc563c284 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,20 @@ +# NetBox + NetBox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. Initially conceived by the network engineering team at [DigitalOcean](https://www.digitalocean.com/), NetBox was developed specifically to address the needs of network and infrastructure engineers. NetBox runs as a web application atop the [Django](https://www.djangoproject.com/) Python framework with a [PostgreSQL](http://www.postgresql.org/) database. For a complete list of requirements, see `requirements.txt`. The code is available [on GitHub](https://github.com/digitalocean/netbox). +Questions? Comments? Please join us on IRC in **#netbox** on **irc.freenode.net**! + +### Build Status + +| | python 2.7 | +|-------------|------------| +| **master** | [](https://travis-ci.org/digitalocean/netbox) | +| **develop** | [](https://travis-ci.org/digitalocean/netbox) | + +## Screenshots +   @@ -12,6 +25,8 @@ NetBox runs as a web application atop the [Django](https://www.djangoproject.com Please see docs/getting-started.md for instructions on installing NetBox. +To upgrade NetBox, please download the [latest release](https://github.com/digitalocean/netbox/releases) and run `upgrade.sh`. + # Components NetBox understands all of the physical and logical building blocks that comprise network infrastructure, and the manners in which they are all related. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..e280b95ff --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,55 @@ +version: '2' + +services: + postgres: + image: postgres:9.6 + container_name: postgres + environment: + POSTGRES_USER: netbox + POSTGRES_PASSWORD: J5brHrAXFLQSif0K + POSTGRES_DB: netbox + netbox: + build: . + links: + - postgres + container_name: netbox + depends_on: + - postgres + environment: + SUPERUSER_NAME: admin + SUPERUSER_EMAIL: admin@example.com + SUPERUSER_PASSWORD: admin + ALLOWED_HOSTS: localhost + DB_NAME: netbox + DB_USER: netbox + DB_PASSWORD: J5brHrAXFLQSif0K + DB_HOST: postgres + SECRET_KEY: r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj + EMAIL_SERVER: localhost + EMAIL_PORT: 25 + EMAIL_USERNAME: foo + EMAIL_PASSWORD: bar + EMAIL_TIMEOUT: 10 + EMAIL_FROM: netbox@bar.com + NETBOX_USERNAME: guest + NETBOX_PASSWORD: guest + volumes: + - $PWD/netbox/netbox/configuration.docker.py:/opt/netbox/netbox/netbox/configuration.py:ro + - $PWD/docker/gunicorn_config.py:/opt/netbox/gunicorn_config.py:ro + - netbox-static-files:/opt/netbox/netbox/static + nginx: + image: nginx:1.11.1-alpine + links: + - netbox + container_name: nginx + depends_on: + - netbox + ports: + - 80:80 + volumes: + - $PWD/docker/nginx.conf:/etc/nginx/nginx.conf:ro + volumes_from: + - netbox +volumes: + netbox-static-files: + driver: local diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100755 index 000000000..53e52ef04 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# run db migrations (retry on error) +while ! /opt/netbox/netbox/manage.py migrate 2>&1; do + sleep 5 +done + +# create superuser silently +if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD} ]]; then + SUPERUSER_NAME='admin' + SUPERUSER_EMAIL='admin@example.com' + SUPERUSER_PASSWORD='admin' + echo "Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}" +fi +echo "from django.contrib.auth.models import User; User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')" | python /opt/netbox/netbox/manage.py shell + +# copy static files +/opt/netbox/netbox/manage.py collectstatic --no-input + +# start unicorn +gunicorn --log-level debug --debug --error-logfile /dev/stderr --log-file /dev/stdout -c /opt/netbox/gunicorn_config.py netbox.wsgi diff --git a/docker/gunicorn_config.py b/docker/gunicorn_config.py new file mode 100644 index 000000000..878841ac0 --- /dev/null +++ b/docker/gunicorn_config.py @@ -0,0 +1,5 @@ +command = '/usr/bin/gunicorn' +pythonpath = '/opt/netbox/netbox' +bind = '0.0.0.0:8001' +workers = 3 +user = 'root' diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 000000000..2a794f314 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,35 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + sendfile on; + tcp_nopush on; + keepalive_timeout 65; + gzip on; + server_tokens off; + + server { + listen 80; + + server_name localhost; + + access_log off; + + location /static/ { + alias /opt/netbox/netbox/static/; + } + + location / { + proxy_pass http://netbox:8001; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; + } + } +} diff --git a/docs/dcim.md b/docs/dcim.md index 99fc31653..0b42cc6d9 100644 --- a/docs/dcim.md +++ b/docs/dcim.md @@ -59,12 +59,12 @@ Note that assignment of components from templates occurs only at the time of dev # Devices -Every piece of hardware which is installed within a rack exists in NetBox as a device. Devices are measured in rack units (U) and whether they are full depth. 0U devices which can be installed in a rack but don't consume vertical rack space (such as a vertically-mounted power distribution unit) can also be defined. +Every piece of hardware which is installed within a rack exists in NetBox as a device. Devices are measured in rack units (U) and depth. 0U devices which can be installed in a rack but don't consume vertical rack space (such as a vertically-mounted power distribution unit) can also be defined. + +When assigning a multi-U device to a rack, it is considered to be mounted in the lowest-numbered rack unit which it occupies. For example, a 3U device which occupies U8 through U10 shows as being mounted in U8. A device is said to be "full depth" if its installation on one rack face prevents the installation of any other device on the opposite face within the same rack unit(s). This could be either because the device is physically too deep to allow a device behind it, or because the installation of an opposing device would impede air flow. -Each device has a physical device type (make and model), which is discussed below. - ### Roles NetBox allows for the definition of arbitrary device roles by which devices can be organized. For example, you might create roles for core switches, distribution switches, and access switches. In the interest of simplicity, device can only belong to one device role. diff --git a/docs/getting-started-docker.md b/docs/getting-started-docker.md new file mode 100644 index 000000000..c5de5bbf1 --- /dev/null +++ b/docs/getting-started-docker.md @@ -0,0 +1,54 @@ +
There was a problem with your request. This error has been logged and administrative staff have been notified. Please return to the home page and try again.
+If you are responsible for this installation, please consider + filing a bug report.
diff --git a/netbox/templates/_base.html b/netbox/templates/_base.html index a67d3c440..bb6d8bd8f 100644 --- a/netbox/templates/_base.html +++ b/netbox/templates/_base.html @@ -13,9 +13,16 @@