Skip to content

Commit

Permalink
Merge pull request #5 from ITJamie/ci_testing2
Browse files Browse the repository at this point in the history
added ci testing
  • Loading branch information
ITJamie authored Sep 18, 2022
2 parents 0f8ea1f + 1324765 commit dbe2997
Show file tree
Hide file tree
Showing 31 changed files with 345 additions and 34 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push

name: ci

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: docker-practice/actions-setup-docker@master
- uses: actions/checkout@v3
- run: |
set -x
docker version
ls -lah
cd development
docker-compose up -d
sleep 5
docker-compose up -d
- run: |
set -x
cd development
docker-compose exec -T rt2nb_runner /opt/repo/development/rt2nb_runner_run_migration.sh
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ cp hardware_map.yaml.sample hardware_map.yaml
5. Create a new Pull Request

## Credits
Thanks to [Device42](https://www.device42.com/) who have already written a [RackTables to Device42 migration utility](https://github.com/device42/Racktables-to-Device42-Migration). I was able to use it as a starting point and begin to rewrite it step by step towards NetBox.
Thanks to [Device42](https://www.device42.com/) who have already written a [RackTables to Device42 migration utility](https://github.com/device42/Racktables-to-Device42-Migration). @goebelmeier was able to use it as a starting point to make this migration script.
I (ITJamie) forked it and added more data migrations

## License
racktables2netbox is licensed under MIT license. See [LICENSE.md](LICENSE.md) for more information.
racktables2netbox is licensed under MIT license. See [LICENSE.md](LICENSE.md) for more information.
20 changes: 10 additions & 10 deletions conf.testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ NetBox:
NETBOX_HOST: http://netbox:8080
#:===== Data to Migrate:======== #
Migrate:
TAGS: False
CUSTOM_ATTRIBUTES: False
TAGS: True
CUSTOM_ATTRIBUTES: True
INFRA: True
VLAN: False
SUBNETS: False
IPS: False
HARDWARE: False
PATCHPANELS: False
PDUS: False
VMS: False
FILES: False
VLAN: True
SUBNETS: True
IPS: True
HARDWARE: True
PATCHPANELS: True
PDUS: True
VMS: True
FILES: True
#:===== Other settings:======== #
Misc:
FILE_SEARCH_URI: https://company_name.sharepoint.com/sites/company_name/Shared%20Documents/Shared/folder-name/rt_export/
Expand Down
6 changes: 6 additions & 0 deletions custom_device_templates/generic/generic_0u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
manufacturer: Generic
model: generic_0u_device
slug: generic_0u_device
u_height: 0
is_full_depth: false
12 changes: 12 additions & 0 deletions custom_device_templates/generic/generic_0u_patch_panel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
manufacturer: Generic
model: generic_0u_patch_panel
slug: generic_0u_patch_panel
u_height: 0
is_full_depth: false
subdevice_role: parent
device-bays:
- name: '01'
- name: '02'
- name: '03'
- name: '04'
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_10u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_10u_device
slug: generic_10u_device
u_height: 10
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_12u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_12u_device
slug: generic_12u_device
u_height: 12
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_18u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_18u_device
slug: generic_18u_device
u_height: 18
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_1u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_1u_device
slug: generic_1u_device
u_height: 1
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
12 changes: 12 additions & 0 deletions custom_device_templates/generic/generic_1u_patch_panel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
manufacturer: Generic
model: generic_1u_patch_panel
slug: generic_1u_patch_panel
u_height: 1
is_full_depth: false
subdevice_role: parent
device-bays:
- name: '01'
- name: '02'
- name: '03'
- name: '04'
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_1u_short_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_1u_short_device
slug: generic_1u_short_device
u_height: 1
is_full_depth: false
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_22u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_22u_device
slug: generic_22u_device
u_height: 22
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_23u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_23u_device
slug: generic_23u_device
u_height: 23
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_24u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_24u_device
slug: generic_24u_device
u_height: 24
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_2u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_2u_device
slug: generic_2u_device
u_height: 2
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_2u_short_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_2u_short_device
slug: generic_2u_short_device
u_height: 2
is_full_depth: false
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_3u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_3u_device
slug: generic_3u_device
u_height: 3
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_3u_short_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_3u_short_device
slug: generic_3u_short_device
u_height: 3
is_full_depth: false
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_46u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_46u_device
slug: generic_46u_device
u_height: 46
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_48u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_48u_device
slug: generic_48u_device
u_height: 48
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_4u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_4u_device
slug: generic_4u_device
u_height: 4
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_4u_short_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_4u_short_device
slug: generic_4u_short_device
u_height: 4
is_full_depth: false
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_5u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_5u_device
slug: generic_5u_device
u_height: 5
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_6u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_6u_device
slug: generic_6u_device
u_height: 6
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_8u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_8u_device
slug: generic_8u_device
u_height: 8
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
11 changes: 11 additions & 0 deletions custom_device_templates/generic/generic_9u_device.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
manufacturer: Generic
model: generic_9u_device
slug: generic_9u_device
u_height: 9
is_full_depth: true
power-ports:
- name: Power 1
type: iec-60320-c14
- name: Power 2
type: iec-60320-c14
27 changes: 27 additions & 0 deletions development/check_if_nb_api_up.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

from time import sleep
import requests
import os

nb_not_up = True
api_url = "http://netbox:8080/api"
max_timeout_attempts = 20
current_attempts = 0
while nb_not_up:
try:
response = requests.get(api_url)
print(f"status_code: {response.status_code}")
if "circuits" in response.text:
print("'circuits' in response. nb is up!")
nb_not_up = False
exit(0)
except:
print("did not get a repsonse yet")
if not current_attempts < max_timeout_attempts:
print("max attempts reached. dying")
exit(2)
if nb_not_up:
print("netbox not yet up. sleeping for 10s and trying again")
current_attempts = current_attempts + 1
sleep(10)
2 changes: 1 addition & 1 deletion development/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
x-docker-data: &netbox-docker-info
image: netboxcommunity/netbox:${VERSION-v3.1-1.5.1}
image: netboxcommunity/netbox:v3.2
restart: on-failure
depends_on:
- postgres
Expand Down
2 changes: 1 addition & 1 deletion development/rt2nb_runner_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip3 install -r /opt/repo/requirements.txt
# pip3 install -r /opt/repo/requirements.txt
tail -f /dev/null
8 changes: 8 additions & 0 deletions development/rt2nb_runner_run_migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -x
pip3 install -r /opt/repo/requirements.txt

cd /opt/repo/

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

0 comments on commit dbe2997

Please sign in to comment.