Skip to content

Commit 8e0402c

Browse files
committed
Hook to cleanup baremetal network agents
In the uni04delta-ipv6 jobs Tobiko tests are validating all network agents are UP/Alive. When ironic tempest runs, there are network agents created for fake Ironic nodes. We need to clean up by deleting the baremetal agents after tempest execution. This change add's a hook running a shell script that will delete all network agents of type `baremetal`. Jira: OSPRH-20084
1 parent 35b1d61 commit 8e0402c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- name: Delete neutron network agents for Baremetal Nodes
3+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4+
gather_facts: false
5+
vars:
6+
_namespace: openstack
7+
environment:
8+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
9+
PATH: "{{ cifmw_path }}"
10+
tasks:
11+
- name: Delete baremetal network agents
12+
ansible.builtin.shell: |
13+
set -xe -o pipefail
14+
oc project {{ _namespace }}
15+
16+
echo "Discovering baremetal network agents..."
17+
18+
# Get all baremetal network agent IDs using JSON format
19+
AGENT_IDS=$(oc rsh openstackclient \
20+
openstack network agent list --agent-type baremetal -f json -c ID | \
21+
jq -r '.[].ID')
22+
23+
if [ -n "$AGENT_IDS" ]; then
24+
echo "Found baremetal network agents:"
25+
echo "$AGENT_IDS"
26+
27+
# Delete each baremetal agent
28+
for AGENT_ID in $AGENT_IDS; do
29+
echo "Deleting baremetal network agent: $AGENT_ID"
30+
oc rsh openstackclient openstack network agent delete "$AGENT_ID"
31+
done
32+
33+
echo "Baremetal network agent cleanup completed"
34+
else
35+
echo "No baremetal network agents found"
36+
fi

0 commit comments

Comments
 (0)