-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly adding interface with IP address to Devices (Nodes)
- Loading branch information
1 parent
c3ac6d8
commit 792f8c7
Showing
4 changed files
with
226 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from netboxlabs.diode.sdk import DiodeClient | ||
from netboxlabs.diode.sdk.ingester import ( | ||
Device, | ||
Entity, | ||
IPAddress, | ||
) | ||
|
||
|
||
def main(): | ||
with DiodeClient( | ||
target="grpc://localhost:8081", | ||
app_name="my-test-app", | ||
app_version="0.0.1", | ||
api_key="5a52c45ee8231156cb620d193b0291912dd15433", | ||
) as client: | ||
entities = [] | ||
|
||
""" | ||
Ingest device with device type, platform, manufacturer, site, role, and tags. | ||
""" | ||
|
||
|
||
device = Device( | ||
name="TESTE", | ||
device_type="Device Type A", | ||
platform="Platform A", | ||
manufacturer="Manufacturer A", | ||
site="Site ABC", | ||
role="Role ABC", | ||
serial="123456", | ||
asset_tag="123456", | ||
status="active", | ||
tags=["tag 1", "tag 2"], | ||
) | ||
|
||
|
||
#device = Device(name="Device A") | ||
|
||
ip_address = IPAddress( | ||
address="172.16.0.1/24", | ||
) | ||
|
||
print(f"device: {device}") | ||
|
||
#print(f"client: {client}") | ||
#print(f"client (dir): {dir(client)}") | ||
#print(f"client (version): {client._target}") | ||
#print(f"ip_address: {ip_address}") | ||
entities.append(Entity(ip_address=ip_address)) | ||
#entities.append(Entity(ip_address=ip_address)) | ||
|
||
response = client.ingest(entities=entities) | ||
print(f"response: {response}") | ||
if response.errors: | ||
print(f"Errors: {response.errors}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: ${PROJECT_NAME:-diode} | ||
services: | ||
ingress-nginx: | ||
image: nginx:latest | ||
command: > | ||
/bin/sh -c "echo 'upstream diode { | ||
server diode-ingester:8081; | ||
} | ||
server { | ||
listen 80; | ||
http2 on; | ||
server_name localhost; | ||
client_max_body_size 25m; | ||
location /diode { | ||
rewrite /diode/(.*) /$$1 break; | ||
grpc_pass grpc://diode; | ||
} | ||
}' | ||
> /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" | ||
restart: always | ||
environment: | ||
- DIODE_NGINX_PORT=${DIODE_NGINX_PORT} | ||
ports: | ||
- ${DIODE_NGINX_PORT}:80 | ||
depends_on: | ||
- diode-ingester | ||
- diode-reconciler | ||
|
||
diode-ingester: | ||
image: netboxlabs/diode-ingester:${DIODE_TAG:-latest} | ||
environment: | ||
- API_KEY=${RECONCILER_API_KEY} | ||
- REDIS_PASSWORD=${REDIS_PASSWORD} | ||
- REDIS_HOST=${REDIS_HOST} | ||
- REDIS_PORT=${REDIS_PORT} | ||
- RECONCILER_GRPC_HOST=${RECONCILER_GRPC_HOST} | ||
- RECONCILER_GRPC_PORT=${RECONCILER_GRPC_PORT} | ||
- SENTRY_DSN=${SENTRY_DSN} | ||
restart: always | ||
ports: | ||
- "8081:8081" | ||
depends_on: | ||
- diode-redis | ||
- diode-reconciler | ||
|
||
diode-reconciler: | ||
image: netboxlabs/diode-reconciler:${DIODE_TAG:-latest} | ||
environment: | ||
- REDIS_PASSWORD=${REDIS_PASSWORD} | ||
- REDIS_HOST=${REDIS_HOST} | ||
- REDIS_PORT=${REDIS_PORT} | ||
- NETBOX_DIODE_PLUGIN_API_BASE_URL=${NETBOX_DIODE_PLUGIN_API_BASE_URL} | ||
- DIODE_TO_NETBOX_API_KEY=${DIODE_TO_NETBOX_API_KEY} | ||
- NETBOX_TO_DIODE_API_KEY=${NETBOX_TO_DIODE_API_KEY} | ||
- DIODE_API_KEY=${DIODE_API_KEY} | ||
- LOGGING_LEVEL=${LOGGING_LEVEL} | ||
- SENTRY_DSN=${SENTRY_DSN} | ||
restart: always | ||
ports: [ ] | ||
depends_on: | ||
- diode-redis | ||
diode-redis: | ||
image: redis/redis-stack-server:latest | ||
command: | ||
- sh | ||
- -c | ||
- redis-server --appendonly yes --dir /data --save 60 1 --requirepass $$REDIS_PASSWORD --loadmodule /opt/redis-stack/lib/rejson.so --loadmodule /opt/redis-stack/lib/redisearch.so --port $$REDIS_PORT | ||
environment: | ||
- REDIS_PASSWORD=${REDIS_PASSWORD} | ||
- REDIS_PORT=${REDIS_PORT} | ||
ports: [ ] | ||
volumes: | ||
- diode-redis-data:/data | ||
diode-redis-cli: | ||
image: redis/redis-stack-server:latest | ||
links: | ||
- diode-redis | ||
entrypoint: | ||
- sh | ||
- -c | ||
- | | ||
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -a "$REDIS_PASSWORD" <<EOF | ||
FT.CREATE ingest-entity ON JSON PREFIX 1 "ingest-entity:" SCHEMA \ | ||
$.data_type AS data_type TEXT \ | ||
$.state AS state NUMERIC \ | ||
$.request_id AS request_id TEXT \ | ||
$.ingestion_ts AS ingestion_ts NUMERIC SORTABLE | ||
EOF | ||
volumes: | ||
diode-redis-data: | ||
driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters