Merge pull request #3 from netbox-community/develop
pull in develop changes
This commit is contained in:
commit
28a26288c9
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
about: Create a report about a malfunction of the Docker setup
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
@ -9,39 +9,49 @@ assignees: ''
|
|||
|
||||
<!--
|
||||
|
||||
Before raising an issue here, answer the following questions for yourself, please:
|
||||
Please only raise an issue if you're certain that you've found a bug.
|
||||
Else, see these other means to get help:
|
||||
|
||||
* Did you read through the troubleshooting section? (https://github.com/netbox-community/netbox-docker/wiki/Troubleshooting)
|
||||
* Have you had a look at the rest of the wiki? (https://github.com/netbox-community/netbox-docker/wiki)
|
||||
* Have you updated to the latest version and tried again? (i.e. `git pull` and `docker-compose pull`)
|
||||
* Have you reset the project and tried again? (i.e. `docker-compose down -v`)
|
||||
* Are you confident that your problem is related to the Docker image or Docker Compose file this project provides?
|
||||
(Otherwise ask on the NetBox mailing list, please: https://groups.google.com/d/forum/netbox-discuss)
|
||||
* Have you looked through the issues already resolved?
|
||||
* See our troubleshooting section:
|
||||
https://github.com/netbox-community/netbox-docker/wiki/Troubleshooting
|
||||
* Have a look at the rest of the wiki:
|
||||
https://github.com/netbox-community/netbox-docker/wiki
|
||||
* Check the release notes:
|
||||
https://github.com/netbox-community/netbox-docker/releases
|
||||
* Look through the issues already resolved:
|
||||
https://github.com/netbox-community/netbox-docker/issues?q=is%3Aclosed
|
||||
|
||||
Please try this means to get help before opening an issue here:
|
||||
If you did not find what you're looking for,
|
||||
try the help of our community:
|
||||
|
||||
* On the networktocode Slack in the #netbox-docker channel: http://slack.networktocode.com/
|
||||
* On the networktocode Slack in the #netbox channel: http://slack.networktocode.com/
|
||||
* On the NetBox mailing list: https://groups.google.com/d/forum/netbox-discuss
|
||||
* Post to Github Discussions:
|
||||
https://github.com/netbox-community/netbox-docker/discussions
|
||||
* Join the `#netbox-docker` channel on our Slack:
|
||||
https://join.slack.com/t/netdev-community/shared_invite/zt-mtts8g0n-Sm6Wutn62q_M4OdsaIycrQ
|
||||
* Ask on the NetBox mailing list:
|
||||
https://groups.google.com/d/forum/netbox-discuss
|
||||
|
||||
Please don't open an issue when you have a PR ready. Just submit the PR, that's good enough.
|
||||
Please don't open an issue to open a PR.
|
||||
Just submit the PR, that's good enough.
|
||||
|
||||
-->
|
||||
|
||||
## Current Behavior
|
||||
|
||||
<!-- describe what you did and how it misbehaved -->
|
||||
...
|
||||
|
||||
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
<!-- describe what you expected instead -->
|
||||
...
|
||||
|
||||
|
||||
|
||||
## Debug Information
|
||||
|
||||
<!-- please fill in the following information that might helps us debug your problem more quickly -->
|
||||
<!-- please fill in the following information that helps us debug your problem more quickly -->
|
||||
|
||||
The output of `docker-compose version`: `XXXXX`
|
||||
The output of `docker version`: `XXXXX`
|
||||
The output of `git rev-parse HEAD`: `XXXXX`
|
||||
|
@ -59,7 +69,16 @@ The output of `docker inspect netboxcommunity/netbox:latest --format "{{json .Co
|
|||
|
||||
The output of `docker-compose logs netbox`:
|
||||
<!--
|
||||
If your log is very long, create a Gist instead (and post the link to it): https://gist.github.com
|
||||
If your log is very long, create a Gist instead and post the link to it: https://gist.github.com
|
||||
-->
|
||||
|
||||
```text
|
||||
LOG LOG LOG
|
||||
```
|
||||
|
||||
The output of `cat docker-compose.override.yml`:
|
||||
<!--
|
||||
If this file is very long, create a Gist instead and post the link to it: https://gist.github.com
|
||||
-->
|
||||
|
||||
```text
|
||||
|
|
|
@ -5,7 +5,7 @@ contact_links:
|
|||
about: The Github Discussions are the right place to ask questions about how to use or do certain things with NetBox Docker.
|
||||
|
||||
- name: Chat
|
||||
url: http://slack.networktocode.com/
|
||||
url: https://join.slack.com/t/netdev-community/shared_invite/zt-mtts8g0n-Sm6Wutn62q_M4OdsaIycrQ
|
||||
about: 'Usually the quickest way to seek help with small issues is to join our #netbox-docker Slack channel.'
|
||||
|
||||
- name: Community Wiki
|
||||
|
|
|
@ -9,39 +9,52 @@ assignees: ''
|
|||
|
||||
<!--
|
||||
|
||||
Before raising an issue here, answer the following questions for yourself, please:
|
||||
This issue type is to propose new features for the Docker setup.
|
||||
To just spin an idea, see the Github Discussions section, please.
|
||||
|
||||
* Did you read through the troubleshooting section? (https://github.com/netbox-community/netbox-docker/wiki/Troubleshooting)
|
||||
* Have you had a look at the rest of the wiki? (https://github.com/netbox-community/netbox-docker/wiki)
|
||||
* Have you read the release notes recently (https://github.com/netbox-community/netbox-docker/releases)
|
||||
* Are you confident that your feature/change request is related to the Docker image or Docker Compose file this project provides?
|
||||
(Otherwise ask on the NetBox mailing list, please: https://groups.google.com/d/forum/netbox-discuss)
|
||||
* Have you looked through the issues already resolved?
|
||||
Before asking for help, see these links first:
|
||||
|
||||
Please try this means to get help before opening an issue here:
|
||||
* See our troubleshooting section:
|
||||
https://github.com/netbox-community/netbox-docker/wiki/Troubleshooting
|
||||
* Have a look at the rest of the wiki:
|
||||
https://github.com/netbox-community/netbox-docker/wiki
|
||||
* Check the release notes:
|
||||
https://github.com/netbox-community/netbox-docker/releases
|
||||
* Look through the issues already resolved:
|
||||
https://github.com/netbox-community/netbox-docker/issues?q=is%3Aclosed
|
||||
|
||||
* On the networktocode Slack in the #netbox-docker channel: http://slack.networktocode.com/
|
||||
* On the networktocode Slack in the #netbox channel: http://slack.networktocode.com/
|
||||
* On the NetBox mailing list: https://groups.google.com/d/forum/netbox-discuss
|
||||
If you did not find what you're looking for,
|
||||
try the help of our community:
|
||||
|
||||
Please don't open an issue when you have a PR ready. Just submit the PR, that's good enough.
|
||||
* Post to Github Discussions:
|
||||
https://github.com/netbox-community/netbox-docker/discussions
|
||||
* Join the `#netbox-docker` channel on our Slack:
|
||||
https://join.slack.com/t/netdev-community/shared_invite/zt-mtts8g0n-Sm6Wutn62q_M4OdsaIycrQ
|
||||
* Ask on the NetBox mailing list:
|
||||
https://groups.google.com/d/forum/netbox-discuss
|
||||
|
||||
Please don't open an issue to open a PR.
|
||||
Just submit the PR, that's good enough.
|
||||
|
||||
-->
|
||||
|
||||
## Desired Behavior
|
||||
|
||||
<!-- please describe the behavior you desire -->
|
||||
...
|
||||
|
||||
|
||||
|
||||
## Contrast to Current Behavior
|
||||
|
||||
<!-- please describe how the desired behavior is different from the current behavior -->
|
||||
...
|
||||
|
||||
|
||||
|
||||
## Changes Required
|
||||
|
||||
<!-- if you can, please elaborate what changes would exactly be required -->
|
||||
...
|
||||
|
||||
|
||||
|
||||
## Discussion: Benefits and Drawbacks
|
||||
|
||||
|
@ -51,4 +64,5 @@ Please make your case here:
|
|||
- What are the drawbacks of this change? Is it backwards-compatible?
|
||||
- Anything else that you think is relevant to the discussion of this feature/change request.
|
||||
-->
|
||||
...
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ jobs:
|
|||
name: Checks syntax of our code
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v2
|
||||
- name: Lint Code Base
|
||||
uses: github/super-linter@v3
|
||||
|
|
21
README.md
21
README.md
|
@ -11,15 +11,17 @@
|
|||
Images are built using this code and are released to [Docker Hub][netbox-dockerhub] and [Quay.io][netbox-quayio] once a day.
|
||||
|
||||
Do you have any questions?
|
||||
Before opening an issue on Github, please join the [Network To Code][ntc-slack] Slack and ask for help in our [`#netbox-docker`][netbox-docker-slack] channel.
|
||||
Before opening an issue on Github,
|
||||
please join the [our Slack][netbox-docker-slack] and ask for help in the [`#netbox-docker`][netbox-docker-slack-channel] channel.
|
||||
|
||||
[github-stargazers]: https://github.com/netbox-community/netbox-docker/stargazers
|
||||
[github-release]: https://github.com/netbox-community/netbox-docker/releases
|
||||
[netbox-docker-microbadger]: https://microbadger.com/images/netboxcommunity/netbox
|
||||
[netbox-dockerhub]: https://hub.docker.com/r/netboxcommunity/netbox/
|
||||
[netbox-docker-github]: https://github.com/netbox-community/netbox-docker/
|
||||
[ntc-slack]: http://slack.networktocode.com/
|
||||
[netbox-docker-slack]: https://slack.com/app_redirect?channel=netbox-docker&team=T09LQ7E9E
|
||||
[netbox-docker-slack]: https://join.slack.com/t/netdev-community/shared_invite/zt-mtts8g0n-Sm6Wutn62q_M4OdsaIycrQ
|
||||
[netbox-docker-slack-channel]: https://netdev-community.slack.com/archives/C01P0GEVBU7
|
||||
[netbox-slack-channel]: https://netdev-community.slack.com/archives/C01P0FRSXRV
|
||||
[netbox-docker-license]: https://github.com/netbox-community/netbox-docker/blob/release/LICENSE
|
||||
[netbox-quayio]: https://quay.io/repository/netboxcommunity/netbox
|
||||
|
||||
|
@ -84,10 +86,12 @@ It covers advanced topics such as using files for secrets, deployment to Kuberne
|
|||
|
||||
## Getting Help
|
||||
|
||||
Feel free to ask questions in our [Github Community][netbox-community] or join [our Slack channel `#netbox-docker`][netbox-docker-slack] on the [Network To Code Slack][ntc-slack],
|
||||
Feel free to ask questions in our [Github Community][netbox-community]
|
||||
or [join our Slack][netbox-docker-slack] and ask [in our channel `#netbox-docker`][netbox-docker-slack-channel],
|
||||
which is free to use and where there are almost always people online that can help you in the Slack channel.
|
||||
|
||||
If you need help with using NetBox or developing for it or against it's API you may find the `#netbox` channel on the same Slack instance very helpful.
|
||||
If you need help with using NetBox or developing for it or against it's API
|
||||
you may find [the `#netbox` channel][netbox-slack-channel] on the same Slack instance very helpful.
|
||||
|
||||
[netbox-community]: https://github.com/netbox-community/netbox-docker/discussions
|
||||
|
||||
|
@ -130,8 +134,7 @@ It runs NetBox's own unit tests and ensures that all initializers work:
|
|||
IMAGE=netboxcommunity/netbox:latest ./test.sh
|
||||
```
|
||||
|
||||
## About
|
||||
## Support
|
||||
|
||||
This repository is currently maintained and funded by [nxt][nxt].
|
||||
|
||||
[nxt]: https://nxt.engineering/en/
|
||||
This repository is currently maintained by the community.
|
||||
Please consider sponsoring the maintainers of this project.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
version: '3.4'
|
||||
services:
|
||||
netbox:
|
||||
ports:
|
||||
- 8000:8080
|
|
@ -16,8 +16,6 @@ services:
|
|||
- ./reports:/etc/netbox/reports:z,ro
|
||||
- ./scripts:/etc/netbox/scripts:z,ro
|
||||
- netbox-media-files:/opt/netbox/netbox/media:z
|
||||
ports:
|
||||
- "8080"
|
||||
netbox-worker:
|
||||
<<: *netbox
|
||||
depends_on:
|
||||
|
|
|
@ -68,6 +68,4 @@ echo "✅ Initialisation is done."
|
|||
|
||||
# Launch whatever is passed by docker
|
||||
# (i.e. the RUN instruction in the Dockerfile)
|
||||
#
|
||||
# shellcheck disable=SC2068
|
||||
exec $@
|
||||
exec "$@"
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
## Examples:
|
||||
|
||||
# - name: link_to_repo
|
||||
# text: 'Link to Netbox Docker'
|
||||
# url: 'https://github.com/netbox-community/netbox-docker'
|
||||
# link_text: 'Link to Netbox Docker'
|
||||
# link_url: 'https://github.com/netbox-community/netbox-docker'
|
||||
# new_window: False
|
||||
# content_type: device
|
||||
# - name: link_to_localhost
|
||||
# text: 'Link to localhost'
|
||||
# url: 'http://localhost'
|
||||
# link_text: 'Link to localhost'
|
||||
# link_url: 'http://localhost'
|
||||
# new_window: True
|
||||
# content_type: device
|
||||
|
|
|
@ -42,3 +42,12 @@
|
|||
# position: 3
|
||||
# custom_field_data:
|
||||
# text_field: Description
|
||||
# - name: server04
|
||||
# device_role: server
|
||||
# device_type: Other
|
||||
# site: SING 1
|
||||
# location: cage 101
|
||||
# face: front
|
||||
# position: 3
|
||||
# custom_field_data:
|
||||
# text_field: Description
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
# site: AMS 1
|
||||
# - name: power panel SING 1
|
||||
# site: SING 1
|
||||
# rack_group: cage 101
|
||||
# location: cage 101
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
# text_field: Description
|
||||
# - site: SING 1
|
||||
# name: rack-03
|
||||
# group: cage 101
|
||||
# location: cage 101
|
||||
# role: Role 3
|
||||
# type: 4-post-cabinet
|
||||
# width: 19
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
# - name: VLAN group 1
|
||||
# site: AMS 1
|
||||
# scope_type: dcim.region
|
||||
# scope: Amsterdam
|
||||
# slug: vlan-group-1
|
||||
# - name: VLAN group 2
|
||||
# site: AMS 1
|
||||
# scope_type: dcim.site
|
||||
# scope: AMS 1
|
||||
# slug: vlan-group-2
|
||||
# - name: VLAN group 3
|
||||
# scope_type: dcim.location
|
||||
# scope: cage 101
|
||||
# slug: vlan-group-3
|
||||
# - name: VLAN group 4
|
||||
# scope_type: dcim.rack
|
||||
# scope: rack-01
|
||||
# slug: vlan-group-4
|
||||
# - name: VLAN group 5
|
||||
# scope_type: virtualization.cluster
|
||||
# scope: cluster1
|
||||
# slug: vlan-group-5
|
||||
# - name: VLAN group 6
|
||||
# scope_type: virtualization.clustergroup
|
||||
# scope: Group 1
|
||||
# slug: vlan-group-6
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
#!/bin/bash
|
||||
|
||||
DEFAULT_REPO=netbox-community/netbox-docker
|
||||
REPO="${REPO-${DEFAULT_REPO}}"
|
||||
|
||||
echomoji() {
|
||||
EMOJI=${1}
|
||||
TEXT=${2}
|
||||
shift 2
|
||||
if [ -z "$DISABLE_EMOJI" ]; then
|
||||
echo "${EMOJI}" "${@}"
|
||||
else
|
||||
echo "${TEXT}" "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
echo_nok() {
|
||||
echomoji "❌" "!" "${@}"
|
||||
}
|
||||
echo_ok() {
|
||||
echomoji "✅" "-" "${@}"
|
||||
}
|
||||
echo_hint() {
|
||||
echomoji "👉" ">" "${@}"
|
||||
}
|
||||
|
||||
# check errors shall exit with code 1
|
||||
|
||||
check_clean_repo() {
|
||||
changes=$(git status --porcelain 2>/dev/null)
|
||||
if [ ${?} ] && [ -n "$changes" ]; then
|
||||
echo_nok "There are git changes pending:"
|
||||
echo "$changes"
|
||||
echo_hint "Please clean the repository before continueing: git stash --include-untracked"
|
||||
exit 1
|
||||
fi
|
||||
echo_ok "Repository has no pending changes."
|
||||
}
|
||||
|
||||
check_branch() {
|
||||
expected_branch="${1}"
|
||||
actual_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||
if [ ${?} ] && [ "${actual_branch}" != "${expected_branch}" ]; then
|
||||
echo_nok "Current branch should be '${expected_branch}', but is '${actual_branch}'."
|
||||
echo_hint "Please change to the '${expected_branch}' branch: git checkout ${expected_branch}"
|
||||
exit 1
|
||||
fi
|
||||
echo_ok "The current branch is '${actual_branch}'."
|
||||
}
|
||||
|
||||
check_upstream() {
|
||||
expected_upstream_branch="origin/${1}"
|
||||
actual_upstream_branch=$(git rev-parse --abbrev-ref '@{upstream}' 2>/dev/null)
|
||||
if [ ${?} ] && [ "${actual_upstream_branch}" != "${expected_upstream_branch}" ]; then
|
||||
echo_nok "Current upstream branch should be '${expected_upstream_branch}', but is '${actual_upstream_branch}'."
|
||||
echo_hint "Please set '${expected_upstream_branch}' as the upstream branch: git branch --set-upstream-to=${expected_upstream_branch}"
|
||||
exit 1
|
||||
fi
|
||||
echo_ok "The current upstream branch is '${actual_upstream_branch}'."
|
||||
}
|
||||
|
||||
check_origin() {
|
||||
expected_origin="git@github.com:${REPO}.git"
|
||||
actual_origin=$(git remote get-url origin 2>/dev/null)
|
||||
if [ ${?} ] && [ "${actual_origin}" != "${expected_origin}" ]; then
|
||||
echo_nok "The url of origin is '${actual_origin}', but '${expected_origin}' is expected."
|
||||
echo_hint "Please set '${expected_origin}' as the url for origin: git origin set-url '${expected_origin}'"
|
||||
exit 1
|
||||
fi
|
||||
echo_ok "The current origin url is '${actual_origin}'."
|
||||
}
|
||||
|
||||
check_latest() {
|
||||
git fetch --tags origin
|
||||
|
||||
local_head_commit=$(git rev-parse HEAD 2>/dev/null)
|
||||
remote_head_commit=$(git rev-parse FETCH_HEAD 2>/dev/null)
|
||||
if [ "${local_head_commit}" != "${remote_head_commit}" ]; then
|
||||
echo_nok "HEAD is at '${local_head_commit}', but FETCH_HEAD is at '${remote_head_commit}'."
|
||||
echo_hint "Please ensure that you have pushed and pulled all the latest chanegs: git pull --prune --rebase origin; git push origin"
|
||||
exit 1
|
||||
fi
|
||||
echo_ok "HEAD and FETCH_HEAD both point to '${local_head_commit}'."
|
||||
}
|
||||
|
||||
check_tag() {
|
||||
local tag
|
||||
|
||||
tag=$(<VERSION)
|
||||
if git rev-parse "${tag}" 2>/dev/null >/dev/null; then
|
||||
echo_nok "The tag '${tag}' already points to '$(git rev-parse "${tag}" 2>/dev/null)'."
|
||||
echo_hint "Please ensure that the 'VERSION' file has been updated before trying to release: echo X.Y.Z > VERSION"
|
||||
exit 1
|
||||
fi
|
||||
echo_ok "The tag '${tag}' does not exist yet."
|
||||
}
|
||||
|
||||
check_develop() {
|
||||
echomoji 📋 "?" "Checking 'develop' branch"
|
||||
|
||||
check_branch develop
|
||||
check_upstream develop
|
||||
check_clean_repo
|
||||
check_latest
|
||||
}
|
||||
|
||||
check_release() {
|
||||
echomoji 📋 "?" "Checking 'release' branch"
|
||||
|
||||
check_upstream release
|
||||
check_clean_repo
|
||||
check_latest
|
||||
}
|
||||
|
||||
# git errors shall exit with code 2
|
||||
|
||||
git_switch() {
|
||||
echomoji 🔀 "≈" "Switching to '${1}' branch…"
|
||||
if ! git checkout "${1}" >/dev/null; then
|
||||
echo_nok "It was not possible to switch to the branch '${1}'."
|
||||
exit 2
|
||||
fi
|
||||
echo_ok "The branch is now '${1}'."
|
||||
}
|
||||
|
||||
git_tag() {
|
||||
echomoji 🏷 "X" "Tagging version '${1}'…"
|
||||
if ! git tag "${1}"; then
|
||||
echo_nok "The tag '${1}' was not created because of an error."
|
||||
exit 2
|
||||
fi
|
||||
echo_ok "The tag '$(<VERSION)' was created."
|
||||
}
|
||||
|
||||
git_push() {
|
||||
echomoji ⏩ "»" "Pushing the tag '${2}' to '${1}'…"
|
||||
if ! git push "${1}" "${2}"; then
|
||||
echo_nok "The tag '${2}' could not be pushed to '${1}'."
|
||||
exit 2
|
||||
fi
|
||||
echo_ok "The tag '${2}' was pushed."
|
||||
}
|
||||
|
||||
git_merge() {
|
||||
echomoji ⏩ "»" "Merging '${1}'…"
|
||||
if ! git merge --no-ff "${1}"; then
|
||||
echo_nok "The branch '${1}' could not be merged."
|
||||
exit 2
|
||||
fi
|
||||
echo_ok "The branch '${2}' was merged."
|
||||
}
|
||||
|
||||
git_merge() {
|
||||
echomoji ⏩ "»" "Rebasing onto '${1}'…"
|
||||
if ! git rebase "${1}"; then
|
||||
echo_nok "Could not rebase onto '${1}'."
|
||||
exit 2
|
||||
fi
|
||||
echo_ok "Rebased onto '${2}'."
|
||||
}
|
||||
|
||||
###
|
||||
# MAIN
|
||||
###
|
||||
|
||||
echomoji 📋 "▶︎" "Checking pre-requisites for releasing '$(<VERSION)'"
|
||||
|
||||
check_origin
|
||||
|
||||
check_develop
|
||||
check_tag
|
||||
|
||||
git_switch release
|
||||
check_release
|
||||
|
||||
echomoji 📋 "▶︎" "Releasing '$(<VERSION)'"
|
||||
|
||||
git_merge develop
|
||||
check_tag
|
||||
git_tag "$(<VERSION)"
|
||||
|
||||
git_push "origin" release
|
||||
git_push "origin" "$(<VERSION)"
|
||||
|
||||
git_switch develop
|
||||
git_rebase release
|
||||
|
||||
echomoji ✅ "◼︎" "The release of '$(<VERSION)' is complete."
|
|
@ -1,4 +1,4 @@
|
|||
napalm==3.2.0
|
||||
ruamel.yaml==0.16.12
|
||||
ruamel.yaml==0.17.4
|
||||
django-auth-ldap==2.3.0
|
||||
django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import sys
|
||||
|
||||
from dcim.models import RackGroup, Site
|
||||
from dcim.models import Location, Site
|
||||
from startup_script_utils import load_yaml
|
||||
|
||||
rack_groups = load_yaml("/opt/netbox/initializers/rack_groups.yml")
|
||||
rack_groups = load_yaml("/opt/netbox/initializers/locations.yml")
|
||||
|
||||
if rack_groups is None:
|
||||
sys.exit()
|
||||
|
@ -17,7 +17,7 @@ for params in rack_groups:
|
|||
query = {field: params.pop(assoc)}
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
rack_group, created = RackGroup.objects.get_or_create(**params)
|
||||
location, created = Location.objects.get_or_create(**params)
|
||||
|
||||
if created:
|
||||
print("🎨 Created rack group", rack_group.name)
|
||||
print("🎨 Created location", location.name)
|
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
|
||||
from dcim.models import Rack, RackGroup, RackRole, Site
|
||||
from dcim.models import Location, Rack, RackRole, Site
|
||||
from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
|
||||
from tenancy.models import Tenant
|
||||
|
||||
|
@ -14,7 +14,7 @@ required_assocs = {"site": (Site, "name")}
|
|||
optional_assocs = {
|
||||
"role": (RackRole, "name"),
|
||||
"tenant": (Tenant, "name"),
|
||||
"group": (RackGroup, "name"),
|
||||
"location": (Location, "name"),
|
||||
}
|
||||
|
||||
for params in racks:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Platform, Rack, Site
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Location, Platform, Rack, Site
|
||||
from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
|
||||
from tenancy.models import Tenant
|
||||
from virtualization.models import Cluster
|
||||
|
@ -21,6 +21,7 @@ optional_assocs = {
|
|||
"platform": (Platform, "name"),
|
||||
"rack": (Rack, "name"),
|
||||
"cluster": (Cluster, "name"),
|
||||
"location": (Location, "name"),
|
||||
}
|
||||
|
||||
for params in devices:
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
import sys
|
||||
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Platform, Rack, Site
|
||||
from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
|
||||
from tenancy.models import Tenant
|
||||
from virtualization.models import Cluster
|
||||
|
||||
devices = load_yaml("/opt/netbox/initializers/devices.yml")
|
||||
|
||||
if devices is None:
|
||||
sys.exit()
|
||||
|
||||
required_assocs = {
|
||||
"device_role": (DeviceRole, "name"),
|
||||
"device_type": (DeviceType, "model"),
|
||||
"site": (Site, "name"),
|
||||
}
|
||||
|
||||
optional_assocs = {
|
||||
"tenant": (Tenant, "name"),
|
||||
"platform": (Platform, "name"),
|
||||
"rack": (Rack, "name"),
|
||||
"cluster": (Cluster, "name"),
|
||||
}
|
||||
|
||||
for params in devices:
|
||||
custom_field_data = pop_custom_fields(params)
|
||||
|
||||
# primary ips are handled later in `270_primary_ips.py`
|
||||
params.pop("primary_ip4", None)
|
||||
params.pop("primary_ip6", None)
|
||||
|
||||
for assoc, details in required_assocs.items():
|
||||
model, field = details
|
||||
query = {field: params.pop(assoc)}
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
for assoc, details in optional_assocs.items():
|
||||
if assoc in params:
|
||||
model, field = details
|
||||
query = {field: params.pop(assoc)}
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
device, created = Device.objects.get_or_create(**params)
|
||||
|
||||
if created:
|
||||
set_custom_fields_values(device, custom_field_data)
|
||||
|
||||
print("🖥️ Created device", device.name)
|
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
|
||||
from dcim.models import Site
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from ipam.models import VLANGroup
|
||||
from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
|
||||
|
||||
|
@ -9,7 +9,7 @@ vlan_groups = load_yaml("/opt/netbox/initializers/vlan_groups.yml")
|
|||
if vlan_groups is None:
|
||||
sys.exit()
|
||||
|
||||
optional_assocs = {"site": (Site, "name")}
|
||||
optional_assocs = {"scope": (None, "name")}
|
||||
|
||||
for params in vlan_groups:
|
||||
custom_field_data = pop_custom_fields(params)
|
||||
|
@ -18,9 +18,20 @@ for params in vlan_groups:
|
|||
if assoc in params:
|
||||
model, field = details
|
||||
query = {field: params.pop(assoc)}
|
||||
|
||||
params[assoc] = model.objects.get(**query)
|
||||
|
||||
# Get model from Contenttype
|
||||
scope_type = params.pop("scope_type", None)
|
||||
if not scope_type:
|
||||
print(f"VLAN Group '{params['name']}': scope_type is missing from VLAN Group")
|
||||
continue
|
||||
app_label, model = str(scope_type).split(".")
|
||||
ct = ContentType.objects.filter(app_label=app_label, model=model).first()
|
||||
if not ct:
|
||||
print(
|
||||
f"VLAN Group '{params['name']}': ContentType for "
|
||||
+ f"app_label = '{app_label}' and model = '{model}' not found"
|
||||
)
|
||||
continue
|
||||
params["scope_id"] = ct.model_class().objects.get(**query).id
|
||||
vlan_group, created = VLANGroup.objects.get_or_create(**params)
|
||||
|
||||
if created:
|
||||
|
|
|
@ -23,7 +23,7 @@ for link in custom_links:
|
|||
if link["content_type_id"] is None:
|
||||
print(
|
||||
"⚠️ Unable to create Custom Link '{0}': The content_type '{1}' is unknown".format(
|
||||
link.name, content_type
|
||||
link.get('name'), content_type
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
|
||||
from dcim.models import PowerPanel, RackGroup, Site
|
||||
from dcim.models import Location, PowerPanel, Site
|
||||
from startup_script_utils import load_yaml, pop_custom_fields, set_custom_fields_values
|
||||
|
||||
power_panels = load_yaml("/opt/netbox/initializers/power_panels.yml")
|
||||
|
@ -10,7 +10,7 @@ if power_panels is None:
|
|||
|
||||
required_assocs = {"site": (Site, "name")}
|
||||
|
||||
optional_assocs = {"rack_group": (RackGroup, "name")}
|
||||
optional_assocs = {"location": (Location, "name")}
|
||||
|
||||
for params in power_panels:
|
||||
custom_field_data = pop_custom_fields(params)
|
||||
|
|
Loading…
Reference in New Issue