Skip to content

Commit be0e4a2

Browse files
committed
fixes issue when device interface has no ip adress
1 parent f4532f6 commit be0e4a2

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ REDIS_HOST=redis
1515
REDIS_PASSWORD=notverysecurepwd
1616
REDIS_PORT=6379
1717
SKIP_SUPERUSER=false
18-
SECRET_KEY=r8d793usj&!dci#P9ghsdfsdfsdlsos9s8s
18+
SECRET_KEY=ObqltrK3fLC2yG6raIosrgu97G5ftMcZofyfXXnAUikCG0cTZ1
1919
SUPERUSER_EMAIL=[email protected]
2020
SUPERUSER_NAME=admin
2121
SUPERUSER_PASSWORD=admin

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM netboxcommunity/netbox:v3.5.8
1+
FROM netboxcommunity/netbox:v3.5.9
22

33
RUN pip install --upgrade pip\
44
&& pip install poetry

netbox_atlas_plugin/api/serializers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,19 @@ def get_targets(vm, target):
100100
interfaces = []
101101
if hasattr(vm, "interfaces") and vm.interfaces is not None:
102102
result = vm.interfaces.filter(mgmt_only=True)
103-
interfaces = map(lambda i: str(IPNetwork(i.ip_addresses.first().address).ip), result)
103+
interfaces = map(get_address, result)
104104
return interfaces
105105
elif target == "loopback10":
106106
interfaces = []
107107
if hasattr(vm, "interfaces") and vm.interfaces is not None:
108108
result = vm.interfaces.filter(name='Loopback10')
109-
interfaces = map(lambda i: str(IPNetwork(i.ip_addresses.first().address).ip), result)
109+
interfaces = map(get_address, result)
110110
return interfaces
111111
else:
112112
if hasattr(vm, "primary_ip") and vm.primary_ip is not None:
113113
return [str(IPNetwork(vm.primary_ip.address).ip)]
114+
115+
116+
def get_address(interface):
117+
if len(interface.ip_addresses.all()) > 0:
118+
return str(IPNetwork(interface.ip_addresses.first().address).ip)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "netbox-atlas-plugin"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
description = "A Netbox plugin to provide a Prometheus service discovery api"
55
authors = ["Stefan Hipfel <[email protected]>"]
66
license = "Apache-2.0"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='netbox_atlas_plugin',
10-
version='0.1.0',
10+
version='1.0.2',
1111
description='A Prometheus SD API plugin for Netbox.',
1212
long_description=long_description,
1313
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)