| Michael Marchetti | 79731f4 | 2018-07-10 18:07:12 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| ramonsalguer | 8ac0f08 | 2020-06-03 20:13:34 +0200 | [diff] [blame] | 2 | |
| 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 Marchetti | 79731f4 | 2018-07-10 18:07:12 +0200 | [diff] [blame] | 15 | mkdir -p /etc/systemd/system/scripts |
| 16 | cat > /etc/systemd/system/scripts/osm-vimemu-startup.sh <<-'EOF' |
| 17 | #!/bin/sh |
| 18 | |
| 19 | export OSM_HOSTNAME=127.0.0.1 |
| 20 | export OSM_SOL005=True |
| 21 | |
| 22 | echo "Waiting for OSM startup" |
| 23 | while 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 |
| 30 | done |
| 31 | echo "OSM is up" |
| Michael Marchetti | 1b60d17 | 2018-08-02 17:15:48 +0200 | [diff] [blame] | 32 | sleep 10 |
| Michael Marchetti | 79731f4 | 2018-07-10 18:07:12 +0200 | [diff] [blame] | 33 | export VIMEMU_HOSTNAME=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu) |
| 34 | osm vim-create --name vim-emulator --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack |
| 35 | osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/ping.tar.gz |
| 36 | osm vnfd-create /home/vagrant/vim-emu/examples/vnfs/pong.tar.gz |
| 37 | osm nsd-create /home/vagrant/vim-emu/examples/services/pingpong_nsd.tar.gz |
| 38 | osm ns-create --nsd_name pingpong --ns_name test --vim_account vim-emulator |
| 39 | |
| 40 | echo "VIM emulator created" |
| 41 | systemctl disable osm-vimemu-setup.service |
| 42 | EOF |
| 43 | chmod +x /etc/systemd/system/scripts/osm-vimemu-startup.sh |
| 44 | |
| 45 | cat > /etc/systemd/system/osm-vimemu-setup.service <<-'EOF' |
| 46 | [Unit] |
| 47 | Description=OSM VIM emulator setup |
| 48 | |
| 49 | [Service] |
| 50 | Type=oneshot |
| 51 | ExecStart=/etc/systemd/system/scripts/osm-vimemu-startup.sh |
| 52 | RemainAfterExit=yes |
| 53 | TimeoutSec=120 |
| 54 | |
| 55 | # Output needs to appear in instance console output |
| 56 | StandardOutput=journal+console |
| 57 | |
| 58 | [Install] |
| 59 | WantedBy=multi-user.target |
| 60 | EOF |
| 61 | |
| Mike Marchetti | 06554a5 | 2018-08-31 10:18:44 -0400 | [diff] [blame] | 62 | #systemctl enable osm-vimemu-setup.service |