[one-users] Host hooks aren't triggered

Tino Vazquez tinova79 at gmail.com
Fri Apr 1 09:06:57 PDT 2011


Hi,

Everything seems alright, except for the xpath expression returned nil
object. So please let's try debugging the vms fetched:

---
class OpenNebula::VirtualMachinePool
  attr_reader :xml
end

my_file.puts vms.xml
---

Regards,

-Tino

--
Constantino Vázquez Blanco | dsa-research.org/tinova
Virtualization Technology Engineer / Researcher
OpenNebula Toolkit | opennebula.org



On Fri, Apr 1, 2011 at 5:47 PM, Zaina AFOULKI
<zaina.afoulki at ensi-bourges.fr> wrote:
> Hi Tino,
>
> I added the lines as you asked and I get this in the /tmp/remove_me.txt
> OpenNebula host  NilClass
> NilClass
>
> $ onehost list -x
> <HOST_POOL>
>  <HOST>
>    <ID>29</ID>
>    <NAME>node1</NAME>
>    <STATE>2</STATE>
>    <IM_MAD>im_kvm</IM_MAD>
>    <VM_MAD>vmm_kvm</VM_MAD>
>    <TM_MAD>tm_nfs</TM_MAD>
>    <LAST_MON_TIME>1301672703</LAST_MON_TIME>
>    <CLUSTER>default</CLUSTER>
>    <TEMPLATE>
>      <ARCH><![CDATA[x86_64]]></ARCH>
>      <CPUSPEED><![CDATA[1998]]></CPUSPEED>
>      <FREECPU><![CDATA[90.6]]></FREECPU>
>      <FREEMEMORY><![CDATA[770956]]></FREEMEMORY>
>      <HOSTNAME><![CDATA[node1]]></HOSTNAME>
>      <HYPERVISOR><![CDATA[kvm]]></HYPERVISOR>
>      <MODELNAME><![CDATA[Intel(R) Core(TM)2 Duo CPU E6550 @
> 2.33GHz]]></MODELNAME>
>      <NETRX><![CDATA[0]]></NETRX>
>      <NETTX><![CDATA[0]]></NETTX>
>      <TOTALCPU><![CDATA[200]]></TOTALCPU>
>      <TOTALMEMORY><![CDATA[2056676]]></TOTALMEMORY>
>      <USEDCPU><![CDATA[109.4]]></USEDCPU>
>      <USEDMEMORY><![CDATA[1285720]]></USEDMEMORY>
>    </TEMPLATE>
>    <HOST_SHARE>
>      <HID>29</HID>
>      <DISK_USAGE>0</DISK_USAGE>
>      <MEM_USAGE>262144</MEM_USAGE>
>      <CPU_USAGE>10</CPU_USAGE>
>      <MAX_DISK>0</MAX_DISK>
>      <MAX_MEM>2056676</MAX_MEM>
>      <MAX_CPU>200</MAX_CPU>
>      <FREE_DISK>0</FREE_DISK>
>      <FREE_MEM>770956</FREE_MEM>
>      <FREE_CPU>90</FREE_CPU>
>      <USED_DISK>0</USED_DISK>
>      <USED_MEM>1285720</USED_MEM>
>      <USED_CPU>109</USED_CPU>
>      <RUNNING_VMS>1</RUNNING_VMS>
>    </HOST_SHARE>
>  </HOST>
>  <HOST>
>    <ID>31</ID>
>    <NAME>node2</NAME>
>    <STATE>4</STATE>
>    <IM_MAD>im_kvm</IM_MAD>
>    <VM_MAD>vmm_kvm</VM_MAD>
>    <TM_MAD>tm_nfs</TM_MAD>
>    <LAST_MON_TIME>1301672409</LAST_MON_TIME>
>    <CLUSTER>default</CLUSTER>
>    <TEMPLATE>
>      <ARCH><![CDATA[x86_64]]></ARCH>
>      <CPUSPEED><![CDATA[1998]]></CPUSPEED>
>      <FREECPU><![CDATA[200.0]]></FREECPU>
>      <FREEMEMORY><![CDATA[1800824]]></FREEMEMORY>
>      <HOSTNAME><![CDATA[node2]]></HOSTNAME>
>      <HYPERVISOR><![CDATA[kvm]]></HYPERVISOR>
>      <MODELNAME><![CDATA[Intel(R) Core(TM)2 Duo CPU E6550 @
> 2.33GHz]]></MODELNAME>
>      <NETRX><![CDATA[0]]></NETRX>
>      <NETTX><![CDATA[0]]></NETTX>
>      <TOTALCPU><![CDATA[200]]></TOTALCPU>
>      <TOTALMEMORY><![CDATA[2056676]]></TOTALMEMORY>
>      <USEDCPU><![CDATA[0.0]]></USEDCPU>
>      <USEDMEMORY><![CDATA[255852]]></USEDMEMORY>
>    </TEMPLATE>
>    <HOST_SHARE>
>      <HID>31</HID>
>      <DISK_USAGE>0</DISK_USAGE>
>      <MEM_USAGE>0</MEM_USAGE>
>      <CPU_USAGE>0</CPU_USAGE>
>      <MAX_DISK>0</MAX_DISK>
>      <MAX_MEM>2056676</MAX_MEM>
>      <MAX_CPU>200</MAX_CPU>
>      <FREE_DISK>0</FREE_DISK>
>      <FREE_MEM>1800824</FREE_MEM>
>      <FREE_CPU>200</FREE_CPU>
>      <USED_DISK>0</USED_DISK>
>      <USED_MEM>255852</USED_MEM>
>      <USED_CPU>0</USED_CPU>
>      <RUNNING_VMS>0</RUNNING_VMS>
>    </HOST_SHARE>
>  </HOST>
> </HOST_POOL>
>
>
>
> $ onevm list -x
>
>
> <VM_POOL>
>  <VM>
>    <ID>3056</ID>
>    <UID>2</UID>
>    <USERNAME>sfr</USERNAME>
>    <NAME>sfr-ar</NAME>
>    <LAST_POLL>1301672685</LAST_POLL>
>    <STATE>3</STATE>
>    <LCM_STATE>3</LCM_STATE>
>    <STIME>1301672613</STIME>
>    <ETIME>0</ETIME>
>    <DEPLOY_ID>one-3056</DEPLOY_ID>
>    <MEMORY>0</MEMORY>
>    <CPU>0</CPU>
>    <NET_TX>0</NET_TX>
>    <NET_RX>0</NET_RX>
>    <LAST_SEQ>0</LAST_SEQ>
>    <TEMPLATE>
>      <CPU><![CDATA[0.1]]></CPU>
>      <DISK>
>        <DISK_ID><![CDATA[0]]></DISK_ID>
>        <SOURCE><![CDATA[/home/oneadmin/vmu.img]]></SOURCE>
>        <TARGET><![CDATA[sda]]></TARGET>
>      </DISK>
>      <FEATURES>
>        <ACPI><![CDATA[yes]]></ACPI>
>      </FEATURES>
>      <HAIZEA>
>        <DURATION><![CDATA[00:07:00]]></DURATION>
>        <PREEMPTIBLE><![CDATA[no]]></PREEMPTIBLE>
>        <START><![CDATA[+00:00:50]]></START>
>      </HAIZEA>
>      <MEMORY><![CDATA[256]]></MEMORY>
>      <NAME><![CDATA[sfr-ar]]></NAME>
>      <NIC>
>        <BRIDGE><![CDATA[br0]]></BRIDGE>
>        <IP><![CDATA[172.30.8.12]]></IP>
>        <MAC><![CDATA[02:00:ac:1e:08:0c]]></MAC>
>        <NETWORK><![CDATA[orange_public]]></NETWORK>
>        <NETWORK_ID><![CDATA[20]]></NETWORK_ID>
>      </NIC>
>      <OS>
>        <BOOT><![CDATA[hd]]></BOOT>
>        <ROOT><![CDATA[sda]]></ROOT>
>      </OS>
>      <RAW>
>        <DATA><![CDATA[<devices><serial type="pty"><source
> path="/dev/pts/5"/><target port="0"/></serial><console type="pty"
> tty="/dev/pts/5"><source path="/dev/pts/5"/><target
> port="0"/></console><graphics type="vnc" port="5901"
> autoport="yes"/></devices>]]></DATA>
>        <TYPE><![CDATA[kvm]]></TYPE>
>      </RAW>
>      <VMID><![CDATA[3056]]></VMID>
>    </TEMPLATE>
>    <HISTORY>
>      <SEQ>0</SEQ>
>      <HOSTNAME>node1</HOSTNAME>
>      <HID>29</HID>
>      <STIME>1301672663</STIME>
>      <ETIME>0</ETIME>
>      <PSTIME>1301672663</PSTIME>
>      <PETIME>1301672665</PETIME>
>      <RSTIME>1301672665</RSTIME>
>      <RETIME>0</RETIME>
>      <ESTIME>0</ESTIME>
>      <EETIME>0</EETIME>
>      <REASON>0</REASON>
>    </HISTORY>
>  </VM>
>  <VM>
>    <ID>3057</ID>
>    <UID>2</UID>
>    <USERNAME>sfr</USERNAME>
>    <NAME>sfr-ar</NAME>
>    <LAST_POLL>1301672685</LAST_POLL>
>    <STATE>3</STATE>
>    <LCM_STATE>3</LCM_STATE>
>    <STIME>1301672614</STIME>
>    <ETIME>0</ETIME>
>    <DEPLOY_ID>one-3057</DEPLOY_ID>
>    <MEMORY>0</MEMORY>
>    <CPU>0</CPU>
>    <NET_TX>0</NET_TX>
>    <NET_RX>0</NET_RX>
>    <LAST_SEQ>0</LAST_SEQ>
>    <TEMPLATE>
>      <CPU><![CDATA[0.1]]></CPU>
>      <DISK>
>        <DISK_ID><![CDATA[0]]></DISK_ID>
>        <SOURCE><![CDATA[/home/oneadmin/vmu.img]]></SOURCE>
>        <TARGET><![CDATA[sda]]></TARGET>
>      </DISK>
>      <FEATURES>
>        <ACPI><![CDATA[yes]]></ACPI>
>      </FEATURES>
>      <HAIZEA>
>        <DURATION><![CDATA[00:07:00]]></DURATION>
>        <PREEMPTIBLE><![CDATA[no]]></PREEMPTIBLE>
>        <START><![CDATA[+00:00:50]]></START>
>      </HAIZEA>
>      <MEMORY><![CDATA[256]]></MEMORY>
>      <NAME><![CDATA[sfr-ar]]></NAME>
>      <NIC>
>        <BRIDGE><![CDATA[br0]]></BRIDGE>
>        <IP><![CDATA[172.30.8.10]]></IP>
>        <MAC><![CDATA[02:00:ac:1e:08:0a]]></MAC>
>        <NETWORK><![CDATA[orange_public]]></NETWORK>
>        <NETWORK_ID><![CDATA[20]]></NETWORK_ID>
>      </NIC>
>      <OS>
>        <BOOT><![CDATA[hd]]></BOOT>
>        <ROOT><![CDATA[sda]]></ROOT>
>      </OS>
>      <RAW>
>        <DATA><![CDATA[<devices><serial type="pty"><source
> path="/dev/pts/5"/><target port="0"/></serial><console type="pty"
> tty="/dev/pts/5"><source path="/dev/pts/5"/><target
> port="0"/></console><graphics type="vnc" port="5901"
> autoport="yes"/></devices>]]></DATA>
>        <TYPE><![CDATA[kvm]]></TYPE>
>      </RAW>
>      <VMID><![CDATA[3057]]></VMID>
>    </TEMPLATE>
>    <HISTORY>
>      <SEQ>0</SEQ>
>      <HOSTNAME>node2</HOSTNAME>
>      <HID>31</HID>
>      <STIME>1301672664</STIME>
>      <ETIME>0</ETIME>
>      <PSTIME>1301672664</PSTIME>
>      <PETIME>1301672684</PETIME>
>      <RSTIME>1301672684</RSTIME>
>      <RETIME>0</RETIME>
>      <ESTIME>0</ESTIME>
>      <EETIME>0</EETIME>
>      <REASON>0</REASON>
>    </HISTORY>
>  </VM>
> </VM_POOL>
>
>
>
> On Fri, 1 Apr 2011 17:31:44 +0200, Tino Vazquez wrote:
>>
>> Hi,
>>
>> Please try the following:
>>
>> my_file.puts "OpenNebula host  #{vm_ids_array.class}"
>> my_file.puts vm_ids_array.class
>>
>> Also, please send the output of
>>
>> $ onehost list -x
>> $ onevm list -x
>>
>> Regards,
>>
>> -Tino
>>
>> --
>> Constantino Vázquez Blanco | dsa-research.org/tinova
>> Virtualization Technology Engineer / Researcher
>> OpenNebula Toolkit | opennebula.org
>>
>>
>>
>> On Fri, Apr 1, 2011 at 5:23 PM, Zaina AFOULKI
>> <zaina.afoulki at ensi-bourges.fr> wrote:
>>>
>>> Hi Tino,
>>>
>>> I added this to the ruby script (I'm new to Ruby, so I'm not sure it's
>>> correct):
>>>
>>> my_file.puts "OpenNebula host  #{vm_ids_array.class}"
>>> for item in 0...vm_ids_array.length
>>>        my_file.puts " #{vm_ids_array[item]}";
>>> end
>>>
>>> $cat /tmp/remove_me.txt
>>> OpenNebula host has failed 31
>>> NilClass
>>>
>>> oned.log:
>>>
>>> Fri Apr  1 17:16:36 2011 [HKM][D]: Message received: LOG - 31 Command
>>> execution fail: /home/oneadmin/one/share/hooks/host_error.rb 31 -r y
>>> Fri Apr  1 17:16:36 2011 [HKM][D]: Message received: LOG - 31 STDERR
>>> follows.
>>> Fri Apr  1 17:16:36 2011 [HKM][D]: Message received: LOG - 31
>>> /home/oneadmin/one/share/hooks/host_error.rb:81: undefined method
>>> `length'
>>> for nil:NilClass (NoMethodError)
>>>
>>> Thanks for your help,
>>>
>>> --
>>> Zaina
>>>
>>> On Fri, 1 Apr 2011 12:31:21 +0100, Tino Vazquez wrote:
>>>>
>>>> Hi Zaina,
>>>>
>>>> Could you please print out also the content of "vm_ids_array"? I am
>>>> afraid the xpath expression may not be doing its job.
>>>>
>>>> Regards,
>>>>
>>>> -Tino
>>>>
>>>> --
>>>> Constantino Vázquez Blanco, MSc
>>>> OpenNebula Major Contributor
>>>> www.OpenNebula.org | @tinova79
>>>>
>>>>
>>>>
>>>> On Fri, Apr 1, 2011 at 8:57 AM, Zaina AFOULKI
>>>> <zaina.afoulki at ensi-bourges.fr> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I checked the ruby script that's called and it seems that the array
>>>>> containing the list of VMs is empty
>>>>> vm_ids_array =
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> vms.retrieve_elements("/VM_POOL/VM[STATE=3]/HISTORY[HOSTNAME=\"#{host_name}\"]/../ID")
>>>>>
>>>>> I tried printing something to a tmp file to make sure that the script
>>>>> gets
>>>>> the right host id.
>>>>> my_file = File.new("/tmp/remove_me.txt", "w")
>>>>> my_file.puts "OpenNebula host has failed #{ARGV[0]}"
>>>>>
>>>>> The hostname and host_id are correctly detected by the script.
>>>>>
>>>>> Thank you for any hints on how to fix this,
>>>>>
>>>>> --
>>>>> Zaina
>>>>>
>>>>> On Thu, 31 Mar 2011 16:36:22 +0200, Zaina AFOULKI wrote:
>>>>>>
>>>>>> I just checked back the oned.log and it seems that the hook is
>>>>>> executed
>>>>>> [HKM][D]: Message received: EXECUTE SUCCESS 31 disable
>>>>>>
>>>>>> However the VMs aren't re-submitted as expected ?
>>>>>>
>>>>>> Thanks,
>>>>>> --
>>>>>> Zaina
>>>>>>
>>>>>> On Thu, 31 Mar 2011 16:20:27 +0200, Zaina AFOULKI wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm having some trouble getting the HOST_HOOKS to work:
>>>>>>> I added this to the configuration file and restarted oned.
>>>>>>>
>>>>>>> HOST_HOOK = [
>>>>>>>    name      = "disable",
>>>>>>>    on        = "DISABLE",
>>>>>>>    command   = "host_error.rb",
>>>>>>>    arguments = "$HID -r y",
>>>>>>>    remote    = "no" ]
>>>>>>>
>>>>>>> However when I disable a host using "onehost disable" the VMs aren't
>>>>>>> re-submitted.
>>>>>>> The oned.log doesn't indicate that the hook has been triggered.
>>>>>>>
>>>>>>> I'm using OpenNebula 2.2 and the script host_error.rb is indeed
>>>>>>> located in my $ONE_LOCATION/share/hooks/
>>>>>>>
>>>>>>> What am I doing wrong? Thanks
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.opennebula.org
>>>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>>>
>>>
>>> --
>>> Zaina AFOULKI
>>> Étudiante à l'Ecole Nationale Supérieure d'Ingénieurs de Bourges.
>>> 1ère année Sécurité et Technologies Informatiques
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opennebula.org
>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>
>
> --
> Zaina AFOULKI
> Étudiante à l'Ecole Nationale Supérieure d'Ingénieurs de Bourges.
> 1ère année Sécurité et Technologies Informatiques
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>



More information about the Users mailing list