1

On XenServer is there any way to read VM metadata (Custom fields, Tags, VM Name) from inside the VM using Linux (CentOS 5.8) ?

Basically what I want to do is:

  1. Create new VM using

    xe vm-install template=MYTEMPLATE new-name-label=MYVM

  2. Read metadata to configure VM hostname, IP address, etc

On EC2 you can pass an user-data-file containing a script when you launch a new VM. Once the VM comes up the script is executed. Similar to this:

ec2-run-instances --key KEYPAIR --user-data-file CONFIGURE-SCRIPT ami-bf5eb9d6

I can pass some information to the VM using "OS boot parameters" inside "BOOT OPTIONS"

# cat /proc/cmdline 
ro root=/dev/vg0/root console=xvc0  CUSTOMTEXT

This does not look very elegant to me and may interfere with some real Linux boot parameters. Another problem is that the CUSTOMTEXT will continue to be passed to the VM on every boot.

I just need a way to pass a few parameters once during VM creation and run a script that will use those parameters on first boot.

any ideas ?

cheers

Gustavo

Nils
  • 7,695
  • 3
  • 34
  • 73
Luis
  • 306
  • 1
  • 2
  • 11

1 Answers1

2

After searching a bit more on Google, the answer to this problem is XenStore (http://wiki.xen.org/wiki/XenStore)

To get the VM name (domU) from Linux run:

xenstore-ls /local/domain/`xenstore-read domid`

Additional links with useful solutions:

http://forums.citrix.com/thread.jspa?threadID=264531

How to find dom0 name from hosted domU

http://old-list-archives.xen.org/archives/html/xen-users/2010-11/msg00179.html

https://wiki.openstack.org/wiki/GuestAgentXenStoreCommunication

Luis
  • 306
  • 1
  • 2
  • 11