Add simulator improvements.
[sim/o1-interface.git] / ntsimulator / yang / sysrepo-configuration-load.sh
1 #!/bin/bash
2 ################################################################################
3 #
4 # Copyright 2019 highstreet technologies GmbH and others
5 #
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
9
10 #     http://www.apache.org/licenses/LICENSE-2.0
11
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.
17 ################################################################################
18
19 sleep 20
20
21 echo "Loading data into sysrepo..."
22
23 result=$(netopeer2-cli <<-END
24         knownhosts --del 0
25     knownhosts --del 0
26 END
27 )
28
29 SSH_PUB_KEY_MELACON="$(cat /home/netconf/.ssh/melacon.server.key.pub)"
30
31 echo "Writing the public key to the known_hosts..."
32 echo "[127.0.0.1]:830 $SSH_PUB_KEY_MELACON" > /root/.ssh/known_hosts
33
34 pyang -f sample-xml-skeleton --sample-xml-list-entries 2 *.yang
35
36 result=$(netopeer2-cli <<-END
37     auth keys add /home/netconf/.ssh/melacon.server.key.pub /home/netconf/.ssh/melacon.server.key
38         connect --host 127.0.0.1 --login netconf
39         user-rpc --content=/opt/dev/yang/edit_config_operation.xml
40         disconnect
41 END
42 )
43
44 count=1
45
46 while [[ $count -le 100 ]] && [[ "$result" != "OK" ]]
47 do
48   ((count++))
49   pyang -f sample-xml-skeleton --sample-xml-list-entries 2 *.yang
50   
51   result=$(netopeer2-cli <<-END
52         connect --host 127.0.0.1 --login netconf
53         user-rpc --content=edit_config_operation.xml
54         disconnect
55 END
56 )
57 done
58
59 echo "Finished loading data into sysrepo. Removing edit-config XML..."
60 rm -f /opt/dev/yang/edit_config_operation.xml
61
62 echo "Done..."
63 exit 0