Skip to content

Commit 0c97b63

Browse files
committed
a function to generate simple GoBGP config was introduced
1 parent 71e11df commit 0c97b63

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

auxiliary_functions.sh

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ then
55
exit 0
66
fi
77

8+
## @fn gobgp_toml_config()
9+
## @brief returns a minimum GoBGP config (in TOML format) for a BGP server
10+
function gobgp_toml_config() {
11+
local local_asn=$1
12+
local remote_asn=$2
13+
local local_router_ip=$3
14+
local remote_router_ip=$4
15+
16+
local BGP_CONF=
17+
18+
read -r -d '' BGP_CONF <<- BGP_CONF_MARKER
19+
[global.config]
20+
as = "$local_asn"
21+
router-id = "$local_router_ip"
22+
[[neighbors]]
23+
[neighbors.config]
24+
neighbor-address = "$remote_router_ip"
25+
peer-as = "$remote_asn"
26+
[[neighbors.afi-safis]]
27+
[neighbors.afi-safis.config]
28+
afi-safi-name = "l2vpn-evpn"
29+
BGP_CONF_MARKER
30+
31+
echo "$BGP_CONF"
32+
}
33+
834
## @fn frr_bgp_config()
935
## @brief returns minimum FRR config for BGP server
1036
function frr_bgp_config() {
@@ -17,7 +43,7 @@ function frr_bgp_config() {
1743
adv_ip="10.0.0.100/32"
1844
fi
1945

20-
local BGP_CONF=
46+
local BGP_CONF=
2147

2248
read -r -d '' BGP_CONF <<- BGP_CONF_MARKER
2349
log syslog informational
@@ -35,7 +61,23 @@ read -r -d '' BGP_CONF <<- BGP_CONF_MARKER
3561
!
3662
BGP_CONF_MARKER
3763

64+
}
3865

66+
## @fn run_gobgpd
67+
## @brief runs gobgpd daemon on the specified machine
68+
function run_gobgpd() {
69+
local local_asn=$1 # where GoBGP is installed
70+
local remote_asn=$2
71+
local local_router_ip=$3 # where GoBGP is installed
72+
local remote_router_ip=$4
73+
gobgp_toml_config $local_asn $remote_asn \
74+
$local_router_ip $remote_router_ip > ./gobgpd.toml.conf
75+
76+
ssh root@$local_router_ip "pkill gobgpd"
77+
ssh root@$local_router_ip "mkdir -p /etc/gobgp.d"
78+
ssh root@$local_router_ip "rm -rf /etc/gobgp.d/gobgpd.toml.conf"
79+
scp ./gobgpd.toml.conf root@$local_router_ip:/etc/gobgp.d/gobgpd.toml.conf
80+
ssh root@$local_router_ip "gobgpd -f /etc/gobgp.d/gobgpd.toml.conf" &
3981
}
4082

4183
## @fn clean_results()
@@ -434,7 +476,7 @@ function aggregate_over_list() {
434476
}
435477

436478
## @fn query_task_stats
437-
## @brief gather task stats for a given OpenSDN module
479+
## @brief Gathers task stats for a given OpenSDN module
438480
function query_task_stats() {
439481
local module_ip=$1
440482
local module_port=$2
@@ -482,7 +524,7 @@ function query_task_stats() {
482524
t_task_state.xml \
483525
"//task_group_list/list/SandeshTaskGroup[$i_task]/task_entry_list/list" \
484526
"SandeshTaskEntry" \
485-
"tasks_completed"`
527+
"total_tasks_completed"`
486528

487529
tasks_running=`\
488530
aggregate_over_list \
@@ -516,3 +558,6 @@ export AUXILIARY_FUNCTIONS=
516558
#END-OF-FILE
517559
#
518560

561+
562+
563+

0 commit comments

Comments
 (0)