Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | IETF_HW_STATE=0 |
| 6 | YANG_ROADM=0 |
| 7 | YANG_COHERENT=0 |
| 8 | YANG_INLINE=0 |
| 9 | YANG_CALIBRATION=0 |
| 10 | |
| 11 | YANG_DIR=/usr/share/cla-sysrepo/yang |
| 12 | REPO=/etc/sysrepo/yang |
| 13 | |
| 14 | for ARG in $(cat /proc/cmdline); do |
| 15 | case "${ARG}" in |
| 16 | czechlight=*) |
| 17 | CZECHLIGHT="${ARG:11}" |
| 18 | ;; |
| 19 | esac |
| 20 | done |
| 21 | |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 22 | INITIAL_DATA=${CZECHLIGHT%%-g2} |
| 23 | |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 24 | case "${CZECHLIGHT}" in |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 25 | sdn-roadm-line*) |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 26 | YANG_ROADM=1 |
| 27 | WITH_FEATURE=hw-line-9 |
| 28 | IETF_HW_STATE=1 |
| 29 | ;; |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 30 | sdn-roadm-add-drop*) |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 31 | YANG_ROADM=1 |
| 32 | WITH_FEATURE=hw-add-drop-20 |
| 33 | IETF_HW_STATE=1 |
| 34 | ;; |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 35 | sdn-roadm-hires-add-drop*) |
| 36 | YANG_ROADM=1 |
| 37 | WITH_FEATURE=hw-add-drop-20 |
| 38 | IETF_HW_STATE=1 |
| 39 | INITIAL_DATA=sdn-roadm-add-drop |
| 40 | ;; |
| 41 | sdn-roadm-coherent-a-d*) |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 42 | IETF_HW_STATE=1 |
| 43 | YANG_COHERENT=1 |
| 44 | ;; |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 45 | sdn-inline*) |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 46 | IETF_HW_STATE=1 |
| 47 | YANG_INLINE=1 |
| 48 | ;; |
| 49 | calibration-box) |
| 50 | YANG_CALIBRATION=1 |
| 51 | ;; |
| 52 | esac |
| 53 | |
Tomáš Pecka | c34a545 | 2020-12-16 21:29:09 +0100 | [diff] [blame] | 54 | # asks ietf-yang-library model in sysrepo for the state of a module given by $1 |
| 55 | # can return "implement", "import" or "" if the module is not present in the tree |
| 56 | yang-module-state() { |
| 57 | sysrepocfg -f xml -X --xpath "/ietf-yang-library:modules-state/module[name='$1']/conformance-type" -d operational | sed -n 's/\s*<conformance-type>\(.*\)<\/conformance-type>/\1/p' |
| 58 | } |
| 59 | |
| 60 | if [[ ${IETF_HW_STATE} == 1 ]]; then |
| 61 | # if old model is implemented, remove it first. This uninstall dependent ietf-hardware if imported and not implemented |
| 62 | if [[ "$(yang-module-state ietf-hardware-state)" == "implement" ]]; then |
| 63 | sysrepoctl -u ietf-hardware-state --apply |
| 64 | fi |
| 65 | |
| 66 | # if new model is not implemented |
| 67 | if [[ "$(yang-module-state ietf-hardware)" != "implement" ]]; then |
| 68 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/iana-hardware@2018-03-13.yang |
| 69 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/ietf-hardware@2018-03-13.yang |
| 70 | sysrepoctl --change ietf-hardware --permissions 0664 --enable-feature hardware-sensor --apply |
| 71 | fi |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 72 | fi |
| 73 | |
| 74 | if [[ ${YANG_ROADM} == 1 && ! -f ${REPO}/czechlight-roadm-device@2019-09-30.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 75 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-roadm-device@2019-09-30.yang |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 76 | sysrepoctl --change czechlight-roadm-device --group optics --permissions 0664 --apply |
| 77 | if [[ ${WITH_FEATURE} ]]; then |
| 78 | sysrepoctl --change czechlight-roadm-device --enable-feature ${WITH_FEATURE} |
| 79 | fi |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 80 | sysrepocfg --datastore=startup --format=json --module=czechlight-roadm-device --import="${YANG_DIR}/${INITIAL_DATA}.json" |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 81 | fi |
| 82 | |
| 83 | if [[ ${YANG_COHERENT} == 1 && ! -f ${REPO}/czechlight-coherent-add-drop@2019-09-30.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 84 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-coherent-add-drop@2019-09-30.yang |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 85 | sysrepocfg --datastore=startup --format=json --module=czechlight-coherent-add-drop --new-data="${YANG_DIR}/${INITIAL_DATA}.json" |
Jan Kundrát | 00876bd | 2021-01-29 19:51:59 +0100 | [diff] [blame] | 86 | sysrepoctl --change czechlight-coherent-add-drop --group optics --permissions 0664 --apply |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 87 | fi |
| 88 | |
| 89 | if [[ ${YANG_INLINE} == 1 && ! -f ${REPO}/czechlight-inline-amp@2019-09-30.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 90 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-inline-amp@2019-09-30.yang |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 91 | sysrepocfg --datastore=startup --format=json --module=czechlight-inline-amp --import="${YANG_DIR}/${INITIAL_DATA}.json" |
Jan Kundrát | 00876bd | 2021-01-29 19:51:59 +0100 | [diff] [blame] | 92 | sysrepoctl --change czechlight-inline-amp --group optics --permissions 0664 --apply |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 93 | fi |
| 94 | |
| 95 | if [[ ${YANG_CALIBRATION} == 1 && ! -f ${REPO}/czechlight-calibration-device@2019-06-25.yang ]]; then |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 96 | sysrepoctl --search-dirs ${YANG_DIR} --install ${YANG_DIR}/czechlight-calibration-device@2019-06-25.yang |
Jan Kundrát | 811c0b0 | 2021-02-05 19:16:43 +0100 | [diff] [blame] | 97 | sysrepocfg --datastore=startup --format=json --module=czechlight-calibration-device --import="${YANG_DIR}/${INITIAL_DATA}.json" |
Jan Kundrát | 00876bd | 2021-01-29 19:51:59 +0100 | [diff] [blame] | 98 | sysrepoctl --change czechlight-calibration-device --group optics --permissions 0664 --apply |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 99 | fi |
| 100 | |
Tomáš Pecka | 01df848 | 2021-01-13 18:04:19 +0100 | [diff] [blame] | 101 | if [[ ! -f ${REPO}/ietf-system@2014-08-06.yang ]]; then |
Jan Kundrát | 77c1cb1 | 2021-01-25 12:16:27 +0100 | [diff] [blame] | 102 | sysrepoctl --search-dirs /usr/share/velia/yang --install /usr/share/velia/yang/ietf-system@2014-08-06.yang |
Tomáš Pecka | 01df848 | 2021-01-13 18:04:19 +0100 | [diff] [blame] | 103 | sysrepoctl --change ietf-system --permissions 0664 --apply |
| 104 | fi |
| 105 | |
Jan Kundrát | cf5dd8a | 2020-11-05 15:59:11 +0100 | [diff] [blame] | 106 | if [[ ! -f ${REPO}/czechlight-lldp@2020-11-04.yang ]]; then |
| 107 | if compgen -G "${REPO}/czechlight-lldp@*.yang" >/dev/null; then |
| 108 | sysrepoctl --search-dirs /usr/share/lldp-systemd-networkd-sysrepo/yang --update /usr/share/lldp-systemd-networkd-sysrepo/yang/czechlight-lldp@2020-11-04.yang |
| 109 | else |
| 110 | sysrepoctl --search-dirs /usr/share/lldp-systemd-networkd-sysrepo/yang --install /usr/share/lldp-systemd-networkd-sysrepo/yang/czechlight-lldp@2020-11-04.yang |
| 111 | fi |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 112 | sysrepoctl --change czechlight-lldp --permissions 0664 --apply |
| 113 | fi |
| 114 | |
Tomáš Pecka | 25aae68 | 2021-01-27 14:45:57 +0100 | [diff] [blame] | 115 | if [[ ! -f ${REPO}/czechlight-system@2021-01-13.yang ]]; then |
| 116 | sysrepoctl --search-dirs /usr/share/velia/yang --install /usr/share/velia/yang/czechlight-system@2021-01-13.yang |
| 117 | sysrepoctl --change czechlight-system --permissions 0664 --apply |
| 118 | fi |
| 119 | |
Jan Kundrát | 34d2f48 | 2021-01-11 19:24:09 +0100 | [diff] [blame] | 120 | # If not do not copy here from startup -> running, running might be stale. |
| 121 | sysrepocfg -C startup |