Add support for Netbox API parameter

This commit is contained in:
Igor Pecovnik
2025-11-20 05:57:23 +01:00
parent 10dec95fd4
commit bfc2600592

View File

@@ -29,6 +29,9 @@ inputs:
netbox:
description: NetboxID
required: true
netboxapi:
description: NetboxAPI
required: true
runs:
using: "composite"
@@ -80,10 +83,10 @@ runs:
for server_id in ${{ inputs.failoverserver }}; do
unset REGION LATITUDE LONGITUDE PHYSICAL TIME_ZONE UPLOAD
# read virtual machine
COMMAND=$(curl -sH "Authorization: Token ${{ inputs.netbox }}" -H "Accept: application/json; indent=4" "https://stuff.armbian.com/netbox/api/virtualization/virtual-machines/${server_id}/" | jq)
COMMAND=$(curl -sH "Authorization: Token ${{ inputs.netbox }}" -H "Accept: application/json; indent=4" "${{ inputs.netboxapi }}/api/virtualization/virtual-machines/${server_id}/" | jq)
IFS=',' read -r SITE_ID NAME DL_PATH_DEBS DL_PATH_IMAGES WEIGHT <<<$(echo $COMMAND | jq '.site.id,.name,.custom_fields["download_path_debs"],.custom_fields["download_path_images"],.custom_fields["weight"]' | sed 's/$/,/' | xargs | sed 's/, /,/g')
# site data
COMMAND=$(curl -sH "Authorization: Token ${{ inputs.netbox }}" -H "Accept: application/json; indent=4" "https://stuff.armbian.com/netbox/api/dcim/sites/${SITE_ID}/" | jq)
COMMAND=$(curl -sH "Authorization: Token ${{ inputs.netbox }}" -H "Accept: application/json; indent=4" "${{ inputs.netboxapi }}/api/dcim/sites/${SITE_ID}/" | jq)
IFS=',' read REGION LATITUDE LONGITUDE PHYSICAL TIME_ZONE UPLOAD DOWNLOAD_EXCLUDE <<<$(echo $COMMAND | jq -r '.region.name,.latitude,.longitude,.physical_address,.time_zone,.custom_fields["upload_speed"],.custom_fields["download_exclude"]' | sed 's/$/,/' | xargs | sed 's/, /,/g')
echo "" >> dlrouter-${FILENAME}.yaml