Posts Tagged ‘Network’

Xen Server 5.0.0 SDK relative

March 29th, 2010 jmguilla No comments

A little post just because I ruined my day trying to get virtual machine’s mac addresses, ip addresses and heartbeat and because the right way to do it is not really enlightened in the SDK’s documentation:

Get the com.xensource.xenapi.VM you want to get information from. For ip addresses, getVMGuestMetrics method and getNetworks, it will give you all network related information, ip address included. For mac address, you have a public getter on com.xensource.xenapi.VIF object, that you can have from your virtual machine thanks to the method getVIFs ( ok, this one is the easier ). For the heartbeat, once you have the com.xensource.xenapi.VMGuestMetrics of the appropriate virtual machine, a getLive method will give you the virtual machine status ( true, the vm is running normally, false, it is experiencing troubles, probably with cpu charge )…

Is Libvirt powerful enough?

March 22nd, 2010 jmguilla No comments

Today I’ve been discussing with my CTO why Libvirt is not mature enough for multi-virtualization environment management and why it has not replaced editors’ management solutions yet…

From an application deployment point of view, the most important thing we need it’s the capability to dynamically modify the virtual machines, or at least, the users’ environment. This way, we are able to bootstrap application environment when the VM boots ( really useful when you use template or clone… ). Furthermore, if the application deployment fails, you need a way to find where did it fail. It is really important to know what is the deployment status from the network point of view ( has the NIC been mounted? Has the VM got an IP address? What is the IP address? ).

VMware guest mac address

March 18th, 2010 jmguilla No comments
It is part of my job to programmatically manage virtual environments. Finding a way to determine if the virtual machines are correctly up on the network is important. To open a RDP and check it by hand is pretty boring… Fortunatly, many APIs give developpers the capability to find NIC’s mac address, guest IP…
One of the development environments one can use to manage VMware virtualization environement is VMware VIX. We can happily see that it exists a mean to get guest IP ( OK, it is not really enlightened anywhere in the API, but after a little of google… it came the getGuestProperty “guestinfo.ip”… ) but nothing was done regarding NIC’s mac address.

The best way I found so far, is to log in guest and run a script that will set guest properties to the found addresses. Vix API makes us able to do such things, the hot point is “what script should I run in guest?”. For every linux based OSes, it is straight forward:

ifconfig | sed -rn ’s/.*(([0-9a-fA-F]{2}[-:]){5}[0-9a-fA-F]{2})/\1/p’ | while read mac ; do index=$(($index+1)); vmware-guestd –cmd “info-set guestinfo.guestmac.$index $mac”; done

Once the script has run successfully, just iterate through guestinfo.guestmac.[1 2 3 ... ] properties until one gets null or empty string value. It was more complicated for Windows OSes, first because I’m ( or I was, this will maybe be the subject of an upcoming post ) a Linux fan boy, but also because the default command interpreter ( cmd.exe, which is only a dos emulator ) has a really “poor” default set of commands. Furthermore, we wanted that to work both on desktop & server Microsoft windows. Here is the script:

VMwareService –cmd “info-set guestinfo.guestmac 0″
ipconfig /all|findstr [0-9a-fA-F][0-9a-fA-F][-:][0-9a-fA-F][0-9a-fA-F][-:][0-9a-fA-F][0-9a-fA-F][-:][0-9a-fA-F][0-9a-fA-F][-:] > %TEMP%\\PA_MAC.txt
SET /p pa_vmm_tmp=<%TEMP%\\PA_MAC.txt
VMwareService –cmd “info-set guestinfo.guestmac %pa_vmm_tmp%

As you may have noticed, once you get the guest property, it remains a little regexp to get the expected mac addresses… oops, sorry, the mac address. Yeah, this is the pitfall, this will make you able to get only one mac address. I hope somebody will give me the right way, Microsoft Windows OSes independent to get every mounted NID’s mac addresses.

I hope this will help!