From VNX
Revision as of 02:18, 8 June 2014 by David (talk | contribs) (Created page with "{{Title|VNX Tutorial (LXC version)}} == Description == VNX includes several example scenarios based on the [ VNUML tutoria...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

VNX Tutorial (LXC version)


VNX includes several example scenarios based on the VNUML tutorial scenario but including all types of virtual machines supported by VNX (see tutorial_*.xml files in /usr/share/vnx/examples directory).

The scenario presented here is made of 6 Ubuntu LXC virtual machines (4 hosts -h1, h2, h3 and h4- and 2 routers -r1 and r2-) connected through three virtual networks. The host participates in the scenario having a network interface in Net3. All systems use an Ubuntu server root filesystem.

Figure 1: tutorial_ubuntu scenario topology

Starting the scenario

Start the scenario with:

cd /usr/share/vnx/examples/
sudo vnx -f tutorial_lxc_ubuntu.xml -v --create

You will see the six textual consoles of the virtual machine consoles opening.

If you close the console of a VM (for example h4), you can reopen it with:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --console -M h4

LXC allows to open multiple textual consoles of each VM. Repeat the command to open new ones.

You can also open the consoles manually with the commands shown at the end of vnx execution:

 Scenario "tutorial_lxc_ubuntu" started

 h1          | lxc                 | con0:  'lxc-console -n h1'
             |                     | con1:  'lxc-console -n h1'
 h2          | lxc                 | con0:  'lxc-console -n h2'
             |                     | con1:  'lxc-console -n h2'
 r1          | lxc                 | con0:  'lxc-console -n r1'
             |                     | con1:  'lxc-console -n r1'
 r2          | lxc                 | con0:  'lxc-console -n r2'
             |                     | con1:  'lxc-console -n r2'
 h3          | lxc                 | con0:  'lxc-console -n h3'
             |                     | con1:  'lxc-console -n h3'
 h4          | lxc                 | con0:  'lxc-console -n h4'
             |                     | con1:  'lxc-console -n h4'

You can show the previous table at any time with:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --console-info

See VNX Console Management for more details about consoles.

Executing commands

You can start the web servers in h3 and h4 with:

sudo vnx -f tutorial_lxc_ubuntu.xml -v -x start-www -M h3,h4

This command will execute on h3 and h4 the commands defined by means of <exec> and <filetree> tags and marked with seq="start-www".

For example, for h3 virtual machine:

<filetree seq="start-www" root="/var/www">conf/tutorial_ubuntu/h3</filetree>
<exec seq="start-www" type="verbatim" ostype="system">chmod 644 /var/www/*</exec>
<exec seq="start-www" type="verbatim" ostype="system">service apache2 start</exec>

Once you have started the web servers, you can connect to them from the host or from h1 by opening a web navigator and loading

Additionally, you can start a firefox navigator in h1 automatically using vnx (login into h1 with vnx/xxxx or root/xxxx before executing the command):

sudo vnx -f tutorial_ubuntu.xml -v -x www-h3

And stop (kill) it with:

sudo vnx -f tutorial_ubuntu.xml -v -x www-h3-off

Both commands are defined in the XML with:

   <exec seq="www-h3"    type="verbatim" ostype="xexec">firefox</exec>
   <exec seq="www-h3-off" type="verbatim" ostype="system">pkill firefox</exec>
Figure 2: tutorial_ubuntu screen capture

Stopping the scenario

To stop the scenario preserving the changes made inside virtual machines you have to use the "-d" or "--shutdown" option:

sudo vnx -f tutorial_ubuntu.xml -v --shutdown

You can later restart the scenario with:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --start

To stop the scenario discarding all the changes made in the virtual machines use the "-P" or "--destroy" option:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --destroy

Other interesting options

You can restart the virtual machines individually with:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --shutdown -M h1
sudo vnx -f tutorial_lxc_ubuntu.xml -v --start -M h1

You can suspend to memory and restore a virtual machine with:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --suspend -M h1
sudo vnx -f tutorial_lxc_ubuntu.xml -v --resume -M h1

You can see a graphical map of the virtual scenario using the --show-map option:

sudo vnx -f tutorial_lxc_ubuntu.xml -v --show-map
Figure 1: tutorial_ubuntu scenario topology

tutorial_lxc_ubuntu.xml scenario