blob: cd47497acb5c1fb1d7d4961edc0d28015b3d223e [file] [log] [blame]
Michael Marchetti79731f42018-07-10 18:07:12 +02001#!/bin/sh
2mkdir -p /etc/systemd/system/scripts
3cat > /etc/systemd/system/scripts/osm-vimemu-startup.sh <<-'EOF'
4#!/bin/sh
5
6export OSM_HOSTNAME=127.0.0.1
7export OSM_SOL005=True
8
9echo "Waiting for OSM startup"
10while 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
17done
18echo "OSM is up"
Michael Marchetti1b60d172018-08-02 17:15:48 +020019sleep 10
Michael Marchetti79731f42018-07-10 18:07:12 +020020export VIMEMU_HOSTNAME=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
21osm vim-create --name vim-emulator --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack
22osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/ping.tar.gz
23osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/pong.tar.gz
24osm nsd-create /home/vagrant/vim-emu/examples/services/pingpong_nsd.tar.gz
25osm ns-create --nsd_name pingpong --ns_name test --vim_account vim-emulator
26
27echo "VIM emulator created"
28systemctl disable osm-vimemu-setup.service
29EOF
30chmod +x /etc/systemd/system/scripts/osm-vimemu-startup.sh
31
32cat > /etc/systemd/system/osm-vimemu-setup.service <<-'EOF'
33[Unit]
34Description=OSM VIM emulator setup
35
36[Service]
37Type=oneshot
38ExecStart=/etc/systemd/system/scripts/osm-vimemu-startup.sh
39RemainAfterExit=yes
40TimeoutSec=120
41
42# Output needs to appear in instance console output
43StandardOutput=journal+console
44
45[Install]
46WantedBy=multi-user.target
47EOF
48
Michael Marchetti1b60d172018-08-02 17:15:48 +020049systemctl enable osm-vimemu-setup.service