[Users] Obtain VM name from within VM?

Yuriy Demchenko demchenko.ya at gmail.com
Wed Jun 19 12:03:34 UTC 2013


On 06/19/2013 02:31 PM, Itamar Heim wrote:
> On 06/18/2013 10:59 AM, Yuriy Demchenko wrote:
>> Hi,
>>
>> Is VMpayload supported by oVirt 3.2.2 el6?
>
> it should be.
> have you tried first passing payload via the engine? 
erm, not quite understand what do you mean? via admin web-interface?
there's no fields/options related to payload in web interface, not in 
'edit vm' dialog, not in 'runonce' dialog (only 'attach cd/floppy', 
'custom properties' with fixed choice-list and general options).


However, I've achieved my goal some other way - wrote a hook that fills 
'SKU Number' bios field (not used by default) with VM name. It appeared 
even more simpler and convenient solution than vmpayload/fileinject. 
Hook is in attach, in case someone interested.
-------------- next part --------------
#!/usr/bin/python

import os
import sys
import hooking
import traceback


'''
vmname inject vdsm hook
====================
hook is getting VM name and writes it into bios 'SKU Number' field.

'''

if True:
    try:
        domxml = hooking.read_domxml()
        names = domxml.getElementsByTagName('name')[0]
        vmname = names.childNodes[0].nodeValue
        system = domxml.getElementsByTagName('system')[0]
        entry = domxml.createElement('entry')
        entry.setAttribute('name','sku')
        text = domxml.createTextNode(vmname)
        entry.appendChild(text)
        system.appendChild(entry)
        hooking.write_domxml(domxml)

    except:
        sys.stderr.write('name-inject: [unexpected error]: %s\n' %
                         traceback.format_exc())
        sys.exit(2)


More information about the Users mailing list