Page -> Vnx-autoconf Views :  Page  Discussion  View source  History 

From VNX

Autoconfiguration and Command Execution (ACE)

Command execution  

Users can directly interact with virtual machines through their consoles or management interfaces. However, in order to automate the execution of commands in virtual machines, VNX provides three tags for that purpose:

  • <filetree>, to copy of files from the host to the virtual machines,
  • <exec>, to execute commands inside virtual machines, and
  • <cmd-seq>, to create composed command sequences.

All of them have an attribute named "seq" that allows to associate a string identifier to them. This identifier is used to invoke the execution of that commands from the VNX command line. For example:

vnx -f tutorial_lxc_ubuntu.xml --execute start-www

will execute all the commands defined in 'tutorial_lxc_ubuntu.xml' with the attribute seq='start-www'. The parameter passed to '--execute' option can be a comma-separated list of seq identifiers to allow executing several set of commands. For example:

vnx -f tutorial_lxc_ubuntu.xml --execute stop-www,start-www

will execute in sequentially the set of commands identified by 'stop-www' and 'start-www'.

For a given seq value, all <filetree> commands are always executed before <exec> ones.

Copying files: <filetree> tag  

<filetree> tag is used to copy files from the host to a virtual machine. The value inside the tag specifies the file or directory to be copied to the virtual machine.

The destination directory or filename inside the virtual machine where the file(s) will be copied is specified using the 'root' attribute.

By convention, directory names have to be terminated with an '/' to distinguis them from filenames.

The attributes user, group and perms can be used to specify respectively the owner, group and permisions of the files copied. Permissions have to be specified using linux numerical style (i.e. '644').

Examples:

  • Copy all the files and directories under host directory conf/R1/1 (relative path to the directory where the XML file resides) to /etc/quagga directory of VM:
  • <filetree seq='copy1' root='/etc/quagga/'>conf/R1/1/</filetree>
    
  • Copy the host file conf/H2/test-page.html to /var/www/html directory, change its name to index.html, change its owner:group to www-data:www-data and change its permissions to 644
  • <filetree seq='copy2' user='www-data' group='www-data' perms='644' root='/var/www/html/index.html'>
      conf/H2/test-page.html
    </filetree>'
    

Executing commands: <exec> tag  

<exe> tag is used to execute commands on the virtual machines. The commands to be executed are specified in the tag value. The way commands are specified depends on the value of type attribute:

  • verbatim, in this case, the tag value directly specifies the commands to execute, in one or several lines
  • file, in this case, the tag value specifies the name of a file which contains the commands to execute.

The "ostype" attribute is used to specify the type of command included in <exec> tag, either command line (CLI) or graphical (GUI), and whether vnx tool waits for command execution end or not.

For libvirt VMs, four values are posible for the ostype attribute:

ostype Type of commands Waits for command execution end
system CLI YES
exec CLI NO
xsystem GUI YES
xexec GUI NO

For LXC VMs only system and exec values can be used.

In the case of dynamips VMs, ostype possible values are:

  • show, for commands that will be executed in console exec mode.
  • set, for commands to be added to the router configuration.
  • load, for loading a new configuration file. In this case the tag value specifies the name of the config file. If the name is preceded with the word 'merge', the new configuration is merged with the present configuration of the router.

Examples:

  • Define two basic commands to start and stop zebra and quagga daemons:
  • <exec seq="start_ospf" type="verbatim" ostype="system">
      /usr/lib/quagga/zebra -d
      /usr/lib/quagga/ospfd -d
    </exec>
    
    <exec seq="stop_ospf" type="verbatim" ostype="system">
      killall vtysh
      killall zebra
      killall ospfd
    </exec>
    

Note: multiline commands can be defined inside an <exec> tag by using the standard convention of ending the first lines with an '\'

<exec seq="kk" type="verbatim">
  touch \
    /tmp/file1 \
    /tmp/file2 \
    /tmp/file3
</exec>

Creating composed command sequences: <cmd-seq> tag  

<cmd-seq> tag is used to create composed sequences of commands. The value inside the tag (seq-list) is a comma separated list of seq attribute values of commands defined in <filetree>, <exec> or even other <cmd-seq> tags.

When a composed command sequence is executed, VNX firstly expands the seq-list substituting all the seq-values belonging to other <cmd-seq> tags with the basic commands (<filetree>'s and <exec>'s) defined for them. Once the list is expanded, all the commands are executed sequentially following the order in which they where defined.

<cmd-seq> tags can be specific for concrete VMs (defined inside <vm> tag) or global (defined inside <global> tag.

Examples:

  • Define two command sequences (conf1 and conf2) to restart ospdd quagga daemon loading a new configuration:
  • <filetree seq="copy_conf1" root="/etc/quagga/">conf/RA/1/</filetree>
    
    <filetree seq="copy_conf2" root="/etc/quagga/">conf/RA/2/</filetree>
    
    <exec seq="start_ospf" type="verbatim" ostype="system">
      /usr/lib/quagga/zebra -d
      /usr/lib/quagga/ospfd -d
    </exec>
    
    <exec seq="stop_ospf" type="verbatim" ostype="system">
      killall vtysh
      killall zebra
      killall ospfd
    </exec>
    
    <cmd-seq seq='conf1'>stop_ospf,copy_conf1,start_ospf</cmd-seq>
    <cmd-seq seq='conf2'>stop_ospf,copy_conf2,start_ospf</cmd-seq>
    
    


Autoconfiguration

To be completed....




TOOLBOX
LANGUAGES
Personal tools