- for port in "${os_ports[@]}"; do
- echo "Removing orphaned port $port"
- openstack --os-cloud "$os_cloud" port delete "$port"
+ cutoff=$(date -d "30 minutes ago" +%s)
+ for port_ts in "${os_ports_ts[@]}"; do
+ created_at_isots="${port_ts#* }"
+ port_uuid="${port_ts% *}"
+ echo "checking port uuid: ${port_uuid} with TS: ${created_at_isots}"
+ created_at_uxts=$(date -d "${created_at_isots}" +"%s")
+ # Clean up ports where created_at > 30 minutes
+ if [[ "$created_at_uxts" -gt "$cutoff" ]]; then
+ echo "Removing orphaned port $port_uuid created_at ts > 30 minutes."
+ openstack --os-cloud "$os_cloud" port delete "$port_uuid"
+ fi