Skip to content

Commit 00022e7

Browse files
authored
Merge pull request #331 from netbox-community/develop
Develop
2 parents e9a9d9b + dd49060 commit 00022e7

File tree

9 files changed

+35
-17
lines changed

9 files changed

+35
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.netbox
33
.initializers
44
docker-compose.override.yml
5+
*.pem

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Before opening an issue on Github, please join the [Network To Code][ntc-slack]
3333

3434
Then there is currently one extra tags for each of the above tags:
3535

36-
* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directroy.
36+
* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directory.
3737
[Learn more about that in our wiki][netbox-docker-ldap].
3838

3939
New images are built and published automatically every ~24h.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.24.1
1+
0.25.0

configuration/configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ def read_secret(secret_name):
150150
# are permitted to access most data in NetBox (excluding secrets) but not make any changes.
151151
LOGIN_REQUIRED = os.environ.get('LOGIN_REQUIRED', 'False').lower() == 'true'
152152

153+
# The length of time (in seconds) for which a user will remain logged into the web UI before being prompted to
154+
# re-authenticate. (Default: 1209600 [14 days])
155+
LOGIN_TIMEOUT = os.environ.get('LOGIN_TIMEOUT', None)
156+
153157
# Setting this to True will display a "maintenance mode" banner at the top of every page.
154158
MAINTENANCE_MODE = os.environ.get('MAINTENANCE_MODE', 'False').lower() == 'true'
155159

docker/nginx.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ http {
2929
proxy_pass http://netbox:8001;
3030
proxy_set_header X-Forwarded-Host $http_host;
3131
proxy_set_header X-Real-IP $remote_addr;
32-
proxy_set_header X-Forwarded-Proto $scheme;
3332
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
3433
}
3534
}

startup_scripts/000_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if not User.objects.filter(username=username):
1313
user = User.objects.create_user(
1414
username = username,
15-
password = user_details.get('password', 0) or User.objects.make_random_password)
15+
password = user_details.get('password', 0) or User.objects.make_random_password())
1616

1717
print("👤 Created user",username)
1818

startup_scripts/240_virtualization_interfaces.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from dcim.models import Interface
2-
from virtualization.models import VirtualMachine
1+
from virtualization.models import VirtualMachine, VMInterface
32
from extras.models import CustomField, CustomFieldValue
43
from startup_script_utils import load_yaml
54
import sys
@@ -22,7 +21,7 @@
2221

2322
params[assoc] = model.objects.get(**query)
2423

25-
interface, created = Interface.objects.get_or_create(**params)
24+
interface, created = VMInterface.objects.get_or_create(**params)
2625

2726
if created:
2827
if custom_fields is not None:

startup_scripts/260_ip_addresses.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
from ipam.models import IPAddress, VRF
1+
import sys
2+
23
from dcim.models import Device, Interface
3-
from virtualization.models import VirtualMachine
4-
from tenancy.models import Tenant
4+
from django.contrib.contenttypes.models import ContentType
5+
from django.db.models import Q
56
from extras.models import CustomField, CustomFieldValue
6-
7+
from ipam.models import VRF, IPAddress
78
from netaddr import IPNetwork
89
from startup_script_utils import load_yaml
9-
import sys
10+
from tenancy.models import Tenant
11+
from virtualization.models import VirtualMachine, VMInterface
1012

1113
ip_addresses = load_yaml('/opt/netbox/initializers/ip_addresses.yml')
1214

@@ -16,9 +18,12 @@
1618
optional_assocs = {
1719
'tenant': (Tenant, 'name'),
1820
'vrf': (VRF, 'name'),
19-
'interface': (Interface, 'name')
21+
'interface': (None, None)
2022
}
2123

24+
vm_interface_ct = ContentType.objects.filter(Q(app_label='virtualization', model='vminterface')).first()
25+
interface_ct = ContentType.objects.filter(Q(app_label='dcim', model='interface')).first()
26+
2227
for params in ip_addresses:
2328
vm = params.pop('virtual_machine', None)
2429
device = params.pop('device', None)
@@ -35,13 +40,17 @@
3540
if assoc == 'interface':
3641
if vm:
3742
vm_id = VirtualMachine.objects.get(name=vm).id
38-
query = { field: params.pop(assoc), "virtual_machine_id": vm_id }
43+
query = { 'name': params.pop(assoc), "virtual_machine_id": vm_id }
44+
params['assigned_object_type'] = vm_interface_ct
45+
params['assigned_object_id'] = VMInterface.objects.get(**query).id
3946
elif device:
4047
dev_id = Device.objects.get(name=device).id
41-
query = { field: params.pop(assoc), "device_id": dev_id }
48+
query = { 'name': params.pop(assoc), "device_id": dev_id }
49+
params['assigned_object_type'] = interface_ct
50+
params['assigned_object_id'] = Interface.objects.get(**query).id
4251
else:
4352
query = { field: params.pop(assoc) }
44-
params[assoc] = model.objects.get(**query)
53+
params[assoc] = model.objects.get(**query)
4554

4655
ip_address, created = IPAddress.objects.get_or_create(**params)
4756

startup_scripts/__main__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ def filename(f):
1111

1212
with scandir(dirname(abspath(__file__))) as it:
1313
for f in sorted(it, key = filename):
14-
if f.name.startswith('__') or not f.is_file():
14+
if not f.is_file():
15+
continue
16+
17+
if f.name.startswith('__'):
18+
continue
19+
20+
if not f.name.endswith('.py'):
1521
continue
1622

1723
print(f"▶️ Running the startup script {f.path}")

0 commit comments

Comments
 (0)