diff --git a/.gitignore b/.gitignore index e769694ea..954607b60 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ configuration.py /*.sh !upgrade.sh fabfile.py +*.swp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f437d2516..ec5b48801 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,6 +51,10 @@ Even if it's not quite right for NetBox, we may be able to point you to a tool b ## 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. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c2e2c38ab --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +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 +ADD netbox/netbox/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py + +ENTRYPOINT [ "/docker-entrypoint.sh" ] + +ADD docker/gunicorn_config.py /opt/netbox/ +ADD docker/nginx.conf /etc/netbox-nginx/ +VOLUME ["/etc/netbox-nginx/"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..860022707 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,52 @@ +version: '2' + +services: + postgres: + image: postgres:9.6 + container_name: postgres + environment: + POSTGRES_USER: netbox + POSTGRES_PASSWORD: J5brHrAXFLQSif0K + POSTGRES_DB: netbox + netbox: + image: digitalocean/netbox + 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: + - netbox-static-files:/opt/netbox/netbox/static + nginx: + image: nginx:1.11.1-alpine + links: + - netbox + container_name: nginx + command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf + depends_on: + - netbox + ports: + - 80:80 + 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 0b42cc6d9..cc2cf5073 100644 --- a/docs/dcim.md +++ b/docs/dcim.md @@ -43,6 +43,7 @@ Each device type is assigned a number of component templates which describe the * Power port templates * Power outlet templates * Interface templates +* Device bay templates Whenever a new device is created, it is automatically assigned console, power, and interface components per the templates assigned to its device type. For example, suppose your network employs Juniper EX4300-48T switches. You would create a device type with a model name "EX4300-48T" and assign it to the manufacturer "Juniper." You might then also create the following templates for it: @@ -81,16 +82,19 @@ A device can be assigned modules which represent internal components. Currently, ### Components -There are five types of device components which comprise all of the interconnection logic with NetBox: +There are six types of device components which comprise all of the interconnection logic with NetBox: * Console ports * Console server ports * Power ports * Power outlets * Interfaces +* Device bays Console ports connect only to console server ports, and power ports connect only to power outlets. Interfaces connect to one another in a symmetric manner: If interface A connects to interface B, interface B therefore connects to interface A. (The relationship between two interfaces is actually represented in the database by an InterfaceConnection object, but this is transparent to the user.) -Each type of connection can be defined as either *planned* or *connected*. This allows for easily denoting connections which have not yet been installed. +Each type of connection can be classified as either *planned* or *connected*. This allows for easily denoting connections which have not yet been installed. In addition to a connecting peer, interfaces are also assigned a form factor and may be designated as management-only (for out-of-band management). Interfaces may also be assigned a short description. -In addition to a connecting peer, interfaces are also assigned a form factor and may be designated as management-only (for out-of-band management). Interfaces may also be assigned a short description. +Device bays represent the ability of a device to house child devices. For example, you might install four blade servers into a 2U chassis. The chassis would appear in the rack elevation as a 2U device with four device bays. Each server within it would be defined as a 0U device installed in one of the device bays. Child devices do not appear on rack elevations, but they are included in the "Non-Racked Devices" list within the rack view. + +Note that child devices differ from modules in that they are still treated as independent devices, with their own console/power/data components, modules, and IP addresses. Modules, on the other hand, are parts within a device, such as a hard disk or power supply. 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 @@ +
Are you sure you want to delete these components from {{ devicetype }}?
diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 9d9da6a18..3f03fcee9 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -29,7 +29,12 @@No device bays defined | +
Are you sure you want to delete this device bay from {{ devicebay.device }}?
+{% endblock %} diff --git a/netbox/templates/dcim/devicebay_depopulate.html b/netbox/templates/dcim/devicebay_depopulate.html new file mode 100644 index 000000000..e8a3c344d --- /dev/null +++ b/netbox/templates/dcim/devicebay_depopulate.html @@ -0,0 +1,8 @@ +{% extends 'utilities/confirmation_form.html' %} +{% load form_helpers %} + +{% block title %}Remove {{ device_bay.installed_device }} from {{ device_bay }}?{% endblock %} + +{% block message %} +Are you sure you want to remove {{ device_bay.installed_device }} from {{ device_bay }}?
+{% endblock %} diff --git a/netbox/templates/dcim/devicebay_edit.html b/netbox/templates/dcim/devicebay_edit.html new file mode 100644 index 000000000..507cf0eaf --- /dev/null +++ b/netbox/templates/dcim/devicebay_edit.html @@ -0,0 +1,51 @@ +{% extends '_base.html' %} +{% load form_helpers %} + +{% block title %}{% if devicebay.pk %}Editing {{ devicebay.device }} {{ devicebay }}{% else %}Add a Device Bay ({{ device }}){% endif %}{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/netbox/templates/dcim/devicebay_populate.html b/netbox/templates/dcim/devicebay_populate.html new file mode 100644 index 000000000..a9d84c5e7 --- /dev/null +++ b/netbox/templates/dcim/devicebay_populate.html @@ -0,0 +1,46 @@ +{% extends '_base.html' %} +{% load form_helpers %} + +{% block title %}Populate {{ device_bay }}{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html index 4510e6e43..79246046c 100644 --- a/netbox/templates/dcim/devicetype.html +++ b/netbox/templates/dcim/devicetype.html @@ -14,23 +14,27 @@ -{% if perms.dcim.change_devicetype %} + +{% if perms.dcim.change_devicetype or perms.dcim.delete_devicetype %}Name | +Role | +Type | +Parent | +
---|---|---|---|
@@ -119,6 +125,7 @@ | {{ device.device_role }} | {{ device.device_type }} | +{% if device.parent_bay %}{{ device.parent_bay }}{% endif %} |