VIM emulator classic build walkthrough
From OSM Public Wiki
VIM emulator walkthrough with OSM classic build
Step 1: Install OSM rel. THREE and vim-emu
Install OSM rel. THREE together with the emulator (if not yet done).
$ ./install_osm.sh --lxdimages --vimemu
(Optional) Step 1.1: Manually start vim-emu container
The installation automatically starts a Docker container named vim-emu
that runs the emulation platform. If you want to start the emulator manually, you can do this with the following command:
$ sudo docker run --name vim-emu -t -d --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py
Step 1.2: Configure environment
You need to set the correct environment variables (they are also printed at the end of the installation script).
$ export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'` $ export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'` $ export VIMEMU_HOSTNAME=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
Step 2: Check vim-emu that is running inside a Docker container
# connect to vim-emu Docker container to see its logs ( do in another terminal window) $ sudo docker logs -f vim-emu # check if the emulator is running in the container $ sudo docker exec vim-emu vim-emu datacenter list +---------+-----------------+----------+----------------+--------------------+ | Label | Internal Name | Switch | # Containers | # Metadata Items | +=========+=================+==========+================+====================+ | dc2 | dc2 | dc2.s1 | 0 | 0 | +---------+-----------------+----------+----------------+--------------------+ | dc1 | dc1 | dc1.s1 | 0 | 0 | +---------+-----------------+----------+----------------+--------------------+
Step 3: Attach OSM to vim-emu
# connect OSM to emulated VIM $ osm vim-create --name emu-vim1 --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack # list vims $ osm vim-list +----------+--------------------------------------+ | vim name | uuid | +----------+--------------------------------------+ | emu-vim1 | a8175948-efcf-11e7-94ad-00163eba993f | +----------+--------------------------------------+
Step 4: On-board example pingpong service
# VNFs $ osm upload-package vim-emu/examples/vnfs/ping.tar.gz $ osm upload-package vim-emu/examples/vnfs/pong.tar.gz # NS $ osm upload-package vim-emu/examples/services/pingpong_nsd.tar.gz # You can now check OSM's Launchpad to see the VNFs and NS in the catalog. Or: $ osm vnfd-list +-----------+------+ | vnfd name | id | +-----------+------+ | ping | ping | | pong | pong | +-----------+------+ $ osm nsd-list +----------+----------+ | nsd name | id | +----------+----------+ | pingpong | pingpong | +----------+----------+
Step 5: Instantiate example pingpong service
$ osm ns-create --nsd_name pingpong --ns_name test --vim_account emu-vim1
Step 6: Check service instance
# using OSM client $ osm vnf-list +----------------------------+--------------------------------------+--------------------+-------------------+ | vnf name | id | operational status | config status | +----------------------------+--------------------------------------+--------------------+-------------------+ | default__test__pong__2 | 788fd000-c0f2-4921-ace1-54646b804c9d | pre-init | config-not-needed | | default__test__ping__1 | 8cf2db31-58de-4454-85af-864a968846cf | pre-init | config-not-needed | +----------------------------+--------------------------------------+--------------------+-------------------+ $ osm ns-list +------------------+--------------------------------------+--------------------+---------------+ | ns instance name | id | operational status | config status | +------------------+--------------------------------------+--------------------+---------------+ | test | ea746088-efcf-11e7-bef9-005056b887c5 | running | configured | +------------------+--------------------------------------+--------------------+---------------+ # using vim-emu client $ sudo docker exec vim-emu vim-emu compute list +--------------+----------------------------+---------------+------------------+-------------------------+ | Datacenter | Container | Image | Interface list | Datacenter interfaces | +==============+============================+===============+==================+=========================+ | dc1 | dc1_test.ping.1.ubuntu | ubuntu:trusty | ping0-0 | dc1.s1-eth2 | +--------------+----------------------------+---------------+------------------+-------------------------+ | dc1 | dc1_test.pong.2.ubuntu | ubuntu:trusty | pong0-0 | dc1.s1-eth3 | +--------------+----------------------------+---------------+------------------+-------------------------+
Step 7: Interact with deployed VNFs
# connect to ping VNF container (in another terminal window): $ sudo docker exec -it mn.dc1_test.ping.1.ubuntu /bin/bash
# show network config root@dc1_test-nsi:/# ifconfig eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:03 inet addr:172.17.0.3 Bcast:0.0.0.0 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:648 (648.0 B) TX bytes:0 (0.0 B) ping0-0 Link encap:Ethernet HWaddr 4a:57:93:a0:d4:9d inet addr:192.168.100.3 Bcast:192.168.100.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) # ping the pong VNF over the attached management network root@dc1_test-nsi:/# ping -c2 192.168.100.4 PING 192.168.100.4 (192.168.100.4) 56(84) bytes of data. 64 bytes from 192.168.100.4: icmp_seq=1 ttl=64 time=0.070 ms 64 bytes from 192.168.100.4: icmp_seq=2 ttl=64 time=0.048 ms --- 192.168.100.4 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.048/0.059/0.070/0.011 ms
Step 8: Shut down
# delete service instance $ osm ns-delete test # stop emulation platform $ sudo docker stop vim-emu