refactor: replace hand-rolled credential and polling logic with shared helpers (#904)

- atlanticnet: replace 54-line ensure_atlanticnet_credentials with
  ensure_multi_credentials (env var -> config file -> prompt -> validate -> save)
- ramnode: replace 35-line _ramnode_wait_for_ip polling loop with
  generic_wait_for_instance

Agent: complexity-hunter

Co-authored-by: A <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
A 2026-02-13 05:08:28 -08:00 committed by GitHub
parent fba986abea
commit a982bce29c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 86 deletions

View file

@ -277,42 +277,14 @@ print(json.dumps(body))
" "$@"
}
# Poll the RamNode API until the server has an IPv4 address
# Wait for RamNode instance to become ACTIVE and get its IP
# Sets RAMNODE_SERVER_IP on success
_ramnode_wait_for_ip() {
log_step "Waiting for IP address..."
local max_attempts=30
local attempt=0
while [[ $attempt -lt $max_attempts ]]; do
sleep 2
local server_info
server_info=$(ramnode_compute_api GET "/servers/$RAMNODE_SERVER_ID")
RAMNODE_SERVER_IP=$(echo "$server_info" | python3 -c "
import json, sys
data = json.loads(sys.stdin.read())
addresses = data.get('server', {}).get('addresses', {})
for net_name, addrs in addresses.items():
for addr in addrs:
if addr.get('version') == 4:
print(addr['addr'])
sys.exit(0)
" 2>/dev/null || echo "")
if [[ -n "$RAMNODE_SERVER_IP" ]]; then
export RAMNODE_SERVER_IP
log_info "IP address assigned: $RAMNODE_SERVER_IP"
return 0
fi
attempt=$((attempt + 1))
if [[ $((attempt % 5)) -eq 0 ]]; then
log_step "Still waiting for IP address... (attempt ${attempt}/${max_attempts})"
fi
done
log_error "Timeout waiting for IP address after ${max_attempts} attempts"
return 1
INSTANCE_STATUS_POLL_DELAY=2 generic_wait_for_instance ramnode_compute_api \
"/servers/$RAMNODE_SERVER_ID" "ACTIVE" \
"d['server']['status']" \
"next(addr['addr'] for addrs in d['server']['addresses'].values() for addr in addrs if addr.get('version')==4)" \
RAMNODE_SERVER_IP "RamNode instance" 30
}
# Parse server ID from create response, or log error and return 1