Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize go message consumer + netbox connection #5

Open
wants to merge 85 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
a62f67f
feat: init base go api
romain-neil Jun 30, 2024
8ae142e
feat: extract message model
romain-neil Jul 2, 2024
3f5401f
feat: do not continue if error when decoding json
romain-neil Jul 2, 2024
b1aaf29
refactor: reorder imports
romain-neil Jul 2, 2024
b0ced71
feat: import netbox go library
romain-neil Jul 2, 2024
85eccd3
feat: logging util
romain-neil Jul 2, 2024
95b3ad2
refactor: use existing function to show error
romain-neil Jul 2, 2024
e70623e
feat: add color module
romain-neil Jul 2, 2024
927c58e
remove old code
romain-neil Jul 4, 2024
7fd5dc9
feat: base netbox connector
romain-neil Jul 4, 2024
de466ef
refactor: use our own logger
romain-neil Jul 4, 2024
87300b7
wip: init netbox connection
romain-neil Jul 4, 2024
18550fb
feat: ignore ide files
romain-neil Jul 4, 2024
51e6764
feat: include machine serial inside message
romain-neil Jul 25, 2024
594822a
feat: add packages
romain-neil Jul 25, 2024
8c0544d
feat: show message when fail to handle vm creation/update
romain-neil Jul 25, 2024
0d1ba46
feat: function to update vm
romain-neil Jul 25, 2024
519bab4
feat: create vm if not existing in memory
romain-neil Jul 25, 2024
1bd79e9
refactor: use list for existing vm
romain-neil Jul 25, 2024
3edd927
feat: function to get vm boilerplate
romain-neil Jul 25, 2024
9859149
fix: creation of vm
romain-neil Jul 25, 2024
968304f
feat: function to create vm
romain-neil Jul 25, 2024
ce8d56c
refactor: use extracted functions
romain-neil Jul 25, 2024
5b66f8d
refactor: use netbox vm custom field prefix
romain-neil Jul 25, 2024
9a5601c
refactor: do not update the vm if we created him just before
romain-neil Jul 25, 2024
f6285a4
refactor: simplify code
romain-neil Jul 25, 2024
99cf6ea
feat: add docker compose file
romain-neil Jul 27, 2024
43c9acd
feat: base docker conf
romain-neil Jul 27, 2024
f87505b
fix: attach functions to go object
romain-neil Jul 27, 2024
1bce5d7
refactor: use standard error formatting
romain-neil Jul 28, 2024
8679d2e
refactor: use queue name from env
romain-neil Jul 28, 2024
c3dd1b6
feat: add ttl to message
romain-neil Jul 28, 2024
6b2126c
refactor: rework machine serial compute
romain-neil Jul 28, 2024
c5f7738
refactor: remove old code
romain-neil Jul 28, 2024
8a6be40
refactor: update code to use api v3
romain-neil Jul 28, 2024
33b78fe
refactor: remove old code
romain-neil Jul 28, 2024
742dd4f
refactor: handle case of address already exists in netbox
romain-neil Jul 28, 2024
7296efd
refactor: correct compare of request payload count
romain-neil Jul 28, 2024
e2c9f4c
wip: handle update of vm management ip changes
romain-neil Jul 28, 2024
1efc75c
feat: build go project on ci
romain-neil Jul 31, 2024
7859523
feat: upload build
romain-neil Jul 31, 2024
e8a5b76
feat: set build output file
romain-neil Jul 31, 2024
a012f4d
Revert "feat: set build output file"
romain-neil Jul 31, 2024
b265829
Update go.yml
itzwam Aug 10, 2024
242f674
Update go.yml
itzwam Aug 10, 2024
741b815
refactor: add timeout
romain-neil Aug 10, 2024
23e7612
feat: add timeout when fetching machines list
romain-neil Aug 10, 2024
8b87978
refactor: correct comparisons
romain-neil Aug 10, 2024
1025a58
Update netbox.go
itzwam Aug 10, 2024
eb0725f
wip: update interface ip
romain-neil Aug 10, 2024
a1d6d94
Fixes
Aug 11, 2024
d943417
fix
Aug 11, 2024
062ca18
Update Address
Aug 11, 2024
4755c3f
refactor: extract default api call timeout duration
romain-neil Aug 11, 2024
342411c
refactor: extract creation of ip address
romain-neil Aug 11, 2024
7a914e2
refactor: only pass string
romain-neil Aug 11, 2024
f687499
refactor: code cleanup + more infos
romain-neil Aug 11, 2024
f494ec8
refactor: use better name
romain-neil Aug 11, 2024
9595a29
feat: declare exchange
romain-neil Aug 11, 2024
ae4de93
wip: send successfully treated messages
romain-neil Aug 11, 2024
f2fda29
IP Addresses
Aug 11, 2024
5afe5a5
Queue success + fail
Aug 11, 2024
cb33c00
delay
Aug 11, 2024
4b7b083
Util.Err + failWithError
Aug 11, 2024
945da46
refactor: correct initial vm status
romain-neil Aug 11, 2024
fb48a37
printf
Aug 18, 2024
a522fe0
refactor: extract vm related functions:
romain-neil Aug 21, 2024
8d93e62
feat: add quotes to port mapping
romain-neil Aug 21, 2024
d764046
refactor: extract of create & change ip address related to vm interface
romain-neil Aug 21, 2024
e85650d
feat: base cluster object
romain-neil Aug 22, 2024
6b764bc
refactor: add more fields to vm
romain-neil Aug 22, 2024
3295b2c
refactor: change how vm object are initialized
romain-neil Aug 22, 2024
6ca97b7
refactor: use new properties name
romain-neil Aug 22, 2024
d9be529
refactor: use new properties name
romain-neil Aug 22, 2024
eec2a3b
feat: function to check if vm exist
romain-neil Aug 22, 2024
b3c7e2b
refactor: use existing function
romain-neil Aug 22, 2024
d736653
refactor: extract vm creation
romain-neil Aug 22, 2024
d389721
refactor: use enw var
romain-neil Aug 22, 2024
0bc2ab8
refactor: extract vm update function
romain-neil Aug 22, 2024
04edad4
refactor: use existing netbox var in vm
romain-neil Aug 24, 2024
934b8a8
wip: extract update of vm management ip
romain-neil Aug 24, 2024
cbe4be5
refactor: correctly ink ip address to machine interface
romain-neil Aug 29, 2024
5f68f2b
fix logic
romain-neil Sep 5, 2024
d4ad0ec
refactor: move docker conf
romain-neil Oct 29, 2024
60eda57
refactor + fix (#6)
IDarKay Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.4'

- name: Build
run: go build -o rh-api-linux -v .

- name: debug
run: ls -lah

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rh api
path: rh-api-linux
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#ignore .env file
#ignore .env file
.env

.idea/
.vscode/
102 changes: 0 additions & 102 deletions api/GenerateLoopback.py

This file was deleted.

109 changes: 0 additions & 109 deletions api/util/netbox_utils.py

This file was deleted.

14 changes: 0 additions & 14 deletions api/util/wireguard_utils.py

This file was deleted.

88 changes: 88 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
services:
netbox: &netbox
image: docker.io/netboxcommunity/netbox:${VERSION-v3.7.5}
depends_on:
- postgres
- redis
- redis-cache
env_file: docker/env/netbox.env
user: 'unit:root'
healthcheck:
start_period: 60s
timeout: 3s
interval: 15s
test: "curl -f http://localhost:8080/login/ || exit 1"
volumes:
- ./docker/configuration:/etc/netbox/config:z,ro
- netbox-media-files:/opt/netbox/netbox/media:rw
- netbox-reports-files:/opt/netbox/netbox/reports:rw
- netbox-scripts-files:/opt/netbox/netbox/scripts:rw
ports:
- "8888:8080"
netbox-worker:
<<: *netbox
depends_on:
netbox:
condition: service_healthy
command:
- /opt/netbox/venv/bin/python
- /opt/netbox/netbox/manage.py
- rqworker
healthcheck:
start_period: 20s
timeout: 3s
interval: 15s
test: "ps -aux | grep -v grep | grep -q rqworker || exit 1"
netbox-housekeeping:
<<: *netbox
depends_on:
netbox:
condition: service_healthy
command:
- /opt/netbox/housekeeping.sh
healthcheck:
start_period: 20s
timeout: 3s
interval: 15s
test: "ps -aux | grep -v grep | grep -q housekeeping || exit 1"

# postgres
postgres:
image: docker.io/postgres:16-alpine
env_file: docker/env/postgres.env
volumes:
- netbox-postgres-data:/var/lib/postgresql/data

# redis
redis:
image: docker.io/redis:7-alpine
command:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
- redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
env_file: docker/env/redis.env
volumes:
- netbox-redis-data:/data
redis-cache:
image: docker.io/redis:7-alpine
command:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
env_file: docker/env/redis-cache.env
volumes:
- netbox-redis-cache-data:/data

volumes:
netbox-media-files:
driver: local
netbox-postgres-data:
driver: local
netbox-redis-cache-data:
driver: local
netbox-redis-data:
driver: local
netbox-reports-files:
driver: local
netbox-scripts-files:
driver: local
Loading
Loading