2 ################################################################################
4 # Copyright 2020 highstreet technologies GmbH and others
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 ################################################################################
22 netconf_call_home=`jq '.["netconf-call-home"]' /opt/dev/scripts/configuration.json`
25 if [ $netconf_call_home = "false" ] ; then
26 echo "NETCONF Call Home is disabled, nothing to do..."
29 echo "Enabling NETCONF Call Home in device..."
32 controller_ip=`jq '.["controller-details"] ."controller-ip"' /opt/dev/scripts/configuration.json`
33 controller_username=`jq '.["controller-details"] ."controller-username"' /opt/dev/scripts/configuration.json`
34 controller_password=`jq '.["controller-details"] ."controller-password"' /opt/dev/scripts/configuration.json`
35 controller_port=`jq '.["controller-details"] ."controller-port"' /opt/dev/scripts/configuration.json`
36 netconf_call_home_port=`jq '.["controller-details"] ."netconf-call-home-port"' /opt/dev/scripts/configuration.json`
38 SSH_PUB_KEY_MELACON="$(cat /home/netconf/.ssh/melacon.server.key.pub | awk '{print $2}')"
41 "odl-netconf-callhome-server:device": [
43 "odl-netconf-callhome-server:unique-id": "'$HOSTNAME'",
44 "odl-netconf-callhome-server:ssh-host-key": "'$SSH_PUB_KEY_MELACON'",
45 "odl-netconf-callhome-server:credentials": {
46 "odl-netconf-callhome-server:username": "netconf",
47 "odl-netconf-callhome-server:passwords": [
55 odl_ip=`sed -e 's/^"//' -e 's/"$//' <<<"$controller_ip"`
56 odl_username=`sed -e 's/^"//' -e 's/"$//' <<<"$controller_username"`
57 odl_password=`sed -e 's/^"//' -e 's/"$//' <<<"$controller_password"`
59 echo "Payload: $payload"
61 curl -v -H 'Content-Type: application/json' -X PUT -u $odl_username:$odl_password \
62 -d "$payload" http://$odl_ip:$controller_port/restconf/config/odl-netconf-callhome-server:netconf-callhome-server/allowed-devices/device/$HOSTNAME
64 echo '<netconf-server xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-server">
67 <name>test_ssh_ch_client</name>
71 <name>test_ssh_ch_endpt</name>
72 <address>'$odl_ip'</address>
73 <port>'$netconf_call_home_port'</port>
78 <name>melacon server key</name>
79 <public-key>melacon_server_key</public-key>
88 </netconf-server>' > connections.xml
90 sysrepocfg --merge=connections.xml --format=xml ietf-netconf-server