diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 1d945f72fea..08bccc55186 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -14,7 +14,7 @@ body: attributes: label: NetBox version description: What version of NetBox are you currently running? - placeholder: v3.3.1 + placeholder: v3.3.2 validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index 809246a381b..4dbf51f2c9b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -14,7 +14,7 @@ body: attributes: label: NetBox version description: What version of NetBox are you currently running? - placeholder: v3.3.1 + placeholder: v3.3.2 validations: required: true - type: dropdown diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a026878bb81..33134cb453c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,15 +1,16 @@ -### Fixes: +### Fixes: #1234 + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b4733cbee3..47fca53d023 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,23 +102,28 @@ appropriate labels will be applied for categorization. [getting started](https://docs.netbox.dev/en/stable/development/getting-started/) documentation for tips on setting up your development environment. -* 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. +* Be sure to open an issue and wait for it to be assigned to you **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 +proposed changes that we might not be able to accept. When suggesting a new +feature, also make sure it won't conflict with any work that's already in +progress. * Once you've opened or identified an issue you'd like to work on, ask that it -be assigned to you so that others are aware it's being worked on. A maintainer -will then mark the issue as "accepted." +be assigned to you so that others are aware it's being worked on. If it meets +the acceptance criteria, a maintainer will then mark the issue as "accepted" +and assign it to you. (Note that GitHub requires that a user first comment on +an issue before it can be assigned to that user.) -* Any pull request which does _not_ relate to an **accepted** issue will be closed. +* Any pull request which does not relate to an **assigned** issue will be +closed. * All new functionality must include relevant tests where applicable. * When submitting a pull request, please be sure to work off of the `develop` branch, rather than `master`. The `develop` branch is used for ongoing -development, while `master` is used for tagging stable releases. +development, while `master` is used for tagging stable releases. (If you're +developing for the next minor release, use `feature` instead.) * In most cases, it is not necessary to add a changelog entry: A maintainer will take care of this when the PR is merged. (This helps avoid merge conflicts @@ -136,8 +141,10 @@ these checks): Only comment on an issue if you are sharing a relevant idea or constructive feedback. **Do not** comment on an issue just to show your support (give the -top post a :+1: instead) or ask for an ETA. These comments will be deleted to -reduce noise in the discussion. +top post a :+1: instead) or to ask for an update. Doing so generates +unnecessary noise in the discussion, and is especially annoying for people who +have subscribed to updates for the issue. Any comments without substance +relevant to the discussion will be deleted. ## Issue Lifecycle diff --git a/README.md b/README.md index 60f00794626..93e12507959 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,14 @@ ![Master branch build status](https://github.com/netbox-community/netbox/workflows/CI/badge.svg?branch=master) -NetBox is an infrastructure resource modeling (IRM) tool designed to empower -network automation, used by thousands of organizations around the world. -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. It is intended to -function as a domain-specific source of truth for network operations. +NetBox is the leading solution for modeling and documenting modern networks. By +combining the traditional disciplines of IP address management (IPAM) and +datacenter infrastructure management (DCIM) with powerful APIs and extensions, +NetBox provides the ideal "source of truth" to power network automation. +Available as open source software under the Apache 2.0 license, NetBox is +employed by thousands of organizations around the world. + +![Screenshot of Netbox UI](docs/media/screenshots/netbox-ui.png "NetBox UI") Myriad infrastructure components can be modeled in NetBox, including: @@ -21,6 +23,7 @@ Myriad infrastructure components can be modeled in NetBox, including: * Virtual machines and clusters * IP prefixes, ranges, and addresses * VRFs and route targets +* L2VPN and overlays * FHRP groups (VRRP, HSRP, etc.) * AS numbers * VLANs and scoped VLAN groups @@ -45,11 +48,13 @@ customized and extended through the use of: NetBox also features a complete REST API as well as a GraphQL API for easily integrating with other tools and systems. +The complete documentation for NetBox can be found at [docs.netbox.dev](https://docs.netbox.dev/). +A public demo instance is available at [demo.netbox.dev](https://demo.netbox.dev). + NetBox runs as a web application atop the [Django](https://www.djangoproject.com/) Python framework with a [PostgreSQL](https://www.postgresql.org/) database. For a -complete list of requirements, see `requirements.txt`. The code is available [on GitHub](https://github.com/netbox-community/netbox). - -The complete documentation for NetBox can be found at [docs.netbox.dev](https://docs.netbox.dev/). A public demo instance is available at https://demo.netbox.dev. +complete list of requirements, see `requirements.txt`. The code is available +[on GitHub](https://github.com/netbox-community/netbox).

Thank you to our sponsors!

