Enhance ExaBGP configuration and scripts by adding environment variable support for neighbor IP, local AS, and router ID. Update Dockerfile to include permissions for the new generate_config.py script. Improve start.sh to generate configuration dynamically and display relevant information during startup.
Build and Push Docker Image / build (push) Successful in 3m34s
Build and Push Docker Image / build (push) Successful in 3m34s
This commit is contained in:
@@ -78,18 +78,23 @@ def load_all_prefixes() -> Set[str]:
|
||||
|
||||
def announce_prefixes(prefixes: Set[str]):
|
||||
"""Анонсирование префиксов через ExaBGP API"""
|
||||
# Получение настроек из переменных окружения
|
||||
neighbor_ip = os.environ.get('BGP_NEIGHBOR_IP', '192.168.1.1')
|
||||
local_as = int(os.environ.get('BGP_LOCAL_AS', '65000'))
|
||||
router_id = os.environ.get('BGP_ROUTER_ID', '192.168.1.100')
|
||||
|
||||
for prefix in sorted(prefixes):
|
||||
# Формат команды для ExaBGP
|
||||
command = {
|
||||
"command": "announce route",
|
||||
"neighbor": {
|
||||
"ip": "192.168.1.1",
|
||||
"ip": neighbor_ip,
|
||||
"description": "RouterOS peer"
|
||||
},
|
||||
"attribute": {
|
||||
"origin": "igp",
|
||||
"as-path": [65000],
|
||||
"next-hop": "192.168.1.100"
|
||||
"as-path": [local_as],
|
||||
"next-hop": router_id
|
||||
},
|
||||
"nlri": prefix
|
||||
}
|
||||
@@ -100,11 +105,14 @@ def announce_prefixes(prefixes: Set[str]):
|
||||
|
||||
def withdraw_prefixes(prefixes: Set[str]):
|
||||
"""Отзыв префиксов через ExaBGP API"""
|
||||
# Получение настроек из переменных окружения
|
||||
neighbor_ip = os.environ.get('BGP_NEIGHBOR_IP', '192.168.1.1')
|
||||
|
||||
for prefix in sorted(prefixes):
|
||||
command = {
|
||||
"command": "withdraw route",
|
||||
"neighbor": {
|
||||
"ip": "192.168.1.1",
|
||||
"ip": neighbor_ip,
|
||||
"description": "RouterOS peer"
|
||||
},
|
||||
"nlri": prefix
|
||||
|
||||
Reference in New Issue
Block a user