Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 8f93f4c0 authored by Simon BLONDIEAU's avatar Simon BLONDIEAU
Browse files

Transferred netbox training to dev/netbox-training-workspace

parent 8f257d3b
Branches main
No related tags found
No related merge requests found
Pipeline #141948 failed
Showing
with 1 addition and 697 deletions
[submodule "nbox/netbox-core"]
path = nbox/netbox-core
url = https://github.com/netbox-community/netbox.git
[submodule "nbox/netbox-plugin-demo"]
path = nbox/netbox-plugin-demo
url = https://github.com/netbox-community/netbox-plugin-demo.git
...@@ -9,6 +9,6 @@ Your lab VM must have been initialized first using [this procedure](https://code ...@@ -9,6 +9,6 @@ Your lab VM must have been initialized first using [this procedure](https://code
## Recommended order of completion ## Recommended order of completion
1. [Git](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/git?ref_type=heads) 1. [Git](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/git?ref_type=heads)
2. [GitLab](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/gitlab?ref_type=heads) 2. [GitLab](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/gitlab?ref_type=heads)
3. [Netbox](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/nbox?ref_type=heads) 3. [Netbox](https://code.europa.eu/digit-c4/dev/netbox-training-workspace)
4. [Smithy](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/smithy?ref_type=heads) 4. [Smithy](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/smithy?ref_type=heads)
5. [Optic](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/optic?ref_type=heads) 5. [Optic](https://code.europa.eu/digit-c4/dev/onboarding/-/tree/main/optic?ref_type=heads)
postgresql/
redis/
Dockerfile
.env
.vscode
venv
netbox.env
*.egg-info
*.pyc
*.pyo
__pycache__/
*.so
*.pyd
.DS_Store
Thumbs.db
*~
*.swp
build/
dist/
# Netbox - Onboarding Guide
> Netbox is an open-source Python web application designed to ease the management of IT assets (routers, racks, VM, phones, etc.)
It comes with a series of built-in modules to handle standard items but can also be extended using plugins.
There is an [official Netbox Plugin tutorial](https://github.com/netbox-community/netbox-plugin-tutorial/blob/main/tutorial/step01-initial-setup.md)
> to experience how additional feature can be implemented.
> But it requires to go through a [painful installation process](https://docs.netbox.dev/en/stable/installation/), involving the local deployment of databases (PostgreSQL and Redis).
> Instead, this repo provides and extra framework around the official tutorial to ease the onboarding, thanks to submodules and docker deployment of dependencies.
## Understand the architecture of Netbox
Netbox core is a Django (Python) web application (API+GUI).
It has a series of dependencies, including default plugins that are always active (example: the module for IP address management.)
Those dependencies are listed in the Netbox core [`requirement.txt`](netbox-core/requirements.txt) and must be installed before any execution.
```shell
# Example of dependencies installation
pip install requirements.txt
# Example checkup of installed dependencies
pip list
```
After the installation of mandatory dependencies, Netbox is started thanks to
the execution of a provided (and obscure) python script called "manage.py".
```shell
# Example of manage.py execution, using python
python manage.py runserver
```
Later, additional optional plugins may be developed and integrated. The development looks like the creation of any standalone Python package.
It then must be
* installed within the python (virtual) environment of Netbox core. Or netbox core will not be able to find it
```shell
# Execute the setup script of the custom new plugin
python setup.py develop
# And make sure it is listed with the other dependencies / default plugins
pip list
```
* explicitly listed into Netbox core configuration file. Or Netbox core doesn't know it has to be loaded
```python
# edit netbox core configuration.py
PLUGINS = ["my-new-plugin"]
```
* Netbox restarted
```shell
# execute once again
python manage.py runserver
```
## What to do if you get stuck?
If you're stuck while doing the official tutorial, you can compare your code with mine in the ```nbox/netbox-plugin-demo-solution``` directory of this repository.
## Instructions
### Step 0: Pre-requisites
Your lab VM must have been initialized first using [this procedure](https://code.europa.eu/digit-c4/dev/ansible-collection/-/tree/main/example?ref_type=heads#dev-vm-initialization).
And the project is initialized according to [Best practices](https://code.europa.eu/digit-c4/dev/best-practices)
```bash
cd ~/Workspace/code.europa.eu/digit-c4/dev # Create this path using mkdir -p ~/Workspace/code.europa.eu/digit-c4/dev if it does not exists
git clone https://code.europa.eu/digit-c4/dev/onboarding.git
cd onboarding
git submodule update --init --recursive
```
> ⚠️WARNING⚠️
>
> **All the remaining instructions are executed from the [`nbox` directory found in the onboarding folder](./).**
The first step is therefore to move here, and to create a new virtual environment according to [python best practices]((https://code.europa.eu/digit-c4/dev/best-practices))
```bash
cd nbox
python -m venv venv && source venv/bin/activate
```
Finally, comes the time to install and run Netbox application. This is simplified in few lines instead of pages of instructions found in the official install guide
```bash
# Quick start the databases
docker compose up -d && docker compose ps
# Provide Netbox core with the settings to connec to the local Docker databases
cp configuration.py netbox-core/netbox/netbox/configuration.py
# Install Netbox core Python dependencies
pip install -r netbox-core/requirements.txt
# Run the Netbox core init procedure
python netbox-core/netbox/manage.py migrate
python netbox-core/netbox/manage.py createsuperuser
# Run the Netbox application
python netbox-core/netbox/manage.py runserver 0.0.0.0:8000 --insecure
```
You're now ready to go through the [official Netbox plugin tutorial](https://github.com/netbox-community/netbox-plugin-tutorial/blob/main/tutorial/step01-initial-setup.md).
### Step 0.5: Important notes before going through the official tutorial
* The complex official init procedure will keep the Netbox Python virtual environment in `/opt/netbox/venv`. Activation is therefore documented as follow:
```bash
source /opt/netbox/venv/bin/activate
```
Instead, it must be activated thanks to
```bash
source venv/bin/activate
```
* The Netbox install path is the `netbox-core` directory in the project root.
The Netbox configuration file is therefore located in
`./netbox-core/netbox/netbox/configuration.py`
* All the plugin paths of the tutorial must be adapted, relative to the `netbox-plugin-demo` folder in the project root. Example: the `netbox_access_lists/__init__.py`
actually corresponds to `netbox-plugin-demo/netbox_access_lists/__init__.py`
```
- [project root]
| - netbox-core [netbox install path]
| - netbox-plugin-demo [tutorial reference point]
```
### Step 1: Initial Setup
The https://github.com/netbox-community/netbox-plugin-demo repo has already been initialized for you, as
git submodule in the ```onboarding/nbox/netbox-plugin-demo``` directory.
You can therefore directly move there and jump to the [Plugin Configuration](https://github.com/netbox-community/netbox-plugin-tutorial/blob/main/tutorial/step01-initial-setup.md#plugin-configuration) section
```bash
cd onboarding/nbox/netbox-plugin-demo
# Hide all solutions by checking out this branch
git checkout step00-empty
mkdir netbox_access_lists
touch netbox_access_lists/__init__.py
# Now continue with the official tutorial
```
> Also, you need to **RESTART** the `manage.py runserver` command for the change in the plugin to be interpreted.
### Step 2 to 11:
Just follow the official tutorial. When you want to see your changes in action, refer to step 5.2 of this guide to re-install a newer version of the plugin.
## TODO
| :exclamation: TODO |
|:---------------------------|
| Find a way to include demo data |
#########################
# #
# Required settings #
# #
#########################
# This is a list of valid fully-qualified domain names (FQDNs) for the NetBox server. NetBox will not permit write
# access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name.
#
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
ALLOWED_HOSTS = ['*']
# PostgreSQL database configuration. See the Django documentation for a complete list of available parameters:
# https://docs.djangoproject.com/en/stable/ref/settings/#databases
DATABASE = {
"ENGINE": "django.db.backends.postgresql", # Database engine
"NAME": "netbox", # Database name
"USER": "username", # PostgreSQL username
"PASSWORD": "password", # PostgreSQL password
"HOST": "localhost", # Database server
"PORT": "", # Database port (leave blank for default)
"CONN_MAX_AGE": 300, # Max database connection age
}
# Redis database settings. Redis is used for caching and for queuing background tasks such as webhook events. A separate
# configuration exists for each. Full connection details are required in both sections, and it is strongly recommended
# to use two separate database IDs.
REDIS = {
"tasks": {
"HOST": "localhost",
"PORT": 6379,
# Comment out `HOST` and `PORT` lines and uncomment the following if using Redis Sentinel
# 'SENTINELS': [('mysentinel.redis.example.com', 6379)],
# 'SENTINEL_SERVICE': 'netbox',
"USERNAME": "",
"PASSWORD": "password",
"DATABASE": 0,
"SSL": False,
# Set this to True to skip TLS certificate verification
# This can expose the connection to attacks, be careful
# 'INSECURE_SKIP_TLS_VERIFY': False,
# Set a path to a certificate authority, typically used with a self signed certificate.
# 'CA_CERT_PATH': '/etc/ssl/certs/ca.crt',
},
"caching": {
"HOST": "localhost",
"PORT": 6379,
# Comment out `HOST` and `PORT` lines and uncomment the following if using Redis Sentinel
# 'SENTINELS': [('mysentinel.redis.example.com', 6379)],
# 'SENTINEL_SERVICE': 'netbox',
"USERNAME": "",
"PASSWORD": "password",
"DATABASE": 1,
"SSL": False,
# Set this to True to skip TLS certificate verification
# This can expose the connection to attacks, be careful
# 'INSECURE_SKIP_TLS_VERIFY': False,
# Set a path to a certificate authority, typically used with a self signed certificate.
# 'CA_CERT_PATH': '/etc/ssl/certs/ca.crt',
},
}
# This key is used for secure generation of random numbers and strings. It must never be exposed outside of this file.
# For optimal security, SECRET_KEY should be at least 50 characters in length and contain a mix of letters, numbers, and
# symbols. NetBox will not run without this defined. For more information, see
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-SECRET_KEY
SECRET_KEY = "z%31Sh(rjERLiZQ#NF7yq6TgvRzGC2G=QtyQVWr4T($uONhLGO"
#########################
# #
# Optional settings #
# #
#########################
# Specify one or more name and email address tuples representing NetBox administrators. These people will be notified of
# application errors (assuming correct email settings are provided).
ADMINS = [
# ('John Doe', 'jdoe@example.com'),
]
# Permit the retrieval of API tokens after their creation.
ALLOW_TOKEN_RETRIEVAL = False
# Enable any desired validators for local account passwords below. For a list of included validators, please see the
# Django documentation at https://docs.djangoproject.com/en/stable/topics/auth/passwords/#password-validation.
AUTH_PASSWORD_VALIDATORS = [
# {
# 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
# 'OPTIONS': {
# 'min_length': 10,
# }
# },
]
# Base URL path if accessing NetBox within a directory. For example, if installed at https://example.com/netbox/, set:
# BASE_PATH = 'netbox/'
BASE_PATH = ""
# API Cross-Origin Resource Sharing (CORS) settings. If CORS_ORIGIN_ALLOW_ALL is set to True, all origins will be
# allowed. Otherwise, define a list of allowed origins using either CORS_ORIGIN_WHITELIST or
# CORS_ORIGIN_REGEX_WHITELIST. For more information, see https://github.com/ottoyiu/django-cors-headers
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = [
# 'https://hostname.example.com',
]
CORS_ORIGIN_REGEX_WHITELIST = [
# r'^(https?://)?(\w+\.)?example\.com$',
]
# The name to use for the CSRF token cookie.
CSRF_COOKIE_NAME = "csrftoken"
# Set to True to enable server debugging. WARNING: Debugging introduces a substantial performance penalty and may reveal
# sensitive information about your installation. Only enable debugging while performing testing. Never enable debugging
# on a production system.
DEBUG = True
# Set the default preferred language/locale
DEFAULT_LANGUAGE = "en-us"
# Email settings
EMAIL = {
"SERVER": "localhost",
"PORT": 25,
"USERNAME": "",
"PASSWORD": "",
"USE_SSL": False,
"USE_TLS": False,
"TIMEOUT": 10, # seconds
"FROM_EMAIL": "",
}
# Localization
ENABLE_LOCALIZATION = False
# Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and
# by anonymous users. List models in the form `<app>.<model>`. Add '*' to this list to exempt all models.
EXEMPT_VIEW_PERMISSIONS = [
# 'dcim.site',
# 'dcim.region',
# 'ipam.prefix',
]
# HTTP proxies NetBox should use when sending outbound HTTP requests (e.g. for webhooks).
# HTTP_PROXIES = {
# 'http': 'http://10.10.1.10:3128',
# 'https': 'http://10.10.1.10:1080',
# }
# IP addresses recognized as internal to the system. The debugging toolbar will be available only to clients accessing
# NetBox from an internal IP.
INTERNAL_IPS = ("127.0.0.1", "::1")
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
# https://docs.djangoproject.com/en/stable/topics/logging/
LOGGING = {}
# Automatically reset the lifetime of a valid session upon each authenticated request. Enables users to remain
# authenticated to NetBox indefinitely.
LOGIN_PERSISTENCE = False
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
# are permitted to access most data in NetBox but not make any changes.
LOGIN_REQUIRED = False
# The length of time (in seconds) for which a user will remain logged into the web UI before being prompted to
# re-authenticate. (Default: 1209600 [14 days])
LOGIN_TIMEOUT = None
# The view name or URL to which users are redirected after logging out.
LOGOUT_REDIRECT_URL = "home"
# The file path where uploaded media such as image attachments are stored. A trailing slash is not needed. Note that
# the default value of this setting is derived from the installed location.
# MEDIA_ROOT = '/opt/netbox/netbox/media'
# Expose Prometheus monitoring metrics at the HTTP endpoint '/metrics'
METRICS_ENABLED = False
# Enable installed plugins. Add the name of each plugin to the list.
PLUGINS = []
# Plugins configuration settings. These settings are used by various plugins that the user may have installed.
# Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings.
# PLUGINS_CONFIG = {
# 'my_plugin': {
# 'foo': 'bar',
# 'buzz': 'bazz'
# }
# }
# Remote authentication support
REMOTE_AUTH_ENABLED = False
REMOTE_AUTH_BACKEND = "netbox.authentication.RemoteUserBackend"
REMOTE_AUTH_HEADER = "HTTP_REMOTE_USER"
REMOTE_AUTH_USER_FIRST_NAME = "HTTP_REMOTE_USER_FIRST_NAME"
REMOTE_AUTH_USER_LAST_NAME = "HTTP_REMOTE_USER_LAST_NAME"
REMOTE_AUTH_USER_EMAIL = "HTTP_REMOTE_USER_EMAIL"
REMOTE_AUTH_AUTO_CREATE_USER = True
REMOTE_AUTH_DEFAULT_GROUPS = []
REMOTE_AUTH_DEFAULT_PERMISSIONS = {}
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the
# version check or use the URL below to check for release in the official NetBox repository.
RELEASE_CHECK_URL = None
# RELEASE_CHECK_URL = 'https://api.github.com/repos/netbox-community/netbox/releases'
# The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of
# this setting is derived from the installed location.
# REPORTS_ROOT = '/opt/netbox/netbox/reports'
# Maximum execution time for background tasks, in seconds.
RQ_DEFAULT_TIMEOUT = 300
# The file path where custom scripts will be stored. A trailing slash is not needed. Note that the default value of
# this setting is derived from the installed location.
# SCRIPTS_ROOT = '/opt/netbox/netbox/scripts'
# The name to use for the session cookie.
SESSION_COOKIE_NAME = "sessionid"
# By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use
# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only
# database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
SESSION_FILE_PATH = None
# By default, uploaded media is stored on the local filesystem. Using Django-storages is also supported. Provide the
# class path of the storage driver in STORAGE_BACKEND and any configuration options in STORAGE_CONFIG. For example:
# STORAGE_BACKEND = 'storages.backends.s3boto3.S3Boto3Storage'
# STORAGE_CONFIG = {
# 'AWS_ACCESS_KEY_ID': 'Key ID',
# 'AWS_SECRET_ACCESS_KEY': 'Secret',
# 'AWS_STORAGE_BUCKET_NAME': 'netbox',
# 'AWS_S3_REGION_NAME': 'eu-west-1',
# }
# Time zone (default: UTC)
TIME_ZONE = "UTC"
# Date/time formatting. See the following link for supported formats:
# https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
DATE_FORMAT = "N j, Y"
SHORT_DATE_FORMAT = "Y-m-d"
TIME_FORMAT = "g:i a"
SHORT_TIME_FORMAT = "H:i:s"
DATETIME_FORMAT = "N j, Y g:i a"
SHORT_DATETIME_FORMAT = "Y-m-d H:i"
DEVELOPER = True
version: '3.4'
services:
postgres:
image: postgres:15-alpine
container_name: postgres
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: username
POSTGRES_DB: netbox
volumes:
- ./postgresql/seed/:/docker-entrypoint-initdb.d
- ./postgresql/data:/var/lib/postgresql/data
ports:
- 5432:5432
adminer:
image: adminer
container_name: adminer
ports:
- 8080:8080
redis:
image: redis:7-alpine
container_name: redis
environment:
REDIS_PASSWORD: password
command:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
- redis-server --appendonly yes --requirepass "$$REDIS_PASSWORD" # $$ is because of Docker
volumes:
- ./redis/data/:/data
ports:
- 6379:6379
redisinsight:
image: redislabs/redisinsight:latest
container_name: redisinsight
ports:
- 8001:8001
Subproject commit ba755221bbfb167352312e988c518fba3414bbbf
Subproject commit 4cab0c9f8d2f5852f205fa2f33edcc0a8ef7710f
## netbox-access-lists
Manage simple access control lists in NetBox
from extras.plugins import PluginConfig
class NetBoxAccessListsConfig(PluginConfig):
name = 'netbox_access_lists'
verbose_name = ' NetBox Access Lists'
description = 'Manage simple ACLs in NetBox'
version = '0.1'
base_url = 'access-lists'
config = NetBoxAccessListsConfig
from rest_framework import serializers
from netbox.api.serializers import NetBoxModelSerializer, WritableNestedSerializer
from ipam.api.serializers import NestedPrefixSerializer
from ..models import AccessList, AccessListRule
class NestedAccessListSerializer(WritableNestedSerializer):
url = serializers.HyperlinkedIdentityField(
view_name='plugins-api:netbox_access_lists-api:accesslist-detail'
)
class Meta:
model = AccessList
fields = ('id', 'url', 'display', 'name')
class NestedAccessListRuleSerializer(WritableNestedSerializer):
url = serializers.HyperlinkedIdentityField(
view_name='plugins-api:netbox_access_lists-api:accesslistrule-detail'
)
class Meta:
model = AccessListRule
fields = ('id', 'url', 'display', 'index')
class AccessListSerializer(NetBoxModelSerializer):
url = serializers.HyperlinkedIdentityField(
view_name='plugins-api:netbox_access_lists-api:accesslist-detail'
)
rule_count = serializers.IntegerField(read_only=True)
class Meta:
model = AccessList
fields = (
'id', 'url', 'display', 'name', 'default_action', 'comments', 'tags', 'rule_count',
'custom_fields', 'created', 'last_updated',
)
class AccessListRuleSerializer(NetBoxModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='plugins-api:netbox_access_lists-api:accesslistrule-detail')
access_list = NestedAccessListSerializer()
source_prefix = NestedPrefixSerializer()
destination_prefix = NestedPrefixSerializer()
class Meta:
model = AccessListRule
fields = (
'id', 'url', 'display', 'access_list', 'index', 'protocol', 'source_prefix', 'source_ports',
'destination_prefix', 'destination_ports', 'action', 'tags', 'custom_fields', 'created',
'last_updated',
)
from netbox.api.routers import NetBoxRouter
from . import views
app_name = 'netbox_access_list'
router = NetBoxRouter()
router.register('access-lists', views.AccessListViewSet)
router.register('access-list-rules', views.AccessListRuleViewSet)
urlpatterns = router.urls
from django.db.models import Count
from netbox.api.viewsets import NetBoxModelViewSet
from .. import filtersets, models
from .serializers import AccessListSerializer, AccessListRuleSerializer
class AccessListViewSet(NetBoxModelViewSet):
queryset = models.AccessList.objects.prefetch_related('tags').annotate(
rule_count=Count('rules')
)
serializer_class = AccessListSerializer
class AccessListRuleViewSet(NetBoxModelViewSet):
queryset = models.AccessListRule.objects.prefetch_related(
'access_list', 'source_prefix', 'destination_prefix', 'tags'
)
serializer_class = AccessListRuleSerializer
filterset_class = filtersets.AccessListRuleFilterSet
from netbox.filtersets import NetBoxModelFilterSet
from .models import AccessListRule
class AccessListRuleFilterSet(NetBoxModelFilterSet):
class Meta:
model = AccessListRule
fields = ('id', 'access_list', 'index', 'protocol', 'action')
def search(self, queryset, name, value):
return queryset.filter(description__icontains=value)
from django import forms
from ipam.models import Prefix
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm
from utilities.forms.fields import CommentField, DynamicModelChoiceField
from .models import AccessList, AccessListRule, ActionChoices, ProtocolChoices
class AccessListForm(NetBoxModelForm):
comments = CommentField()
class Meta:
model = AccessList
fields = ('name', 'default_action', 'comments', 'tags')
class AccessListRuleForm(NetBoxModelForm):
access_list = DynamicModelChoiceField(
queryset=AccessList.objects.all()
)
source_prefix = DynamicModelChoiceField(
queryset=Prefix.objects.all()
)
destination_prefix = DynamicModelChoiceField(
queryset=Prefix.objects.all()
)
class Meta:
model = AccessListRule
fields = (
'access_list', 'index', 'description', 'source_prefix', 'source_ports', 'destination_prefix',
'destination_ports', 'protocol', 'action', 'tags',
)
class AccessListRuleFilterForm(NetBoxModelFilterSetForm):
model = AccessListRule
# TODO: use Netbox DynamicModelChoiceField instead of forms.ModelMultipleChoiceField when step 9 is done
access_list = forms.ModelMultipleChoiceField(
queryset=AccessList.objects.all(),
required=False
)
index = forms.IntegerField(
required=False
)
protocol = forms.MultipleChoiceField(
choices=ProtocolChoices,
required=False
)
action = forms.MultipleChoiceField(
choices=ActionChoices,
required=False
)
from graphene import ObjectType
from netbox.graphql.types import NetBoxObjectType
from netbox.graphql.fields import ObjectField, ObjectListField
from . import filtersets, models
class AccessListType(NetBoxObjectType):
class Meta:
model = models.AccessList
fields = '__all__'
class AccessListRuleType(NetBoxObjectType):
class Meta:
model = models.AccessListRule
fields = '__all__'
filterset_class = filtersets.AccessListRuleFilterSet
class Query(ObjectType):
access_list = ObjectField(AccessListType)
access_list_list = ObjectListField(AccessListType)
access_list_rule = ObjectField(AccessListRuleType)
access_list_rule_list = ObjectListField(AccessListRuleType)
schema = Query
# Generated by Django 4.1.5 on 2023-12-05 14:17
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import utilities.json
class Migration(migrations.Migration):
initial = True
dependencies = [
('extras', '0084_staging'),
('ipam', '0063_standardize_description_comments'),
]
operations = [
migrations.CreateModel(
name='AccessList',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True, null=True)),
('last_updated', models.DateTimeField(auto_now=True, null=True)),
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
('name', models.CharField(max_length=100)),
('default_action', models.CharField(max_length=30)),
('comments', models.TextField(blank=True)),
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
],
options={
'ordering': ('name',),
},
),
migrations.CreateModel(
name='AccessListRule',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
('created', models.DateTimeField(auto_now_add=True, null=True)),
('last_updated', models.DateTimeField(auto_now=True, null=True)),
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
('index', models.PositiveIntegerField()),
('protocol', models.CharField(blank=True, max_length=30)),
('source_ports', django.contrib.postgres.fields.ArrayField(base_field=models.PositiveIntegerField(), blank=True, null=True, size=None)),
('destination_ports', django.contrib.postgres.fields.ArrayField(base_field=models.PositiveIntegerField(), blank=True, null=True, size=None)),
('action', models.CharField(max_length=30)),
('description', models.CharField(blank=True, max_length=500)),
('access_list', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rules', to='netbox_access_lists.accesslist')),
('destination_prefix', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='ipam.prefix')),
('source_prefix', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='ipam.prefix')),
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
],
options={
'ordering': ('access_list', 'index'),
'unique_together': {('access_list', 'index')},
},
),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment