using ovmd and ovm_vmmessage to (re)configure your virtual machines.

What you need

  • Installation of ovm_utils on your manager ( p13602094_30_Linux-x86-64.zip available on metalink )
  • A VM with ovmd installed. Keep in mind that all OVM3 templates come with OVMD already installed. If you need to install it manually see this manual

How it works

ovmd is a listening process on your vm that allows messages to be send from and to the manager.
ovm_vmmessage is a utility included in ovm_utils that allows you to send messages to a vm in key/value pair.
the ovmd has a script called configure that can be executed to set system information. When you call it manually :

(vm1) # ovmd -s configure
Parameters:

u’com.oracle.linux.network.hostname’:
u’com.oracle.linux.network.host.0′:
u’com.oracle.linux.network.device.0′:
u’com.oracle.linux.network.hwaddr.0′:
u’com.oracle.linux.network.mtu.0′:
u’com.oracle.linux.network.onboot.0′:
u’com.oracle.linux.network.bootproto.0′:
u’com.oracle.linux.network.ipaddr.0′:
u’com.oracle.linux.network.netmask.0′:
u’com.oracle.linux.network.gateway.0′:
u’com.oracle.linux.network.dns-servers.0′:
u’com.oracle.linux.network.dns-search-domains.0′:
u’com.oracle.linux.root-password’: [required]

============================================================================

Input or edit parameter:

To use the current value, press “Enter”.
To input an empty string, input ” and press “Enter”.

Script: network
Key: com.oracle.linux.network.hostname
Description: System host name.
Required: False

Please input new value:

the parameters section will show you which keys the script accepts and recognises.
You can send these key/value pairs from the manager to the vm to skip the dialog.
f.e.

(manager) # ./ovm_vmmessage
Arguments :
-u [user name] Oracle VM Manager admin username (required)
-p [password] admin password (required)
-h [hostname] Oracle VM Manager hostname (required)
-X use secure (ssl) connection to port 54322
-v [vm name] virtual machine name
-U [vm UUID] virtual machine UUID
-k [key] key to send
-V [value] key-value to send (required when using -k)
-q [key] key to query

(manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.hostname -V test_ovmd
(manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.root-password -V rootroot

If you now check on your vm for the values, you’ll see the following :

(vm1) # ovmd -l
{“com.oracle.linux.network.hostname”:”test_ovmd”}
{“com.oracle.linux.root-password”:”rootroot”}

In order to make them active. Just run the ovmd -s configure script again. No dialog will be shown and all settings will be saved and active after a reboot.

(vm1) # ovmd -s configure
(vm1) # reboot

Configuring Templates

Now it becomes interesting!
Some of you might have recognised the questions the ‘ovmd -s configure’ command asked. These are actually the questions a newly created vm asks when it is cloned from the OVM3 templates of oracle. Wouldn’t it be interesting you don’t need to launch the console for each and every vm you create?

Well try this :

  • Create a new VM by cloning it from an OVM3 template/assembly available on edelivery ( f.e. OVM_OL6U2_x86_64_PVM.ova )
  • Boot the vm and let it sit on its dialogs
  • Run the following commands :

    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.hostname -V vm1
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.device.0 -V eth0
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.onboot.0 -V yes
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.bootproto.0 -V static
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.ipaddr.0 -V 10.100.23.36
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.netmask.0 -V 255.255.255.0
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.gateway.0 -V 10.100.23.254
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.network.dns-servers.0 -V 10.0.13.44
    (manager) # ./ovm_vmmessage -u admin -p password -h localhost -v vm1 -k com.oracle.linux.root-password -V rootroot

  • And voila. The minute your root password is set ( remember to do it last ), the information is loaded and the vm becomes active with all these settings applied. No need to launch the console. Awesome for batch creating vm’s.

It can be nice to reset all settings and make sure ovmd boots with the configure script again on next boot. You can do that by editing the /etc/sysconfig/ovmd script and set INITIAL_CONFIG=yes. Now stop the vm and clone it as vm/template, on first boot the dialog will start again and you’ll be able to send the commands or answer the questions.

I would like to point out this was tested on OracleVM 3.2.1 public beta but it should be applicable to 3.1.1 aswell.

You can find more information about this on the blog of Wim Couckaert.

Advertisements

16 responses to “using ovmd and ovm_vmmessage to (re)configure your virtual machines.

  1. Hello
    I downloaded a OVM RAC template (which should be ovmd-enabled).
    I typed “ovmd-l” and I didnt get any output,
    Do you have any ideas?
    Will post this also in the OVM forum
    Thanks,
    Rudi

  2. Hi Bjorn,

    I manually installed ovmd and its dependencies, sent messages to ovmd but the configure script does not apply the configuration…. any idea ?

    ovmd -l
    {“com.oracle.linux.network.hostname”:”another_ol58″}

    ovmd -d 1 -s configure

    ovmd[2731]: Dec 31 00:10:37 Successfully registered session with VMAPI
    ovmd[2731]: Dec 31 00:10:37 ovmd is running in Startup Script mode, using target configure
    ovmd[2731]: Dec 31 00:10:37
    runStartupScript was called for script /usr/sbin/ovm-template-config
    ovmd[2731]: Dec 31 00:10:37 First call to OVMAPI_ParamGetAllNames returns 7 with buffSize=256
    ovmd[2731]: Dec 31 00:10:37 Retrieved 1 param names
    ovmd[2731]: Dec 31 00:10:37 dumpParamsToChild returned
    ovmd[2731]: Dec 31 00:10:41 Detected child proess termination: waitID=2732 retCode=0 WIFEXITED(retCode)=1 WEXITSTATUS(retCode)=0
    ovmd[2731]: Dec 31 00:10:41 readParamsFromChild returned

    I expect /etc/sysconfig/network to change but it did not.

  3. Just realized that the OVM templates scripts and the RPM available in the OL5 repo for ovm-template config are quite different.

    The current OL5 RPM is:

    rpm -qil ovm-template-config
    Name : ovm-template-config Relocations: (not relocatable)
    Version : 3.0 Vendor: Oracle America
    Release : 68.el5 Build Date: Mon 11 Jun 2012 01:46:48 PM EDT
    Install Date: Mon 24 Dec 2012 01:03:59 PM EST Build Host: ca-build56.us.oracle.com
    Group : Applications/System Source RPM: ovm-template-config-3.0-68.el5.src.rpm
    Size : 203132 License: GPL
    Signature : DSA/SHA1, Mon 11 Jun 2012 01:46:55 PM EDT, Key ID 66ced3de1e5e0159
    URL : http://www.oracle.com/virtualization
    Summary : Oracle VM template configuration tool.
    Description :
    Oracle VM template configuration tool.

    While the one that ships with the OL5.7 template is:

    rpm -qi ovm-template-config
    Name : ovm-template-config Relocations: (not relocatable)
    Version : 1.1.0 Vendor: Oracle Corporation
    Release : 8.el5 Build Date: Fri 09 Sep 2011 02:44:16 PM EDT
    Install Date: Fri 09 Sep 2011 03:09:31 PM EDT Build Host: ca-build9.us.oracle.com
    Group : Utilities Source RPM: ovm-template-config-1.1.0-8.el5.src.rpm
    Size : 58494 License: GPLv2
    Signature : DSA/SHA1, Fri 09 Sep 2011 02:44:29 PM EDT, Key ID 66ced3de1e5e0159
    URL : http://oss.oracle.com/
    Summary : Oracle VM Template reconfiguration scripts
    Description :
    Configuration for Oracle VM Template boot.

    2 RPMS that are quite different….

    • You are correct. With the change from OVM 2.2 to OVM 3.0 the new templates were redesigned with the new OVMD utility included in the ovm-template-config RPM ( version 3.0 ). While the older 2.2 templates still use the original version. ( 1.1.0 ).

      That’s way this only works on OVM 3.0 templates. Make sure you download the correct one or create your own with the correct version of the ovm-template-config RPM.

      • Im testing with OVM 3.2.1 too and I can not get it to work with the current ovm-template-config RPM. It is all python now. I set 13 parameters from the OVM cli and I see them from the guest but ovmd wont apply any configuration. Note my guest is a default OL5.8 installation… not a template prepared by Oracle. I actually trying to create a template of my own.

  4. I got it working…. I probably had one of the ovm-templace-config-* RPM missing.

    Thnaks for the nice post. You put me on the right track.

  5. Hello,

    It firstly seem to us that this feature what we need, but seem to me we misunderstand it. I have also read all post of wimcoekaerts but haven’t found any hints. May be you could clarify.

    1. So ovmd should be called manually after sending parameter to run template scripts?
    2. There is no way to somehow trigger from OVM/soap/console some target to run?
    3. In addition I am not sure does ovmd run only on Oracle Linux/Redhat? Or it could be used on other linux based systems.
    4. As I understand there is no way to do such work (at least read message from OVM in guest) on non linux systems (windows, mac..)?

    We develop system (website) that allow provision of VMs (based on templates) on different platforms (vmware, hyper-v, now oracle). We use soap api to send commands. When clicking provision button in our system user could specify some guest settings (like ip, domain name etc, password). We should preconfigure guest after vm is created (after vmclone finished successfully) according user parameters. We do such tasks on other platforms passing such parameters to guest and then some vendor specific tools to read them on guest. After readin parameters our tools configure guest. From this point all is okay. We just download template. make sure ovmd is installed. run “service ovmd enable-initial-config” on vm created from downloaded template and create another template which will read these parameters on first start. So we have template we could use. The main problem is that user could change initial parameters and we should reapply them on guest (even add additional vnic with another ip, mask etc).

    • Hi,

      At this moment this is indeed a Linux only thing. As far as i know there is no way in triggering the start of a template by sending parameters. I solve this by periodic checking if a key/value pair has been send. If not, sleep until there is a key/value pair i can use.

      You can set your scripts to start on first boot and listen for key/value pairs ( like the ovm-template script does )

      kind regards
      Bjorn

      • I have already written daemon to check some parameter like “runOvmdAction” that trigger ovmd to run with provided target.

        You have mentioned about Linux only. Will it run correctly on Debian and other non REHL distributives. Or it is Oracle/REHL only? As far as I could see there are only rpm packages. Also as I have seen at least network utilities (that used in network template) have dependency on path and format specific for REHL.

  6. Is this still working in recent versions? This is acutally the only site I found something about this ovmapi where it is/was actually running.

    I cannot get ovmd to read the messages, as no connection to the host can be made from the virtual machine:

    # ovmd -l -d1
    ovmd[1142]: Apr 27 12:16:43 OVMAPI_Register (attempt 1) failed with code 1. VMAPI is not active.

    # grep -i ovmapi /var/log/messages
    Apr 27 12:16:43 ovm06 ovmd: No ovmapi providers found. Aborting
    Apr 27 12:16:43 ovm06 OVMAPI: No ovmapi providers found. Aborting

    The kernel-module is loaded, all packages listed in https://docs.oracle.com/cd/E27300_01/E27604/html/vmutl-guestadd-install.html are installed.

    Anyone got a hint for me?

    Those error message are even unknown to Google :-\

    • Hey Christian,

      Still works for me. Can you check with “ovm-chkconfig –list” if there are scripts actually enabled to listen for key/value pairs? Is the service started?

      Kind Regards
      Bjorn

      • My test-setup is gone, but yes, scripts were enabled.

        However, I cannot reproduce the issue in my current setup. The only difference is that it has been installed with Oracle Linux 6.5 and was then upgraded, while my previous setup was freshly installed with Oracle Linux 6.6.

        Now I’m able to configure machines using VM messages.

        Thanks anyway!

        Maybe I’ll find some time to verify an issue with 6.6 base install.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s