Upgrade to 1.5.2, tooling for VPN API requests

This commit is contained in:
Quentin WEPHRE
2024-07-19 08:59:28 +02:00
parent 5819418f7c
commit 1a383c5302
25 changed files with 2026 additions and 1835 deletions

View File

@@ -1,23 +1,23 @@
#!/bin/bash
# Get all devices from an IoT Hub (iothub_name) that have the given tag (tag_key == tag_value)
# Can also filter using tags.number
# Execute an Azure command for each of the devices found
# Here the command will execute a Direct Method for the ThingsPro module on the devices.
iothub_name="IotHub-CUBE-Prod"
tag_key="site"
tag_value="DANISH"
json_output=$(az iot hub query --hub-name $iothub_name --query-command "SELECT * FROM devices WHERE tags.$tag_key = '$tag_value' AND (tags.number = '6' OR tags.number = '8' OR tags.number = '12' OR tags.number = '13') AND capabilities.iotEdge = true" --output json)
hashmap=$(echo "$json_output" | jq -r 'map({key: .tags.number, value: .deviceId}) | from_entries')
for key in $(echo "$hashmap" | jq -r 'keys | map(tonumber) | sort_by(.) | .[]'); do
value=$(jq -r --arg k "$key" '.[$k]' <<< "$hashmap")
status=$(az iot hub invoke-module-method --timeout 10 --method-name thingspro-api-v1 --method-payload '{"method":"GET","path":"/device/general"}' --device-id $value --module-id thingspro-agent --hub-name $iothub_name | jq .status)
echo "Key: $key, Value: $value, Status: $status"
done
#echo $hashmap
#!/bin/bash
# Get all devices from an IoT Hub (iothub_name) that have the given tag (tag_key == tag_value)
# Can also filter using tags.number
# Execute an Azure command for each of the devices found
# Here the command will execute a Direct Method for the ThingsPro module on the devices.
iothub_name="IotHub-CUBE-Prod"
tag_key="site"
tag_value="DANISH"
json_output=$(az iot hub query --hub-name $iothub_name --query-command "SELECT * FROM devices WHERE tags.$tag_key = '$tag_value' AND (tags.number = '6' OR tags.number = '8' OR tags.number = '12' OR tags.number = '13') AND capabilities.iotEdge = true" --output json)
hashmap=$(echo "$json_output" | jq -r 'map({key: .tags.number, value: .deviceId}) | from_entries')
for key in $(echo "$hashmap" | jq -r 'keys | map(tonumber) | sort_by(.) | .[]'); do
value=$(jq -r --arg k "$key" '.[$k]' <<< "$hashmap")
status=$(az iot hub invoke-module-method --timeout 10 --method-name thingspro-api-v1 --method-payload '{"method":"GET","path":"/device/general"}' --device-id $value --module-id thingspro-agent --hub-name $iothub_name | jq .status)
echo "Key: $key, Value: $value, Status: $status"
done
#echo $hashmap