bf8f93b6ee9f94e9822b5efeafa75676e2d86880
[sim/o1-interface.git] / ntsimulator / yang / sysrepo-configuration-load.sh
1 #!/bin/bash
2
3 sleep 5
4
5 echo "Loading data into sysrepo..."
6
7 SSH_PUB_KEY="$(cat /home/netconf/.ssh/id_dsa.pub| awk '{print $2}')"
8
9 echo '<system xmlns="urn:ietf:params:xml:ns:yang:ietf-system"><authentication><user><name>netconf</name><authorized-key><name>ssh_key</name><algorithm>ssh-dss</algorithm>' >> load_auth_pubkey.xml
10 echo '<key-data>'"$SSH_PUB_KEY"'</key-data></authorized-key></user></authentication></system>' >> load_auth_pubkey.xml
11
12 sysrepocfg --merge=load_auth_pubkey.xml --format=xml ietf-system
13 rm load_auth_pubkey.xml
14
15 ssh-keyscan -p 830 localhost >> ~/.ssh/known_hosts
16
17 pyang -f sample-xml-skeleton --sample-xml-list-entries 3 *.yang
18
19 result=$(netopeer2-cli <<-END
20         auth pref publickey 1000
21         auth keys add /home/netconf/.ssh/id_dsa.pub /home/netconf/.ssh/id_dsa
22         connect --login netconf
23         user-rpc --content=/opt/dev/yang/edit_config_operation.xml
24         disconnect
25 END
26 )
27
28 while [[ "$result" != "OK" ]]
29 do
30   pyang -f sample-xml-skeleton --sample-xml-list-entries 2 *.yang
31   
32   result=$(netopeer2-cli <<-END
33         connect --login netconf
34         user-rpc --content=edit_config_operation.xml
35         disconnect
36 END
37 )
38 done
39 echo "Finished loading data into sysrepo..."
40
41 exit 0