blob: d7a044e7da8c9b944885cbed4692dd55475fa285 [file] [log] [blame]
Michael Marchetti79731f42018-07-10 18:07:12 +02001#!/bin/sh
ramonsalguer8ac0f082020-06-03 20:13:34 +02002
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Michael Marchetti79731f42018-07-10 18:07:12 +020015mkdir -p /etc/systemd/system/scripts
16cat > /etc/systemd/system/scripts/osm-vimemu-startup.sh <<-'EOF'
17#!/bin/sh
18
19export OSM_HOSTNAME=127.0.0.1
20export OSM_SOL005=True
21
22echo "Waiting for OSM startup"
23while true; do
24 # wait for startup of osm
25 RC=$(osm vim-list)
26 if [ "$?" -eq 0 ]; then
27 break
28 fi
29 sleep 2
30done
31echo "OSM is up"
Michael Marchetti1b60d172018-08-02 17:15:48 +020032sleep 10
Michael Marchetti79731f42018-07-10 18:07:12 +020033export VIMEMU_HOSTNAME=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
34osm vim-create --name vim-emulator --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack
35osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/ping.tar.gz
36osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/pong.tar.gz
37osm nsd-create /home/vagrant/vim-emu/examples/services/pingpong_nsd.tar.gz
38osm ns-create --nsd_name pingpong --ns_name test --vim_account vim-emulator
39
40echo "VIM emulator created"
41systemctl disable osm-vimemu-setup.service
42EOF
43chmod +x /etc/systemd/system/scripts/osm-vimemu-startup.sh
44
45cat > /etc/systemd/system/osm-vimemu-setup.service <<-'EOF'
46[Unit]
47Description=OSM VIM emulator setup
48
49[Service]
50Type=oneshot
51ExecStart=/etc/systemd/system/scripts/osm-vimemu-startup.sh
52RemainAfterExit=yes
53TimeoutSec=120
54
55# Output needs to appear in instance console output
56StandardOutput=journal+console
57
58[Install]
59WantedBy=multi-user.target
60EOF
61
Mike Marchetti06554a52018-08-31 10:18:44 -040062#systemctl enable osm-vimemu-setup.service