Jan Kundrát | e950cf7 | 2024-09-06 17:46:11 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | LN2_MODULE_DIR="${LN2_MODULE_DIR:-/usr/share/yang/modules/libnetconf2}" |
| 6 | NP2_MODULE_DIR="${NP2_MODULE_DIR:-/usr/share/yang/modules/netopeer2}" |
| 7 | NETOPEER2_SETUP_DIR="${NETOPEER2_SETUP_DIR:-/usr/libexec/netopeer2}" |
| 8 | CLA_YANG="${CLA_YANG:-/usr/share/yang/modules/cla-sysrepo}" |
| 9 | VELIA_YANG="${VELIA_YANG:-/usr/share/yang/modules/velia}" |
| 10 | ALARMS_YANG="${ALARMS_YANG:-/usr/share/yang/modules/sysrepo-ietf-alarms}" |
| 11 | ROUSETTE_YANG="${ROUSETTE_YANG:-/usr/share/yang/modules/rousette}" |
| 12 | CFG_FS_YANG="${CFG_FS_YANG:-/usr/share/yang/modules/czechlight-cfg-fs}" |
| 13 | PROC_CMDLINE="${PROC_CMDLINE:-/proc/cmdline}" |
| 14 | CFG_SYSREPO_DIR="${CFG_SYSREPO_DIR:-/cfg/sysrepo}" |
| 15 | |
| 16 | source ${NETOPEER2_SETUP_DIR}/yang.sh |
| 17 | |
| 18 | ROUSETTE_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 | ) |
| 23 | ALARM_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 | ) |
| 29 | VELIA_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 | ) |
| 53 | CFG_FS_MODULES=( |
| 54 | "--install ${CFG_FS_YANG}/czechlight-netconf-server@2024-09-04.yang" |
| 55 | ) |
| 56 | CLA_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 |
| 65 | for ARG in $(cat "$PROC_CMDLINE"); do |
| 66 | case "${ARG}" in |
| 67 | czechlight=*) |
| 68 | CZECHLIGHT="${ARG##czechlight=}" |
| 69 | ;; |
| 70 | esac |
| 71 | done |
| 72 | |
| 73 | case "${CZECHLIGHT}" in |
| 74 | "") |
| 75 | # no device model set -> do nothing |
| 76 | ;; |
Jan Kundrát | 3d44754 | 2024-10-07 09:57:08 +0200 | [diff] [blame^] | 77 | sdn-roadm-line-g2) |
Jan Kundrát | e950cf7 | 2024-09-06 17:46:11 +0200 | [diff] [blame] | 78 | CLA_MODULES+=( |
| 79 | "--install ${CLA_YANG}/czechlight-roadm-device@2021-03-05.yang" |
| 80 | "--enable-feature hw-line-9" |
| 81 | ) |
| 82 | ;; |
Jan Kundrát | 3d44754 | 2024-10-07 09:57:08 +0200 | [diff] [blame^] | 83 | sdn-roadm-add-drop-g2) |
Jan Kundrát | e950cf7 | 2024-09-06 17:46:11 +0200 | [diff] [blame] | 84 | CLA_MODULES+=( |
| 85 | "--install ${CLA_YANG}/czechlight-roadm-device@2021-03-05.yang" |
| 86 | "--enable-feature hw-add-drop-20" |
| 87 | ) |
| 88 | ;; |
Jan Kundrát | 3d44754 | 2024-10-07 09:57:08 +0200 | [diff] [blame^] | 89 | sdn-roadm-hires-add-drop-g2) |
Jan Kundrát | e950cf7 | 2024-09-06 17:46:11 +0200 | [diff] [blame] | 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 | ;; |
Jan Kundrát | 3d44754 | 2024-10-07 09:57:08 +0200 | [diff] [blame^] | 96 | sdn-roadm-coherent-a-d-g2) |
Jan Kundrát | e950cf7 | 2024-09-06 17:46:11 +0200 | [diff] [blame] | 97 | CLA_MODULES+=( |
| 98 | "--install ${CLA_YANG}/czechlight-coherent-add-drop@2021-03-05.yang" |
| 99 | ) |
| 100 | ;; |
Jan Kundrát | 3d44754 | 2024-10-07 09:57:08 +0200 | [diff] [blame^] | 101 | sdn-inline-g2) |
Jan Kundrát | e950cf7 | 2024-09-06 17:46:11 +0200 | [diff] [blame] | 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 | ;; |
| 128 | esac |
| 129 | |
| 130 | sysrepoctl \ |
| 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 |