blob: f437d59a15cf1df49e0db46bcbf8b5e6a0d4339e [file] [log] [blame]
Jan Kundráte950cf72024-09-06 17:46:11 +02001#!/usr/bin/env bash
2
3set -ex
4
5LN2_MODULE_DIR="${LN2_MODULE_DIR:-/usr/share/yang/modules/libnetconf2}"
6NP2_MODULE_DIR="${NP2_MODULE_DIR:-/usr/share/yang/modules/netopeer2}"
7NETOPEER2_SETUP_DIR="${NETOPEER2_SETUP_DIR:-/usr/libexec/netopeer2}"
8CLA_YANG="${CLA_YANG:-/usr/share/yang/modules/cla-sysrepo}"
9VELIA_YANG="${VELIA_YANG:-/usr/share/yang/modules/velia}"
10ALARMS_YANG="${ALARMS_YANG:-/usr/share/yang/modules/sysrepo-ietf-alarms}"
11ROUSETTE_YANG="${ROUSETTE_YANG:-/usr/share/yang/modules/rousette}"
12CFG_FS_YANG="${CFG_FS_YANG:-/usr/share/yang/modules/czechlight-cfg-fs}"
13PROC_CMDLINE="${PROC_CMDLINE:-/proc/cmdline}"
14CFG_SYSREPO_DIR="${CFG_SYSREPO_DIR:-/cfg/sysrepo}"
15
16source ${NETOPEER2_SETUP_DIR}/yang.sh
17
18ROUSETTE_MODULES=(
19 "--install ${ROUSETTE_YANG}/ietf-restconf@2017-01-26.yang"
20 "--install ${ROUSETTE_YANG}/ietf-restconf-monitoring@2017-01-26.yang"
21 "--install ${ROUSETTE_YANG}/ietf-yang-patch@2017-02-22.yang"
22)
23ALARM_MODULES=(
24 "--install ${ALARMS_YANG}/ietf-alarms@2019-09-11.yang"
25 "--enable-feature alarm-shelving"
26 "--enable-feature alarm-summary"
27 "--install ${ALARMS_YANG}/sysrepo-ietf-alarms@2022-02-17.yang"
28)
29VELIA_MODULES=(
30 "--install ${VELIA_YANG}/ietf-system@2014-08-06.yang"
31 "--install ${VELIA_YANG}/czechlight-lldp@2020-11-04.yang"
32 "--install ${VELIA_YANG}/czechlight-system@2022-07-08.yang"
33 "--install ${VELIA_YANG}/iana-if-type@2017-01-19.yang"
34 # sysrepoctl doesn't like duplicates, and the ietf-interfaces and
35 # ietf-ip modules are now dependencies of ietf-netconf-server
36 # "--install ${VELIA_YANG}/ietf-interfaces@2018-02-20.yang"
37 # "--install ${VELIA_YANG}/ietf-ip@2018-02-22.yang"
38 "--install ${VELIA_YANG}/ietf-routing@2018-03-13.yang"
39 "--install ${VELIA_YANG}/ietf-ipv4-unicast-routing@2018-03-13.yang"
40 "--install ${VELIA_YANG}/ietf-ipv6-unicast-routing@2018-03-13.yang"
41 "--install ${VELIA_YANG}/czechlight-network@2021-02-22.yang"
42 "--install ${VELIA_YANG}/ietf-access-control-list@2019-03-04.yang"
43 "--enable-feature match-on-eth"
44 "--enable-feature eth"
45 "--enable-feature match-on-ipv4"
46 "--enable-feature ipv4"
47 "--enable-feature match-on-ipv6"
48 "--enable-feature ipv6"
49 "--enable-feature mixed-eth-ipv4-ipv6"
50 "--install ${VELIA_YANG}/czechlight-firewall@2021-01-25.yang"
51 "--install ${VELIA_YANG}/velia-alarms@2022-07-12.yang"
52)
53CFG_FS_MODULES=(
54 "--install ${CFG_FS_YANG}/czechlight-netconf-server@2024-09-04.yang"
55)
56CLA_MODULES=(
57 "--install ${CLA_YANG}/iana-hardware@2018-03-13.yang"
58 "--install ${CLA_YANG}/ietf-hardware@2018-03-13.yang"
59 "--enable-feature hardware-sensor"
60 "--enable-feature hardware-state"
61)
62
63# determine which hardware model/variety we're on from /proc/cmdline,
64# e.g., there's a "czechlight=sdn-roadm-line-g2" flag passed from the bootloader
65for ARG in $(cat "$PROC_CMDLINE"); do
66 case "${ARG}" in
67 czechlight=*)
68 CZECHLIGHT="${ARG##czechlight=}"
69 ;;
70 esac
71done
72
73case "${CZECHLIGHT}" in
74 "")
75 # no device model set -> do nothing
76 ;;
77 sdn-roadm-line*)
78 CLA_MODULES+=(
79 "--install ${CLA_YANG}/czechlight-roadm-device@2021-03-05.yang"
80 "--enable-feature hw-line-9"
81 )
82 ;;
83 sdn-roadm-add-drop*)
84 CLA_MODULES+=(
85 "--install ${CLA_YANG}/czechlight-roadm-device@2021-03-05.yang"
86 "--enable-feature hw-add-drop-20"
87 )
88 ;;
89 sdn-roadm-hires-add-drop*)
90 CLA_MODULES+=(
91 "--install ${CLA_YANG}/czechlight-roadm-device@2021-03-05.yang"
92 "--enable-feature hw-add-drop-20"
93 "--enable-feature pre-wss-ocm"
94 )
95 ;;
96 sdn-roadm-coherent-a-d*)
97 CLA_MODULES+=(
98 "--install ${CLA_YANG}/czechlight-coherent-add-drop@2021-03-05.yang"
99 )
100 ;;
101 sdn-inline*)
102 CLA_MODULES+=(
103 "--install ${CLA_YANG}/czechlight-inline-amp@2021-03-05.yang"
104 )
105 ;;
106 calibration-box)
107 CLA_MODULES+=(
108 "--install ${CLA_YANG}/czechlight-calibration-device@2019-06-25.yang"
109 )
110 ;;
111 sdn-bidi-cplus1572-g2)
112 CLA_MODULES+=(
113 "--install ${CLA_YANG}/czechlight-bidi-amp@2022-03-22.yang"
114 "--enable-feature dualband-c-plus-1572"
115 )
116 ;;
117 sdn-bidi-cplus1572-ocm-g2)
118 CLA_MODULES+=(
119 "--install ${CLA_YANG}/czechlight-bidi-amp@2022-03-22.yang"
120 "--enable-feature dualband-c-plus-1572"
121 "--enable-feature c-band-ocm"
122 )
123 ;;
124 *)
125 echo "Error: unsupported CzechLight device model ${CZECHLIGHT}"
126 exit 1
127 ;;
128esac
129
130sysrepoctl \
131 -v2 \
132 --search-dirs ${NP2_MODULE_DIR}:${CLA_YANG}:${VELIA_YANG}:${ALARMS_YANG}:${ROUSETTE_YANG} \
133 ${NETOPEER2_YANG_SETUP[@]} \
134 ${ROUSETTE_MODULES[@]} \
135 ${ALARM_MODULES[@]} \
136 ${VELIA_MODULES[@]} \
137 ${CFG_FS_MODULES[@]} \
138 ${CLA_MODULES[@]} \
139 --init-data ${CFG_SYSREPO_DIR}/startup.json