| Michael Marchetti | 79731f4 | 2018-07-10 18:07:12 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | mkdir -p /etc/systemd/system/scripts |
| 3 | cat > /etc/systemd/system/scripts/osm-vimemu-startup.sh <<-'EOF' |
| 4 | #!/bin/sh |
| 5 | |
| 6 | export OSM_HOSTNAME=127.0.0.1 |
| 7 | export OSM_SOL005=True |
| 8 | |
| 9 | echo "Waiting for OSM startup" |
| 10 | while true; do |
| 11 | # wait for startup of osm |
| 12 | RC=$(osm vim-list) |
| 13 | if [ "$?" -eq 0 ]; then |
| 14 | break |
| 15 | fi |
| 16 | sleep 2 |
| 17 | done |
| 18 | echo "OSM is up" |
| Michael Marchetti | 1b60d17 | 2018-08-02 17:15:48 +0200 | [diff] [blame] | 19 | sleep 10 |
| Michael Marchetti | 79731f4 | 2018-07-10 18:07:12 +0200 | [diff] [blame] | 20 | export VIMEMU_HOSTNAME=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu) |
| 21 | osm vim-create --name vim-emulator --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack |
| 22 | osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/ping.tar.gz |
| 23 | osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/pong.tar.gz |
| 24 | osm nsd-create /home/vagrant/vim-emu/examples/services/pingpong_nsd.tar.gz |
| 25 | osm ns-create --nsd_name pingpong --ns_name test --vim_account vim-emulator |
| 26 | |
| 27 | echo "VIM emulator created" |
| 28 | systemctl disable osm-vimemu-setup.service |
| 29 | EOF |
| 30 | chmod +x /etc/systemd/system/scripts/osm-vimemu-startup.sh |
| 31 | |
| 32 | cat > /etc/systemd/system/osm-vimemu-setup.service <<-'EOF' |
| 33 | [Unit] |
| 34 | Description=OSM VIM emulator setup |
| 35 | |
| 36 | [Service] |
| 37 | Type=oneshot |
| 38 | ExecStart=/etc/systemd/system/scripts/osm-vimemu-startup.sh |
| 39 | RemainAfterExit=yes |
| 40 | TimeoutSec=120 |
| 41 | |
| 42 | # Output needs to appear in instance console output |
| 43 | StandardOutput=journal+console |
| 44 | |
| 45 | [Install] |
| 46 | WantedBy=multi-user.target |
| 47 | EOF |
| 48 | |
| Mike Marchetti | 06554a5 | 2018-08-31 10:18:44 -0400 | [diff] [blame] | 49 | #systemctl enable osm-vimemu-setup.service |