Skip to content

Commit

Permalink
check if nb is live
Browse files Browse the repository at this point in the history
  • Loading branch information
ITJamie committed Aug 22, 2022
1 parent 98379fb commit 77bc43d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ jobs:
- run: |
set -x
cd development
sleep 200
docker-compose exec -T rt2nb_runner /opt/repo/development/rt2nb_runner_run_migration.sh
20 changes: 20 additions & 0 deletions development/check_if_nb_api_up.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3

from time import sleep
import requests
import os

max_timeout = 300
nb_not_up = True
api_url = "http://netbox:8000/api"
while nb_not_up:
try:
response = requests.get(api_url)
if "circuits" in response.json():
nb_not_up = False
except:
print("did not get a repsonse yet")

if nb_not_up:
print("netbox not yet up. sleeping for 10s and trying again")
sleep(10)
2 changes: 2 additions & 0 deletions development/rt2nb_runner_run_migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
pip3 install -r /opt/repo/requirements.txt

cd /opt/repo/

python3 development/check_if_nb_api_up.py
python3 rt2nb/racktables2netbox.py

0 comments on commit 77bc43d

Please sign in to comment.