@@ -90,8 +95,6 @@ our [contributing guide](CONTRIBUTING.md) prior to beginning any work. ### Screenshots -![Screenshot of main page (light mode)](docs/media/screenshots/home-light.png "Main page (light mode)") - ![Screenshot of main page (dark mode)](docs/media/screenshots/home-dark.png "Main page (dark mode)") ![Screenshot of rack elevation](docs/media/screenshots/rack.png "Rack elevation") diff --git a/docs/development/git-cheat-sheet.md b/docs/development/git-cheat-sheet.md new file mode 100644 index 00000000000..35b8e90b5aa --- /dev/null +++ b/docs/development/git-cheat-sheet.md @@ -0,0 +1,388 @@ +# git Cheat Sheet + +This cheat sheet serves as a convenient reference for NetBox contributors who already somewhat familiar with using git. For a general introduction to the tooling and workflows involved, please see GitHub's guide [Getting started with git](https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git). + +## Common Operations + +### Clone a Repo + +This copies a remote git repository (e.g. from GitHub) to your local workstation. It will create a new directory bearing the repo's name in the current path. + +``` title="Command" +git clone https://github.com/$org-name/$repo-name +``` + +``` title="Example" +$ git clone https://github.com/netbox-community/netbox +Cloning into 'netbox'... +remote: Enumerating objects: 95112, done. +remote: Counting objects: 100% (682/682), done. +remote: Compressing objects: 100% (246/246), done. +remote: Total 95112 (delta 448), reused 637 (delta 436), pack-reused 94430 +Receiving objects: 100% (95112/95112), 60.40 MiB | 45.82 MiB/s, done. +Resolving deltas: 100% (74979/74979), done. +``` + +### Pull New Commits + +To update your local branch with any recent upstream commits, run `git pull`. + +``` title="Command" +git pull +``` + +``` title="Example" +$ git pull +remote: Enumerating objects: 1, done. +remote: Counting objects: 100% (1/1), done. +remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (1/1), done. +From https://github.com/netbox-community/netbox + 28bc76695..e0741cc9a develop -> origin/develop +Updating 28bc76695..e0741cc9a +Fast-forward + docs/release-notes/version-3.3.md | 1 + + netbox/netbox/settings.py | 1 + + 2 files changed, 2 insertions(+) +``` + +### List Branches + +`git branch` lists all local branches. Appending `-a` to this command will list both local (green) and remote (red) branches. + +``` title="Command" +git branch -a +``` + +``` title="Example" +$ git branch -a +* develop + remotes/origin/10170-changelog + remotes/origin/HEAD -> origin/develop + remotes/origin/develop + remotes/origin/feature + remotes/origin/master +``` + +### Switch Branches + +To switch to a different branch, use the `checkout` command. + +``` title="Command" +git checkout $branchname +``` + +``` title="Example" +$ git checkout feature +Branch 'feature' set up to track remote branch 'feature' from 'origin'. +Switched to a new branch 'feature' +``` + +### Create a New Branch + +Use the `-b` argument with `checkout` to create a new _local_ branch from the current branch. + +``` title="Command" +git checkout -b $newbranch +``` + +``` title="Example" +$ git checkout -b 123-fix-foo +Switched to a new branch '123-fix-foo' +``` + +### Rename a Branch + +To rename the current branch, use the `git branch` command with the `-m` argument (for "modify"). + +``` title="Command" +git branch -m $newname +``` + +``` title="Example" +$ git branch -m jstretch-testing +$ git branch + develop + feature +* jstretch-testing +``` + +### Merge a Branch + +To merge one branch into another, use the `git merge` command. Start by checking out the _destination_ branch, and merge the _source_ branch into it. + +``` title="Command" +git merge $sourcebranch +``` + +``` title="Example" +$ git checkout testing +Switched to branch 'testing' +Your branch is up to date with 'origin/testing'. +$ git merge branch2 +Updating 9a12b5b5f..8ee42390b +Fast-forward + newfile.py | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 newfile.py +``` + +!!! warning "Avoid Merging Remote Branches" + You generally want to avoid merging branches that exist on the remote (upstream) repository, such as `develop` and `feature`: Merges into these branches should be done via a pull request on GitHub. Only merge branches when it is necessary to consolidate work you've done locally. + +### Show Pending Changes + +After making changes to files in the repo, `git status` will display a summary of created, modified, and deleted files. + +``` title="Command" +git status +``` + +``` title="Example" +$ git status +On branch 123-fix-foo +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: README.md + +Untracked files: + (use "git add ..." to include in what will be committed) + + foo.py + +no changes added to commit (use "git add" and/or "git commit -a") +``` + +### Stage Changed Files + +Before creating a new commit, modified files must be staged. This is typically done with the `git add` command. You can specify a particular path, or just append `-A` to automatically staged _all_ changed files within the current directory. Run `git status` again to verify what files have been staged. + +``` title="Command" +git add -A +``` + +``` title="Example" +$ git add -A +$ git status +On branch 123-fix-foo +Changes to be committed: + (use "git reset HEAD ..." to unstage) + + modified: README.md + new file: foo.py + +``` + +### Review Staged Files + +It's a good idea to thoroughly review all staged changes immediately prior to creating a new commit. This can be done using the `git diff` command. Appending the `--staged` argument will show staged changes; omitting it will show changes that have not yet been staged. + +``` title="Command" +git diff --staged +``` + +``` title="Example" +$ git diff --staged +diff --git a/README.md b/README.md +index 93e125079..4344fb514 100644 +--- a/README.md ++++ b/README.md +@@ -1,3 +1,8 @@ ++ ++Added some lines here ++and here ++and here too ++ +
+ NetBox logo +
+diff --git a/foo.py b/foo.py +new file mode 100644 +index 000000000..e69de29bb +``` + +### Create a New Commit + +The `git commit` command records your changes to the current branch. Specify a commit message with the `-m` argument. (If omitted, a file editor will be opened to provide a message. + +``` title="Command" +git commit -m "Fixes #123: Fixed the thing that was broken" +``` + +``` title="Example" +$ git commit -m "Fixes #123: Fixed the thing that was broken" +[123-fix-foo 9a12b5b5f] Fixes #123: Fixed the thing that was broken + 2 files changed, 5 insertions(+) + create mode 100644 foo.py +``` + +!!! tip "Automatically Closing Issues" + GitHub will [automatically close](https://github.blog/2013-01-22-closing-issues-via-commit-messages/) any issues referenced in a commit message by `Fixes:` or `Closes:` when the commit is merged into the repository's default branch. Contributors are strongly encouraged to follow this convention when forming commit messages. (Use "Closes" for feature requests and "Fixes" for bugs.) + +### Push a Commit Upstream + +Once you've made a commit locally, it needs to be pushed upstream to the _remote_ repository (typically called "origin"). This is done with the `git push` command. If this is a new branch that doesn't yet exist on the remote repository, you'll need to set the upstream for it when pushing. + +``` title="Command" +git push -u origin $branchname +``` + +``` title="Example" +$ git push -u origin testing +Counting objects: 3, done. +Delta compression using up to 16 threads. +Compressing objects: 100% (3/3), done. +Writing objects: 100% (3/3), 377 bytes | 377.00 KiB/s, done. +Total 3 (delta 2), reused 0 (delta 0) +remote: Resolving deltas: 100% (2/2), completed with 2 local objects. +remote: +remote: Create a pull request for 'testing' on GitHub by visiting: +remote: https://github.com/netbox-community/netbox/pull/new/testing +remote: +To https://github.com/netbox-community/netbox + * [new branch] testing -> testing +Branch 'testing' set up to track remote branch 'testing' from 'origin'. +``` + +!!! tip + You can apply the following git configuration to automatically set the upstream for all new branches. This obviates the need to specify `-u origin`. + + ``` + git config --global push.default current + ``` + +## The GitHub CLI Client + +GitHub provides a [free CLI client](https://cli.github.com/) to simplify many aspects of interacting with GitHub repositories. Note that this utility is separate from `git`, and must be [installed separately](https://github.com/cli/cli#installation). + +This guide provides some examples of common operations, but be sure to check out the [GitHub CLI manual](https://cli.github.com/manual/) for a complete accounting of available commands. + +### List Open Pull Requests + +``` title="Command" +gh pr list +``` + +``` title="Example" +$ gh pr list + +Showing 3 of 3 open pull requests in netbox-community/netbox + +#10223 #7503 API Bulk-Create of Devices does not check Rack-Space 7503-bulkdevice about 17 hours ago +#9716 Closes #9599: Add cursor pagination mode lyuyangh:cursor-pagination about 1 month ago +#9498 Adds replication and adoption for module import sleepinggenius2:issue_9361 about 2 months ago +``` + +### Check Out a PR + +This command will automatically check out the remote branch associated with an open pull request. + +``` title="Command" +gh pr checkout $number +``` + +``` title="Example" +$ gh pr checkout 10223 +Branch '7503-bulkdevice' set up to track remote branch '7503-bulkdevice' from 'origin'. +Switched to a new branch '7503-bulkdevice' +``` + +## Fixing Mistakes + +### Modify the Previous Commit + +Sometimes you'll find that you've overlooked a necessary change and need to commit again. If you haven't pushed your most recent commit and just need to make a small tweak or two, you can _amend_ your most recent commit instead of creating a new one. + +First, stage the desired files with `git add` and verify the changes, the issue the `git commit` command with the `--amend` argument. You can also append the `--no-edit` argument if you would like to keep the previous commit message. + +``` title="Command" +git commit --amend --no-edit +``` + +``` title="Example" +$ git add -A +$ git diff --staged +$ git commit --amend --no-edit +[testing 239b16921] Added a new file + Date: Fri Aug 26 16:30:05 2022 -0400 + 2 files changed, 1 insertion(+) + create mode 100644 newfile.py +``` + +!!! danger "Don't Amend After Pushing" + Never amend a commit you've already pushed upstream unless you're **certain** no one else is working on the same branch. Force-pushing will overwrite the change history, which will break any commits from other contributors. When in doubt, create a new commit instead. + +### Undo the Last Commit + +The `git reset` command can be used to undo the most recent commit. (`HEAD~` is equivalent to `HEAD~1` and references the commit prior to the current HEAD.) After making and staging your changes, commit using `-c ORIG_HEAD` to replace the erroneous commit. + +``` title="Command" +git reset HEAD~ +``` + +``` title="Example" +$ git add -A +$ git commit -m "Erroneous commit" +[testing 09ce06736] Erroneous commit + Date: Mon Aug 29 15:20:04 2022 -0400 + 1 file changed, 1 insertion(+) + create mode 100644 BADCHANGE +$ git reset HEAD~ +$ rm BADFILE +$ git add -A +$ git commit -m "Fixed commit" +[testing c585709f3] Fixed commit + Date: Mon Aug 29 15:22:38 2022 -0400 + 1 file changed, 65 insertions(+), 20 deletions(-) +``` + +!!! danger "Don't Reset After Pushing" + Resetting only works until you've pushed your local changes upstream. If you've already pushed upstream, use `git revert` instead. This will create a _new_ commit that reverts the erroneous one, but ensures that the git history remains intact. + +### Rebase from Upstream + +If a change has been pushed to the upstream branch since you most recently pulled it, attempting to push a new local commit will fail: + +``` +$ git push +To https://github.com/netbox-community/netbox.git + ! [rejected] develop -> develop (fetch first) +error: failed to push some refs to 'https://github.com/netbox-community/netbox.git' +hint: Updates were rejected because the remote contains work that you do +hint: not have locally. This is usually caused by another repository pushing +hint: to the same ref. You may want to first integrate the remote changes +hint: (e.g., 'git pull ...') before pushing again. +hint: See the 'Note about fast-forwards' in 'git push --help' for details. +``` + +To resolve this, first fetch the upstream branch to update your local copy, and then [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing) your local branch to include the new changes. Once the rebase has completed, you can push your local commits upstream. + +``` title="Commands" +git fetch +git rebase origin/$branchname +``` + +``` title="Example" +$ git fetch +remote: Enumerating objects: 1, done. +remote: Counting objects: 100% (1/1), done. +remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 +Unpacking objects: 100% (1/1), done. +From https://github.com/netbox-community/netbox + 815b2d8a2..8c35ebbb7 develop -> origin/develop +$ git rebase origin/develop +First, rewinding head to replay your work on top of it... +Applying: Further tweaks to the PR template +Applying: Changelog for #10176, #10217 +$ git push +Counting objects: 9, done. +Delta compression using up to 16 threads. +Compressing objects: 100% (9/9), done. +Writing objects: 100% (9/9), 1.02 KiB | 1.02 MiB/s, done. +Total 9 (delta 6), reused 0 (delta 0) +remote: Resolving deltas: 100% (6/6), completed with 5 local objects. +To https://github.com/netbox-community/netbox.git + 8c35ebbb7..ada745324 develop -> develop +``` diff --git a/docs/index.md b/docs/index.md index c233dedb79c..d6146544357 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,6 +4,8 @@ NetBox is the leading solution for modeling and documenting modern networks. By combining the traditional disciplines of IP address management (IPAM) and datacenter infrastructure management (DCIM) with powerful APIs and extensions, NetBox provides the ideal "source of truth" to power network automation. Read on to discover why thousands of organizations worldwide put NetBox at the heart of their infrastructure. +[![NetBox UI](./media/screenshots/netbox-ui.png)](./media/screenshots/netbox-ui.png) + ## :material-server-network: Built for Networks Unlike general-purpose CMDBs, NetBox has curated a data model which caters specifically to the needs of network engineers and operators. It delivers a wide assortment of object types carefully crafted to best serve the needs of infrastructure design and documentation. These cover all facets of network technology, from IP address managements to cabling to overlays and more: diff --git a/docs/media/screenshots/home-dark.png b/docs/media/screenshots/home-dark.png index 796637ac5b9..f6290fa553d 100644 Binary files a/docs/media/screenshots/home-dark.png and b/docs/media/screenshots/home-dark.png differ diff --git a/docs/media/screenshots/home-light.png b/docs/media/screenshots/home-light.png deleted file mode 100644 index 78d54a7d2f2..00000000000 Binary files a/docs/media/screenshots/home-light.png and /dev/null differ diff --git a/docs/media/screenshots/netbox-ui.png b/docs/media/screenshots/netbox-ui.png new file mode 100644 index 00000000000..fb692558fff Binary files /dev/null and b/docs/media/screenshots/netbox-ui.png differ diff --git a/docs/plugins/development/filtersets.md b/docs/plugins/development/filtersets.md index 318ad5b4eaf..d803ce2f4b5 100644 --- a/docs/plugins/development/filtersets.md +++ b/docs/plugins/development/filtersets.md @@ -34,12 +34,12 @@ To utilize a filter set in a subclass of one of NetBox's generic views (such as ```python # views.py from netbox.views.generic import ObjectListView -from .filtersets import MyModelFitlerSet +from .filtersets import MyModelFilterSet from .models import MyModel class MyModelListView(ObjectListView): queryset = MyModel.objects.all() - filterset = MyModelFitlerSet + filterset = MyModelFilterSet ``` To enable a filter set on a REST API endpoint, set the `filterset_class` attribute on the API view: diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index f5c02de82d9..3482c906196 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -1,5 +1,39 @@ # NetBox v3.3 +## v3.3.2 (2022-09-02) + +### Enhancements + +* [#9477](https://github.com/netbox-community/netbox/issues/9477) - Enable clearing applied table column ordering +* [#10034](https://github.com/netbox-community/netbox/issues/10034) - Add L2VPN column to interface and VLAN tables +* [#10043](https://github.com/netbox-community/netbox/issues/10043) - Add support for `limit` query parameter to available VLANs API endpoint +* [#10060](https://github.com/netbox-community/netbox/issues/10060) - Add journal entries to global search +* [#10195](https://github.com/netbox-community/netbox/issues/10195) - Enable filtering of device components by rack +* [#10233](https://github.com/netbox-community/netbox/issues/10233) - Enable sorting rack elevations by facility ID + +### Bug Fixes + +* [#9328](https://github.com/netbox-community/netbox/issues/9328) - Hide available IPs when non-default ordering is applied +* [#9481](https://github.com/netbox-community/netbox/issues/9481) - Update child device location when parent location changes +* [#9832](https://github.com/netbox-community/netbox/issues/9832) - Improve error message when validating rack reservation units +* [#9895](https://github.com/netbox-community/netbox/issues/9895) - Various corrections to OpenAPI spec +* [#9962](https://github.com/netbox-community/netbox/issues/9962) - SSO login should respect `next` URL query parameter +* [#9963](https://github.com/netbox-community/netbox/issues/9963) - Fix support for custom `CSRF_COOKIE_NAME` value +* [#10155](https://github.com/netbox-community/netbox/issues/10155) - Fix rear port display when editing front port template for module type +* [#10156](https://github.com/netbox-community/netbox/issues/10156) - Avoid forcing SVG image links to open in a new window +* [#10161](https://github.com/netbox-community/netbox/issues/10161) - Restore "set null" option for custom fields during bulk edit +* [#10176](https://github.com/netbox-community/netbox/issues/10176) - Correct utilization display for empty racks +* [#10177](https://github.com/netbox-community/netbox/issues/10177) - Correct display of custom fields when editing VM interfaces +* [#10178](https://github.com/netbox-community/netbox/issues/10178) - Display manufacturer name alongside device type under device view +* [#10181](https://github.com/netbox-community/netbox/issues/10181) - Restore MultiPartParser (regression from #10031) +* [#10184](https://github.com/netbox-community/netbox/issues/10184) - Fix vertical alignment when displaying object attributes with buttons +* [#10208](https://github.com/netbox-community/netbox/issues/10208) - Fix permissions evaluation for interface actions dropdown menu +* [#10217](https://github.com/netbox-community/netbox/issues/10217) - Handle exception when trace splits to multiple rear ports +* [#10220](https://github.com/netbox-community/netbox/issues/10220) - Validate IP version when assigning primary IPs to a virtual machine +* [#10231](https://github.com/netbox-community/netbox/issues/10231) - Correct API schema definition for several serializer fields + +--- + ## v3.3.1 (2022-08-25) ### Enhancements diff --git a/mkdocs.yml b/mkdocs.yml index eef00048105..530c6d52eed 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -249,6 +249,7 @@ nav: - User Preferences: 'development/user-preferences.md' - Web UI: 'development/web-ui.md' - Release Checklist: 'development/release-checklist.md' + - git Cheat Sheet: 'development/git-cheat-sheet.md' - Release Notes: - Summary: 'release-notes/index.md' - Version 3.3: 'release-notes/version-3.3.md' diff --git a/netbox/dcim/api/nested_serializers.py b/netbox/dcim/api/nested_serializers.py index 1be8bb9dc03..f5e06e155fa 100644 --- a/netbox/dcim/api/nested_serializers.py +++ b/netbox/dcim/api/nested_serializers.py @@ -316,6 +316,7 @@ class Meta: class NestedConsoleServerPortSerializer(WritableNestedSerializer): url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleserverport-detail') device = NestedDeviceSerializer(read_only=True) + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.ConsoleServerPort @@ -325,6 +326,7 @@ class Meta: class NestedConsolePortSerializer(WritableNestedSerializer): url = serializers.HyperlinkedIdentityField(view_name='dcim-api:consoleport-detail') device = NestedDeviceSerializer(read_only=True) + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.ConsolePort @@ -334,6 +336,7 @@ class Meta: class NestedPowerOutletSerializer(WritableNestedSerializer): url = serializers.HyperlinkedIdentityField(view_name='dcim-api:poweroutlet-detail') device = NestedDeviceSerializer(read_only=True) + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.PowerOutlet @@ -343,6 +346,7 @@ class Meta: class NestedPowerPortSerializer(WritableNestedSerializer): url = serializers.HyperlinkedIdentityField(view_name='dcim-api:powerport-detail') device = NestedDeviceSerializer(read_only=True) + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.PowerPort @@ -352,6 +356,7 @@ class Meta: class NestedInterfaceSerializer(WritableNestedSerializer): device = NestedDeviceSerializer(read_only=True) url = serializers.HyperlinkedIdentityField(view_name='dcim-api:interface-detail') + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.Interface @@ -361,6 +366,7 @@ class Meta: class NestedRearPortSerializer(WritableNestedSerializer): device = NestedDeviceSerializer(read_only=True) url = serializers.HyperlinkedIdentityField(view_name='dcim-api:rearport-detail') + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.RearPort @@ -370,6 +376,7 @@ class Meta: class NestedFrontPortSerializer(WritableNestedSerializer): device = NestedDeviceSerializer(read_only=True) url = serializers.HyperlinkedIdentityField(view_name='dcim-api:frontport-detail') + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.FrontPort @@ -454,6 +461,7 @@ class Meta: class NestedPowerFeedSerializer(WritableNestedSerializer): url = serializers.HyperlinkedIdentityField(view_name='dcim-api:powerfeed-detail') + _occupied = serializers.BooleanField(required=False, read_only=True) class Meta: model = models.PowerFeed diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index af806acb856..79f5339adcc 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -579,7 +579,7 @@ class Meta: 'description', 'component_type', 'component_id', 'component', 'created', 'last_updated', '_depth', ] - @swagger_serializer_method(serializer_or_field=serializers.DictField) + @swagger_serializer_method(serializer_or_field=serializers.JSONField) def get_component(self, obj): if obj.component is None: return None @@ -693,13 +693,13 @@ class Meta(DeviceSerializer.Meta): 'local_context_data', 'tags', 'custom_fields', 'config_context', 'created', 'last_updated', ] - @swagger_serializer_method(serializer_or_field=serializers.DictField) + @swagger_serializer_method(serializer_or_field=serializers.JSONField) def get_config_context(self, obj): return obj.get_config_context() class DeviceNAPALMSerializer(serializers.Serializer): - method = serializers.DictField() + method = serializers.JSONField() # @@ -975,7 +975,7 @@ class Meta: 'custom_fields', 'created', 'last_updated', '_depth', ] - @swagger_serializer_method(serializer_or_field=serializers.DictField) + @swagger_serializer_method(serializer_or_field=serializers.JSONField) def get_component(self, obj): if obj.component is None: return None @@ -1046,7 +1046,7 @@ class Meta: 'id', 'url', 'display', 'cable', 'cable_end', 'termination_type', 'termination_id', 'termination' ] - @swagger_serializer_method(serializer_or_field=serializers.DictField) + @swagger_serializer_method(serializer_or_field=serializers.JSONField) def get_termination(self, obj): serializer = get_serializer_for_model(obj.termination, prefix=NESTED_SERIALIZER_PREFIX) context = {'request': self.context['request']} diff --git a/netbox/dcim/filtersets.py b/netbox/dcim/filtersets.py index 874d08ba5b8..5d92af87839 100644 --- a/netbox/dcim/filtersets.py +++ b/netbox/dcim/filtersets.py @@ -1084,6 +1084,17 @@ class DeviceComponentFilterSet(django_filters.FilterSet): to_field_name='slug', label='Location (slug)', ) + rack_id = django_filters.ModelMultipleChoiceFilter( + field_name='device__rack', + queryset=Rack.objects.all(), + label='Rack (ID)', + ) + rack = django_filters.ModelMultipleChoiceFilter( + field_name='device__rack__name', + queryset=Rack.objects.all(), + to_field_name='name', + label='Rack (name)', + ) device_id = django_filters.ModelMultipleChoiceFilter( queryset=Device.objects.all(), label='Device (ID)', diff --git a/netbox/dcim/forms/filtersets.py b/netbox/dcim/forms/filtersets.py index 16ff6fee236..173ea5d1ea9 100644 --- a/netbox/dcim/forms/filtersets.py +++ b/netbox/dcim/forms/filtersets.py @@ -87,6 +87,15 @@ class DeviceComponentFilterForm(NetBoxModelFilterSetForm): }, label=_('Location') ) + rack_id = DynamicModelMultipleChoiceField( + queryset=Rack.objects.all(), + required=False, + query_params={ + 'site_id': '$site_id', + 'location_id': '$location_id', + }, + label=_('Rack') + ) virtual_chassis_id = DynamicModelMultipleChoiceField( queryset=VirtualChassis.objects.all(), required=False, @@ -932,7 +941,7 @@ class ConsolePortFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'type', 'speed')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) type = MultipleChoiceField( choices=ConsolePortTypeChoices, @@ -950,7 +959,7 @@ class ConsoleServerPortFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'type', 'speed')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) type = MultipleChoiceField( choices=ConsolePortTypeChoices, @@ -968,7 +977,7 @@ class PowerPortFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'type')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) type = MultipleChoiceField( choices=PowerPortTypeChoices, @@ -982,7 +991,7 @@ class PowerOutletFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'type')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) type = MultipleChoiceField( choices=PowerOutletTypeChoices, @@ -999,7 +1008,7 @@ class InterfaceFilterForm(DeviceComponentFilterForm): ('Addressing', ('vrf_id', 'mac_address', 'wwn')), ('PoE', ('poe_mode', 'poe_type')), ('Wireless', ('rf_role', 'rf_channel', 'rf_channel_width', 'tx_power')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) kind = MultipleChoiceField( choices=InterfaceKindChoices, @@ -1084,7 +1093,7 @@ class FrontPortFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'type', 'color')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) model = FrontPort type = MultipleChoiceField( @@ -1102,7 +1111,7 @@ class RearPortFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'type', 'color')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) type = MultipleChoiceField( choices=PortTypeChoices, @@ -1119,7 +1128,7 @@ class ModuleBayFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'position')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) tag = TagFilterField(model) position = forms.CharField( @@ -1132,7 +1141,7 @@ class DeviceBayFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) tag = TagFilterField(model) @@ -1142,7 +1151,7 @@ class InventoryItemFilterForm(DeviceComponentFilterForm): fieldsets = ( (None, ('q', 'tag')), ('Attributes', ('name', 'label', 'role_id', 'manufacturer_id', 'serial', 'asset_tag', 'discovered')), - ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'virtual_chassis_id', 'device_id')), + ('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')), ) role_id = DynamicModelMultipleChoiceField( queryset=InventoryItemRole.objects.all(), diff --git a/netbox/dcim/forms/models.py b/netbox/dcim/forms/models.py index edf25cf2ce4..d1d5b1683a2 100644 --- a/netbox/dcim/forms/models.py +++ b/netbox/dcim/forms/models.py @@ -1069,6 +1069,7 @@ class FrontPortTemplateForm(BootstrapMixin, forms.ModelForm): required=False, query_params={ 'devicetype_id': '$device_type', + 'moduletype_id': '$module_type', } ) diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 2be64451fee..ab1fe88e470 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -677,6 +677,12 @@ def get_split_nodes(self): """ Return all available next segments in a split cable path. """ - rearports = self.path_objects[-1] - - return FrontPort.objects.filter(rear_port__in=rearports) + nodes = self.path_objects[-1] + + # RearPort splitting to multiple FrontPorts with no stack position + if type(nodes[0]) is RearPort: + return FrontPort.objects.filter(rear_port__in=nodes) + # Cable terminating to multiple FrontPorts mapped to different + # RearPorts connected to different cables + elif type(nodes[0]) is FrontPort: + return RearPort.objects.filter(pk__in=[fp.rear_port_id for fp in nodes]) diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py index 092df3a0e8c..ccf4613bff1 100644 --- a/netbox/dcim/models/devices.py +++ b/netbox/dcim/models/devices.py @@ -168,6 +168,10 @@ def get_prerequisite_models(cls): def get_absolute_url(self): return reverse('dcim:devicetype', args=[self.pk]) + @property + def get_full_name(self): + return f"{ self.manufacturer } { self.model }" + def to_yaml(self): data = { 'manufacturer': self.manufacturer.name, @@ -864,6 +868,7 @@ def save(self, *args, **kwargs): for device in devices: device.site = self.site device.rack = self.rack + device.location = self.location device.save() @property diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index 22fca8cf676..20027675ab1 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -350,7 +350,7 @@ def get_available_units(self, u_height=1, rack_face=None, exclude=None): # Remove units without enough space above them to accommodate a device of the specified height available_units = [] for u in units: - if set(drange(u, u + u_height, 0.5)).issubset(units): + if set(drange(u, u + decimal.Decimal(u_height), 0.5)).issubset(units): available_units.append(u) return list(reversed(available_units)) @@ -415,12 +415,13 @@ def get_utilization(self): """ # Determine unoccupied units total_units = len(list(self.units)) - available_units = self.get_available_units() + available_units = self.get_available_units(u_height=0.5) # Remove reserved units - for u in self.get_reserved_units(): - if u in available_units: - available_units.remove(u) + for ru in self.get_reserved_units(): + for u in drange(ru, ru + 1, 0.5): + if u in available_units: + available_units.remove(u) occupied_unit_count = total_units - len(available_units) percentage = float(occupied_unit_count) / total_units * 100 diff --git a/netbox/dcim/svg/cables.py b/netbox/dcim/svg/cables.py index 26d16fafe89..3872bc4fe9e 100644 --- a/netbox/dcim/svg/cables.py +++ b/netbox/dcim/svg/cables.py @@ -94,7 +94,7 @@ def __init__(self, start, url, color, labels=[], **extra): self.add(cable) # Add link - link = Hyperlink(href=url, target='_blank') + link = Hyperlink(href=url, target='_parent') # Add text label(s) cursor = start[1] @@ -281,7 +281,7 @@ def draw_wirelesslink(self, wirelesslink): self.cursor += PADDING * 2 # Add link - link = Hyperlink(href=f'{self.base_url}{wirelesslink.get_absolute_url()}', target='_blank') + link = Hyperlink(href=f'{self.base_url}{wirelesslink.get_absolute_url()}', target='_parent') # Add text label(s) for i, label in enumerate(labels): diff --git a/netbox/dcim/svg/racks.py b/netbox/dcim/svg/racks.py index 28527498f51..573fc966c88 100644 --- a/netbox/dcim/svg/racks.py +++ b/netbox/dcim/svg/racks.py @@ -151,7 +151,7 @@ def _draw_device(self, device, coords, size, color=None, image=None): css_extra = ' shaded' if is_shaded else '' # Create hyperlink element - link = Hyperlink(href=f'{self.base_url}{device.get_absolute_url()}', target='_blank') + link = Hyperlink(href=f'{self.base_url}{device.get_absolute_url()}', target="_parent") link.set_desc(description) # Add rect element to hyperlink @@ -235,10 +235,7 @@ def draw_margin(self): self.margin_width, u_height * self.unit_height ) - link = Hyperlink( - href='{}{}'.format(self.base_url, reservation.get_absolute_url()), - target='_blank' - ) + link = Hyperlink(href=f'{self.base_url}{reservation.get_absolute_url()}', target='_parent') link.set_desc(f'Reservation #{reservation.pk}: {reservation.description}') link.add( Rect(coords, size, class_='reservation') @@ -268,7 +265,7 @@ def draw_background(self, face): y_offset + self.unit_height / 2 ) - link = Hyperlink(href=url_string.format(unit), target='_blank') + link = Hyperlink(href=url_string.format(unit), target='_parent') link.add(Rect((x_offset, y_offset), (self.unit_width, self.unit_height), class_='slot')) link.add(Text('add device', insert=text_coords, class_='add-device')) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index c1515a15f0b..036f83306c0 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -483,6 +483,12 @@ class BaseInterfaceTable(NetBoxTable): orderable=False, verbose_name='FHRP Groups' ) + l2vpn = tables.Column( + accessor=tables.A('l2vpn_termination__l2vpn'), + linkify=True, + orderable=False, + verbose_name='L2VPN' + ) untagged_vlan = tables.Column(linkify=True) tagged_vlans = columns.TemplateColumn( template_code=INTERFACE_TAGGED_VLANS, @@ -520,8 +526,8 @@ class Meta(DeviceComponentTable.Meta): 'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'enabled', 'type', 'mgmt_only', 'mtu', 'speed', 'duplex', 'mode', 'mac_address', 'wwn', 'poe_mode', 'poe_type', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable', - 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', 'tags', 'vrf', 'ip_addresses', - 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'created', 'last_updated', + 'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', 'tags', 'vrf', 'l2vpn', + 'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'created', 'last_updated', ) default_columns = ('pk', 'name', 'device', 'label', 'enabled', 'type', 'description') @@ -554,8 +560,8 @@ class Meta(DeviceComponentTable.Meta): 'pk', 'id', 'name', 'module_bay', 'module', 'label', 'enabled', 'type', 'parent', 'bridge', 'lag', 'mgmt_only', 'mtu', 'mode', 'mac_address', 'wwn', 'rf_role', 'rf_channel', 'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable', 'cable_color', 'wireless_link', - 'wireless_lans', 'link_peer', 'connection', 'tags', 'ip_addresses', 'fhrp_groups', 'untagged_vlan', - 'tagged_vlans', 'actions', + 'wireless_lans', 'link_peer', 'connection', 'tags', 'vrf', 'l2vpn', 'ip_addresses', 'fhrp_groups', + 'untagged_vlan', 'tagged_vlans', 'actions', ) order_by = ('name',) default_columns = ( diff --git a/netbox/dcim/tables/racks.py b/netbox/dcim/tables/racks.py index d83f25a5f02..39553bac066 100644 --- a/netbox/dcim/tables/racks.py +++ b/netbox/dcim/tables/racks.py @@ -51,7 +51,7 @@ class RackTable(TenancyColumnsMixin, NetBoxTable): status = columns.ChoiceFieldColumn() role = columns.ColoredLabelColumn() u_height = tables.TemplateColumn( - template_code="{{ record.u_height }}U", + template_code="{{ value }}U", verbose_name='Height' ) comments = columns.MarkdownColumn() diff --git a/netbox/dcim/tables/template_code.py b/netbox/dcim/tables/template_code.py index 8b6ac90b5c6..d34003ee562 100644 --- a/netbox/dcim/tables/template_code.py +++ b/netbox/dcim/tables/template_code.py @@ -4,7 +4,7 @@ {{ termination.parent_object }} {% endif %} - {{ termination }}{% if not forloop.last %},{% endif %} + {{ termination }}{% if not forloop.last %}
{% endif %} {% empty %} {{ ''|placeholder }} {% endfor %} @@ -33,7 +33,7 @@ INTERFACE_IPADDRESSES = """
- {% for ip in record.ip_addresses.all %} + {% for ip in value.all %} {% if ip.status != 'active' %} {{ ip }} {% else %} @@ -53,7 +53,7 @@ INTERFACE_TAGGED_VLANS = """ {% if record.mode == 'tagged' %} - {% for vlan in record.tagged_vlans.all %} + {% for vlan in value.all %} {{ vlan }}
{% endfor %} {% elif record.mode == 'tagged-all' %} @@ -62,7 +62,7 @@ """ INTERFACE_WIRELESS_LANS = """ -{% for wlan in record.wireless_lans.all %} +{% for wlan in value.all %} {{ wlan }}
{% endfor %} """ @@ -226,7 +226,7 @@ """ INTERFACE_BUTTONS = """ -{% if perms.dcim.edit_interface %} +{% if perms.dcim.change_interface %} + {% else %} + + {% endif %} Cancel -
diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index 2611686f65d..364b507779c 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -22,16 +22,18 @@

Path split!

Select a node below to continue:

{% else %}

Trace Completed

diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 2df2407b598..8a70db6211e 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -46,10 +46,10 @@
Rack - + {% if object.rack %} {{ object.rack|linkify }} -
+
@@ -90,7 +90,7 @@
Device Type - {{ object.device_type|linkify }} ({{ object.device_type.u_height }}U) + {{ object.device_type|linkify:"get_full_name" }} ({{ object.device_type.u_height }}U) diff --git a/netbox/templates/dcim/location.html b/netbox/templates/dcim/location.html index f0335036f4c..10cec15486c 100644 --- a/netbox/templates/dcim/location.html +++ b/netbox/templates/dcim/location.html @@ -58,9 +58,9 @@
Racks - + {% if rack_count %} -
+
diff --git a/netbox/templates/dcim/rack_elevation_list.html b/netbox/templates/dcim/rack_elevation_list.html index 87a04790082..ef22bd9b8cd 100644 --- a/netbox/templates/dcim/rack_elevation_list.html +++ b/netbox/templates/dcim/rack_elevation_list.html @@ -18,9 +18,15 @@ Front Rear
-
- Normal - Reversed +
diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html index ab04ea018cf..a4ee4180fb7 100644 --- a/netbox/templates/dcim/site.html +++ b/netbox/templates/dcim/site.html @@ -85,11 +85,11 @@
Site
Physical Address - + {% if object.physical_address %} -
+ {{ object.physical_address|linebreaksbr }} @@ -104,9 +104,9 @@
Site
GPS Coordinates - + {% if object.latitude and object.longitude %} -
+
Map It diff --git a/netbox/templates/inc/table_htmx.html b/netbox/templates/inc/table_htmx.html index bf8156c2bfd..45bfb390d3f 100644 --- a/netbox/templates/inc/table_htmx.html +++ b/netbox/templates/inc/table_htmx.html @@ -8,6 +8,16 @@ {% for column in table.columns %} {% if column.orderable %} + {% if column.is_ordered %} +
+ +
+ {% endif %} Interface
{% endif %} {% render_field form.name %} {% render_field form.description %} - {% render_field form.mac_address %} + {% render_field form.tags %} + + +
+
+
Addressing
+
{% render_field form.vrf %} + {% render_field form.mac_address %} +
+ +
+
+
Operation
+
{% render_field form.mtu %} - {% render_field form.tags %} {% render_field form.enabled %}
diff --git a/netbox/tenancy/api/serializers.py b/netbox/tenancy/api/serializers.py index f217fdaf833..d2c6801c60c 100644 --- a/netbox/tenancy/api/serializers.py +++ b/netbox/tenancy/api/serializers.py @@ -107,7 +107,7 @@ class Meta: 'last_updated', ] - @swagger_serializer_method(serializer_or_field=serializers.DictField) + @swagger_serializer_method(serializer_or_field=serializers.JSONField) def get_object(self, instance): serializer = get_serializer_for_model(instance.content_type.model_class(), prefix=NESTED_SERIALIZER_PREFIX) context = {'request': self.context['request']} diff --git a/netbox/users/api/nested_serializers.py b/netbox/users/api/nested_serializers.py index e9e730cc4cb..0d8f7ae42f4 100644 --- a/netbox/users/api/nested_serializers.py +++ b/netbox/users/api/nested_serializers.py @@ -1,5 +1,6 @@ from django.contrib.auth.models import Group, User from django.contrib.contenttypes.models import ContentType +from drf_yasg.utils import swagger_serializer_method from rest_framework import serializers from netbox.api.fields import ContentTypeField @@ -56,8 +57,10 @@ class Meta: model = ObjectPermission fields = ['id', 'url', 'display', 'name', 'enabled', 'object_types', 'groups', 'users', 'actions'] + @swagger_serializer_method(serializer_or_field=serializers.ListField) def get_groups(self, obj): return [g.name for g in obj.groups.all()] + @swagger_serializer_method(serializer_or_field=serializers.ListField) def get_users(self, obj): return [u.username for u in obj.users.all()] diff --git a/netbox/users/views.py b/netbox/users/views.py index f83ed4d10a8..4af273d2928 100644 --- a/netbox/users/views.py +++ b/netbox/users/views.py @@ -39,12 +39,12 @@ class LoginView(View): def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) - def gen_auth_data(self, name, url): + def gen_auth_data(self, name, url, params): display_name, icon_name = get_auth_backend_display(name) return { 'display_name': display_name, 'icon_name': icon_name, - 'url': url, + 'url': f'{url}?{urlencode(params)}', } def get(self, request): @@ -58,15 +58,18 @@ def get(self, request): saml_idps = get_saml_idps() for name in load_backends(settings.AUTHENTICATION_BACKENDS).keys(): url = reverse('social:begin', args=[name, ]) + params = {} + next = request.GET.get('next') + if next: + params['next'] = next if name.lower() == 'saml' and saml_idps: for idp in saml_idps: - params = {'idp': idp} - idp_url = f'{url}?{urlencode(params)}' - data = self.gen_auth_data(name, idp_url) + params['idp'] = idp + data = self.gen_auth_data(name, url, params) data['display_name'] = f'{data["display_name"]} ({idp})' auth_backends.append(data) else: - auth_backends.append(self.gen_auth_data(name, url)) + auth_backends.append(self.gen_auth_data(name, url, params)) return render(request, self.template_name, { 'form': form, diff --git a/netbox/utilities/custom_inspectors.py b/netbox/utilities/custom_inspectors.py index 1a5ede23f8c..258399e86da 100644 --- a/netbox/utilities/custom_inspectors.py +++ b/netbox/utilities/custom_inspectors.py @@ -1,4 +1,3 @@ -from django.contrib.postgres.fields import JSONField from drf_yasg import openapi from drf_yasg.inspectors import FieldInspector, NotHandled, PaginatorInspector, SwaggerAutoSchema from drf_yasg.utils import get_serializer_ref_name @@ -131,15 +130,6 @@ def field_to_swagger_object(self, field, swagger_object_type, use_references, ** return NotHandled -class JSONFieldInspector(FieldInspector): - """Required because by default, Swagger sees a JSONField as a string and not dict - """ - def process_result(self, result, method_name, obj, **kwargs): - if isinstance(result, openapi.Schema) and isinstance(obj, JSONField): - result.type = 'dict' - return result - - class NullablePaginatorInspector(PaginatorInspector): def process_result(self, result, method_name, obj, **kwargs): if method_name == 'get_paginated_response' and isinstance(result, openapi.Schema): diff --git a/netbox/utilities/forms/widgets.py b/netbox/utilities/forms/widgets.py index c27f3c64647..76a4bc607fe 100644 --- a/netbox/utilities/forms/widgets.py +++ b/netbox/utilities/forms/widgets.py @@ -110,6 +110,12 @@ class SelectSpeedWidget(forms.NumberInput): class NumericArrayField(SimpleArrayField): + def clean(self, value): + if value and not self.to_python(value): + raise forms.ValidationError(f'Invalid list ({value}). ' + f'Must be numeric and ranges must be in ascending order') + return super().clean(value) + def to_python(self, value): if not value: return [] diff --git a/netbox/utilities/templates/form_helpers/render_custom_fields.html b/netbox/utilities/templates/form_helpers/render_custom_fields.html index 6b0b2840b99..c59607fcf11 100644 --- a/netbox/utilities/templates/form_helpers/render_custom_fields.html +++ b/netbox/utilities/templates/form_helpers/render_custom_fields.html @@ -7,6 +7,10 @@
{{ group }}
{% endif %} {% for name in fields %} - {% render_field form|getfield:name %} + {% if name in form.nullable_fields %} + {% render_field form|getfield:name bulk_nullable=True %} + {% else %} + {% render_field form|getfield:name %} + {% endif %} {% endfor %} {% endfor %} diff --git a/netbox/virtualization/api/serializers.py b/netbox/virtualization/api/serializers.py index 903d89a070f..b88bc771228 100644 --- a/netbox/virtualization/api/serializers.py +++ b/netbox/virtualization/api/serializers.py @@ -100,7 +100,7 @@ class Meta(VirtualMachineSerializer.Meta): 'tags', 'custom_fields', 'config_context', 'created', 'last_updated', ] - @swagger_serializer_method(serializer_or_field=serializers.DictField) + @swagger_serializer_method(serializer_or_field=serializers.JSONField) def get_config_context(self, obj): return obj.get_config_context() diff --git a/netbox/virtualization/forms/models.py b/netbox/virtualization/forms/models.py index 723c193323f..fca9c6b56b1 100644 --- a/netbox/virtualization/forms/models.py +++ b/netbox/virtualization/forms/models.py @@ -323,6 +323,14 @@ class VMInterfaceForm(InterfaceCommonForm, NetBoxModelForm): label='VRF' ) + fieldsets = ( + ('Interface', ('virtual_machine', 'name', 'description', 'tags')), + ('Addressing', ('vrf', 'mac_address')), + ('Operation', ('mtu', 'enabled')), + ('Related Interfaces', ('parent', 'bridge')), + ('802.1Q Switching', ('mode', 'vlan_group', 'untagged_vlan', 'tagged_vlans')), + ) + class Meta: model = VMInterface fields = [ diff --git a/netbox/virtualization/models.py b/netbox/virtualization/models.py index b8131c1ce2e..abad57f888a 100644 --- a/netbox/virtualization/models.py +++ b/netbox/virtualization/models.py @@ -368,9 +368,14 @@ def clean(self): # Validate primary IP addresses interfaces = self.interfaces.all() - for field in ['primary_ip4', 'primary_ip6']: + for family in (4, 6): + field = f'primary_ip{family}' ip = getattr(self, field) if ip is not None: + if ip.address.version != family: + raise ValidationError({ + field: f"Must be an IPv{family} address. ({ip} is an IPv{ip.address.version} address.)", + }) if ip.assigned_object in interfaces: pass elif ip.nat_inside is not None and ip.nat_inside.assigned_object in interfaces: diff --git a/netbox/virtualization/tables/virtualmachines.py b/netbox/virtualization/tables/virtualmachines.py index 22238a1b64f..dfd01696e9c 100644 --- a/netbox/virtualization/tables/virtualmachines.py +++ b/netbox/virtualization/tables/virtualmachines.py @@ -12,7 +12,7 @@ ) VMINTERFACE_BUTTONS = """ -{% if perms.virtualization.edit_vminterface %} +{% if perms.virtualization.change_vminterface %}