-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path6_start_device_discovery.sh
executable file
·81 lines (68 loc) · 1.64 KB
/
6_start_device_discovery.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -euo pipefail
# Check if all required environment variables are set
REQUIRED_VARS=("MY_EXTERNAL_IP" "DOCKER_SUBNET" "NETBOX_PORT" "DIODE_API_KEY")
for var in "${REQUIRED_VARS[@]}"; do
if [ -z "${!var:-}" ]; then
echo "Error: Required environment variable '$var' is not set."
exit 0
fi
done
WORKING_DIR="device_discovery"
# Remove config directory if it exists
sudo rm -fr ${WORKING_DIR}
# Recreate it and pushd in
mkdir ${WORKING_DIR}
pushd ${WORKING_DIR}
echo
echo "--- Writing agent config ---"
echo
cat <<EOF > agent.yaml
orb:
config_manager:
active: local
backends:
device_discovery:
common:
diode:
target: grpc://${MY_EXTERNAL_IP}:8080/diode
api_key: ${DIODE_API_KEY}
agent_name: agent1
policies:
device_discovery:
discovery_1:
config:
schedule: "* * * * *"
defaults:
site: New York NY
scope:
- driver: srl
hostname: 172.24.0.100
username: admin
password: NokiaSrl1!
optional_args:
insecure: True
- driver: srl
hostname: 172.24.0.101
username: admin
password: NokiaSrl1!
optional_args:
insecure: True
EOF
cat agent.yaml
echo
echo "--- Adding SR Linux driver ---"
echo
cat <<EOF > drivers.txt
napalm-srl==1.0.5
EOF
echo
echo "--- Starting agent ---"
echo
docker run -v $(pwd):/opt/orb/ \
-e DIODE_API_KEY=${DIODE_API_KEY} \
-e INSTALL_DRIVERS_PATH=/opt/orb/drivers.txt \
--network ${DOCKER_NETWORK} \
netboxlabs/orb-agent:latest run -c /opt/orb/agent.yaml
# End
popd