0536
This commit is contained in:
@@ -23,6 +23,7 @@ NB_TOKEN="${NB_TOKEN:-}"
|
|||||||
# --- Optional performance knobs ---
|
# --- Optional performance knobs ---
|
||||||
# NB_PREREAD=1 enables extra GETs to print pre-change values (more load on NetBox).
|
# NB_PREREAD=1 enables extra GETs to print pre-change values (more load on NetBox).
|
||||||
NB_PREREAD="${NB_PREREAD:-0}"
|
NB_PREREAD="${NB_PREREAD:-0}"
|
||||||
|
USE_TAGS="${USE_TAGS:-yes}"
|
||||||
|
|
||||||
# Device ID cache (per worker process)
|
# Device ID cache (per worker process)
|
||||||
# Cache entries are considered fresh for 60 minutes. After that, they may be used up to an
|
# Cache entries are considered fresh for 60 minutes. After that, they may be used up to an
|
||||||
@@ -544,6 +545,9 @@ handle_payload() {
|
|||||||
;;
|
;;
|
||||||
tag_add)
|
tag_add)
|
||||||
# add a tag to the device using task_result as slug
|
# add a tag to the device using task_result as slug
|
||||||
|
if [[ "$USE_TAGS" != "yes" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
if [[ -z "$task_result" ]]; then
|
if [[ -z "$task_result" ]]; then
|
||||||
warn "tag_add: task_result (tag slug) is empty; skipping."
|
warn "tag_add: task_result (tag slug) is empty; skipping."
|
||||||
return 0
|
return 0
|
||||||
@@ -555,15 +559,19 @@ handle_payload() {
|
|||||||
;;
|
;;
|
||||||
update_cleanup_success)
|
update_cleanup_success)
|
||||||
# cleanup after successful update
|
# cleanup after successful update
|
||||||
|
if [[ "$USE_TAGS" == "yes" ]]; then
|
||||||
nb_remove_tag_by_slug "$dev_id" "update-in-progress" || true
|
nb_remove_tag_by_slug "$dev_id" "update-in-progress" || true
|
||||||
nb_remove_tag_by_slug "$dev_id" "update-auto-restarted" || true
|
nb_remove_tag_by_slug "$dev_id" "update-auto-restarted" || true
|
||||||
nb_add_tag_by_slug "$dev_id" "update-successful" || true
|
nb_add_tag_by_slug "$dev_id" "update-successful" || true
|
||||||
|
fi
|
||||||
nb_clear_update_progress "$dev_id" || true
|
nb_clear_update_progress "$dev_id" || true
|
||||||
|
|
||||||
echo ">>> Device '$device' (id=$dev_id) cleanup done:"
|
echo ">>> Device '$device' (id=$dev_id) cleanup done:"
|
||||||
|
if [[ "$USE_TAGS" == "yes" ]]; then
|
||||||
echo " - tag removed: update-in-progress"
|
echo " - tag removed: update-in-progress"
|
||||||
echo " - tag removed: update-auto-restarted"
|
echo " - tag removed: update-auto-restarted"
|
||||||
echo " - tag added: update-successful"
|
echo " - tag added: update-successful"
|
||||||
|
fi
|
||||||
echo " - custom field cleared: update_progress"
|
echo " - custom field cleared: update_progress"
|
||||||
;;
|
;;
|
||||||
custom_field_set)
|
custom_field_set)
|
||||||
@@ -580,6 +588,9 @@ handle_payload() {
|
|||||||
;;
|
;;
|
||||||
tag_remove)
|
tag_remove)
|
||||||
# remove a tag from the device using task_result as slug
|
# remove a tag from the device using task_result as slug
|
||||||
|
if [[ "$USE_TAGS" != "yes" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
if [[ -z "$task_result" ]]; then
|
if [[ -z "$task_result" ]]; then
|
||||||
warn "tag_remove: task_result (tag slug) is empty; skipping."
|
warn "tag_remove: task_result (tag slug) is empty; skipping."
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user