Hello,
Is it possible to get the name that was set in a VM's xen config file from the guest machine? I'm interested in having my kickstart launch a script that can configure hostname, but to do that it would need to get the name set in the config.
Thanks, Ryan
Ryan,
--- On Tue, 3/9/10, Ryan Pugatch rpug@linux.com wrote:
From: Ryan Pugatch rpug@linux.com Subject: [CentOS-virt] get xen name from guest To: "Discussion about the virtualization on CentOS" centos-virt@centos.org Date: Tuesday, March 9, 2010, 8:18 PM Hello,
Is it possible to get the name that was set in a VM's xen config file from the guest machine? I'm interested in having my kickstart launch a script that can configure hostname, but to do that it would need to get the name set in the config.
the Xen xm .PY config has an extra = 'console=ttyS0 xxyyzz=HOSTNAME'
it seems that this is intended for the kernel cmdline, but the parser is very tolerant and picks and chooses what it wants.
It might work to add some exotic param which you grab from dmesg in script.
Brett Worth wrote:
On 03/10/2010 05:53 PM, Mr. X wrote:
the Xen xm .PY config has an extra = 'console=ttyS0 xxyyzz=HOSTNAME'
That's brilliant!
So if the parameter was "myname" then you could do:
hostname `cat /proc/cmdline | tr ' ' '\n' | awk -F= ' $1 == "myname" { print $2 } ' `
Brett
Agreed, that sounds great, but I am not sure what you mean by "Xen xm .PY config". Can you elaborate? Thanks
----- "Ryan Pugatch" rpug@linux.com wrote:
Hello,
Is it possible to get the name that was set in a VM's xen config file from the guest machine? I'm interested in having my kickstart launch a script that can configure hostname, but to do that it would need to get the name set in the config.
Thanks, Ryan
Since there isn't an rpm for the xenstore tools for guests, copy libxenstore.so.* and /usr/bin/xenstore-read (and the rest, if you want) to the guest and use something like this:
#!/bin/bash
let i=1
while [ $i -le 100 ]; do NAME=$(./xenstore-read /local/domain/$i/name 2> /dev/null)
[ -n "${NAME}" ] && break
let i++ done
[ -n "${NAME}" ] && echo ${NAME}
exit 0
I don't see why you would even need this, though. If you are using kickstart, you can get the hostname with either the static configuration or DHCP.
Christopher G. Stach II wrote:
----- "Ryan Pugatch" rpug@linux.com wrote:
Hello,
Is it possible to get the name that was set in a VM's xen config file from the guest machine? I'm interested in having my kickstart launch a script that can configure hostname, but to do that it would need to get the name set in the config.
Thanks, Ryan
Since there isn't an rpm for the xenstore tools for guests, copy libxenstore.so.* and /usr/bin/xenstore-read (and the rest, if you want) to the guest and use something like this:
#!/bin/bash
let i=1
while [ $i -le 100 ]; do NAME=$(./xenstore-read /local/domain/$i/name 2> /dev/null)
[ -n "${NAME}" ] && break let i++
done
[ -n "${NAME}" ] && echo ${NAME}
exit 0
I don't see why you would even need this, though. If you are using kickstart, you can get the hostname with either the static configuration or DHCP.
The reason I want to do this is so I don't have to specify in the kickstart the IP to use. With our Dell servers, for example, I just add the service tag in to DNS and then the server figures out what IP it is supposed to have.
Ryan
Hi,
how do you create the XEN-Config-File for your DomUs? As with DHCP you could use the MAC-Address to identify your DomU, too.
Apart from that you may set the hostname during setup of the DomU. I am using templates to generate new DomUs: After copying the template with rsync into the LV for the new DomU (an LV in Dom0 corresponds to a disk for the DomU) I modify the files where the hostname resides (and statically setup the first network interface by filling in the corresponding files of the DomU) before unmounting the LV again.
Are you really kickstarting each new DomU?
Kind regards
Nils
-----Ursprüngliche Nachricht----- Von: centos-virt-bounces@centos.org [mailto:centos-virt-bounces@centos.org] Im Auftrag von Ryan Pugatch Gesendet: Mittwoch, 10. März 2010 14:16 An: Discussion about the virtualization on CentOS Betreff: Re: [CentOS-virt] get xen name from guest
Christopher G. Stach II wrote:
----- "Ryan Pugatch" rpug@linux.com wrote:
Hello,
Is it possible to get the name that was set in a VM's xen
config file
from the guest machine? I'm interested in having my
kickstart launch
a script that can configure hostname, but to do that it
would need to
get the name set in the config.
Thanks, Ryan
Since there isn't an rpm for the xenstore tools for guests,
copy libxenstore.so.* and /usr/bin/xenstore-read (and the rest, if you want) to the guest and use something like this:
#!/bin/bash
let i=1
while [ $i -le 100 ]; do NAME=$(./xenstore-read /local/domain/$i/name 2> /dev/null)
[ -n "${NAME}" ] && break let i++
done
[ -n "${NAME}" ] && echo ${NAME}
exit 0
I don't see why you would even need this, though. If you
are using kickstart, you can get the hostname with either the static configuration or DHCP.
The reason I want to do this is so I don't have to specify in the kickstart the IP to use. With our Dell servers, for example, I just add the service tag in to DNS and then the server figures out what IP it is supposed to have.
Ryan
CentOS-virt mailing list CentOS-virt@centos.org http://lists.centos.org/mailman/listinfo/centos-virt
On 03/17/2010 08:47 AM, Hildebrand, Nils, 232 wrote:
Hi,
how do you create the XEN-Config-File for your DomUs? As with DHCP you could use the MAC-Address to identify your DomU, too.
Apart from that you may set the hostname during setup of the DomU. I am using templates to generate new DomUs: After copying the template with rsync into the LV for the new DomU (an LV in Dom0 corresponds to a disk for the DomU) I modify the files where the hostname resides (and statically setup the first network interface by filling in the corresponding files of the DomU) before unmounting the LV again.
Are you really kickstarting each new DomU?
Kind regards
Nils
The xen config file is created via virt-install and yes we do tend to do a kickstart for each DomU.
Ryan