From ccad15ecf78c572e5b5240fcd69d100eb78ce26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=A4der?= Date: Tue, 2 Jun 2020 13:37:57 +0200 Subject: [PATCH 1/9] Don't try to run non-python files --- startup_scripts/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/startup_scripts/__main__.py b/startup_scripts/__main__.py index 343ca95..c41bba6 100644 --- a/startup_scripts/__main__.py +++ b/startup_scripts/__main__.py @@ -11,7 +11,13 @@ def filename(f): with scandir(dirname(abspath(__file__))) as it: for f in sorted(it, key = filename): - if f.name.startswith('__') or not f.is_file(): + if not f.is_file(): + continue + + if f.name.startswith('__'): + continue + + if not f.name.endswith('.py'): continue print(f"▶️ Running the startup script {f.path}") From 5624ecc65eeeffc0f2cbed5aa99a3155e3c143db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=A4der?= Date: Tue, 2 Jun 2020 16:06:52 +0200 Subject: [PATCH 2/9] Remove the 'X-Forwarded-Proto' line from the nginx config The reason is that in the default configuration nginx is only serving 'http' traffic. So if an upstream proxy sets the 'X-Forwarded-Proto' header, because it is terminating TLS, then nginx will overwrite it to 'http'. This will cause django to think the page is served via 'http' and it will not create 'https://...' URLs. Related to #292 --- .gitignore | 1 + docker/nginx.conf | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 97aa1b3..3389e7a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .netbox .initializers docker-compose.override.yml +*.pem diff --git a/docker/nginx.conf b/docker/nginx.conf index 3b78a9f..edbd927 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -29,7 +29,6 @@ http { proxy_pass http://netbox:8001; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } From 51490d00397966c4b91ba9a693d607eee3f0bd72 Mon Sep 17 00:00:00 2001 From: John G <42597062+jgcasd@users.noreply.github.com> Date: Tue, 16 Jun 2020 11:27:59 -0700 Subject: [PATCH 3/9] Added LOGIN_TIMEOUT option to configuration.py Added LOGIN_TIMEOUT option to configuration.py. The option is already available in standard Netbox configuration. --- configuration/configuration.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configuration/configuration.py b/configuration/configuration.py index 84bb6ae..404b6a0 100644 --- a/configuration/configuration.py +++ b/configuration/configuration.py @@ -150,6 +150,10 @@ LOGGING = {} # are permitted to access most data in NetBox (excluding secrets) but not make any changes. LOGIN_REQUIRED = os.environ.get('LOGIN_REQUIRED', 'False').lower() == 'true' +# 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 = os.environ.get('LOGIN_TIMEOUT', None) + # Setting this to True will display a "maintenance mode" banner at the top of every page. MAINTENANCE_MODE = os.environ.get('MAINTENANCE_MODE', 'False').lower() == 'true' From 3f9e874d77cf494a6be48c5a593dbb40b42300ec Mon Sep 17 00:00:00 2001 From: Jamie Reid Date: Tue, 14 Jul 2020 11:19:49 +1000 Subject: [PATCH 4/9] Update README.md fix spelling mistake --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 375eb36..25c1286 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Before opening an issue on Github, please join the [Network To Code][ntc-slack] Then there is currently one extra tags for each of the above tags: -* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directroy. +* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directory. [Learn more about that in our wiki][netbox-docker-ldap]. New images are built and published automatically every ~24h. From 9fae2b0f74875d2c484b00def192554255c9c360 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Mon, 24 Aug 2020 11:04:06 +0200 Subject: [PATCH 5/9] Fixed VM interface creation for Netbox 2.9 --- startup_scripts/240_virtualization_interfaces.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/startup_scripts/240_virtualization_interfaces.py b/startup_scripts/240_virtualization_interfaces.py index e5d75f7..f04f30b 100644 --- a/startup_scripts/240_virtualization_interfaces.py +++ b/startup_scripts/240_virtualization_interfaces.py @@ -1,5 +1,4 @@ -from dcim.models import Interface -from virtualization.models import VirtualMachine +from virtualization.models import VirtualMachine, VMInterface from extras.models import CustomField, CustomFieldValue from startup_script_utils import load_yaml import sys @@ -22,7 +21,7 @@ for params in interfaces: params[assoc] = model.objects.get(**query) - interface, created = Interface.objects.get_or_create(**params) + interface, created = VMInterface.objects.get_or_create(**params) if created: if custom_fields is not None: From 3ace32dfc2bccfb13104a0ec67ac479d38d165b2 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Mon, 24 Aug 2020 11:00:48 +0200 Subject: [PATCH 6/9] Fixed creation of passwords for Netbox 2.9 --- startup_scripts/000_users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup_scripts/000_users.py b/startup_scripts/000_users.py index 6605424..a801d85 100644 --- a/startup_scripts/000_users.py +++ b/startup_scripts/000_users.py @@ -12,7 +12,7 @@ for username, user_details in users.items(): if not User.objects.filter(username=username): user = User.objects.create_user( username = username, - password = user_details.get('password', 0) or User.objects.make_random_password) + password = user_details.get('password', 0) or User.objects.make_random_password()) print("👤 Created user",username) From b02a93904e03ec48b40d6dc4b25cfd6fcebe8a84 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Mon, 24 Aug 2020 14:20:35 +0200 Subject: [PATCH 7/9] Fixed IP address creation for Netbox 2.9 --- startup_scripts/260_ip_addresses.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/startup_scripts/260_ip_addresses.py b/startup_scripts/260_ip_addresses.py index 96ec4b0..7d164fd 100644 --- a/startup_scripts/260_ip_addresses.py +++ b/startup_scripts/260_ip_addresses.py @@ -1,12 +1,14 @@ -from ipam.models import IPAddress, VRF -from dcim.models import Device, Interface -from virtualization.models import VirtualMachine -from tenancy.models import Tenant -from extras.models import CustomField, CustomFieldValue +import sys +from dcim.models import Device, Interface +from django.contrib.contenttypes.models import ContentType +from django.db.models import Q +from extras.models import CustomField, CustomFieldValue +from ipam.models import VRF, IPAddress from netaddr import IPNetwork from startup_script_utils import load_yaml -import sys +from tenancy.models import Tenant +from virtualization.models import VirtualMachine, VMInterface ip_addresses = load_yaml('/opt/netbox/initializers/ip_addresses.yml') @@ -16,9 +18,12 @@ if ip_addresses is None: optional_assocs = { 'tenant': (Tenant, 'name'), 'vrf': (VRF, 'name'), - 'interface': (Interface, 'name') + 'interface': (None, None) } +vm_interface_ct = ContentType.objects.filter(Q(app_label='virtualization', model='vminterface')).first() +interface_ct = ContentType.objects.filter(Q(app_label='dcim', model='interface')).first() + for params in ip_addresses: vm = params.pop('virtual_machine', None) device = params.pop('device', None) @@ -35,13 +40,17 @@ for params in ip_addresses: if assoc == 'interface': if vm: vm_id = VirtualMachine.objects.get(name=vm).id - query = { field: params.pop(assoc), "virtual_machine_id": vm_id } + query = { 'name': params.pop(assoc), "virtual_machine_id": vm_id } + params['assigned_object_type'] = vm_interface_ct + params['assigned_object_id'] = VMInterface.objects.get(**query).id elif device: dev_id = Device.objects.get(name=device).id - query = { field: params.pop(assoc), "device_id": dev_id } + query = { 'name': params.pop(assoc), "device_id": dev_id } + params['assigned_object_type'] = interface_ct + params['assigned_object_id'] = Interface.objects.get(**query).id else: query = { field: params.pop(assoc) } - params[assoc] = model.objects.get(**query) + params[assoc] = model.objects.get(**query) ip_address, created = IPAddress.objects.get_or_create(**params) From f174749f982c53e688f4593c8676bdfdff870b1a Mon Sep 17 00:00:00 2001 From: tdorsey Date: Sun, 30 Aug 2020 22:06:20 -0400 Subject: [PATCH 8/9] chore: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 375eb36..25c1286 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Before opening an issue on Github, please join the [Network To Code][ntc-slack] Then there is currently one extra tags for each of the above tags: -* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directroy. +* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directory. [Learn more about that in our wiki][netbox-docker-ldap]. New images are built and published automatically every ~24h. From dd490605ca8ba48ce1ff3fa6ec1ee95620416de0 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Tue, 1 Sep 2020 10:40:16 +0200 Subject: [PATCH 9/9] Preparation for 0.25.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 48b91fd..d21d277 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.24.1 +0.25.0