We have many racks of servers of three types. One type is our storage cluster using weka. All of the hostnames begin with weka. The other two are compute and GPU nodes. Both start with a common string. Next is 'r' followed by the rack number. For the compute nodes a '-c' followed by the compute node number in that rack. Both types are then followed by a '-n' followed by the node number in the rack. I'm an API call to weka which brings back all three types. I want to be able to filter based on type. I can get the weka and compute nodes, but can't quite get the GPU nodes. I have:
# for Weka nodes:
curl --insecure --silent --header "authorization: Bearer ${ATKN}" --request GET https://weka01:14000/api/v2/processes | jq -r '.data[] | select(.hostname | startswith("weka"))'
#
# for compute nodes:
curl --insecure --silent --header "authorization: Bearer ${ATKN}" --request GET https://weka01:14000/api/v2/processes | jq -r '.data[] | select(.hostname | startswith("startstring") and contains("-c"))"
For the GPU nodes, I tried:
curl --insecure --silent --header "authorization: Bearer ${ATKN}" --request GET https://weka01:14000/api/v2/processes | jq -r '.data[] | select(.hostname | startswith("startstring") and contains("-c")|not)'
which gets me both the GPU and weka nodes. Anyone know what I am doing wrong? Just for clarification, the GPU node hostnames look like:
startstring-r1-n3
The compute nodes hostnames look like:
startstring-r2-c17-n2
Operator precedence:
select(.hostname | startswith("startstring") and (contains("-c")|not))
Without the parentheses, the filter would be parsed as:
select(.hostname | (startswith("startstring") and contains("-c")) | not)