1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

bug #1080: acctd error when monitoring VMs with no history

This commit is contained in:
Daniel Molina 2012-01-23 17:18:43 +01:00
parent c38bfca219
commit 2173fae048

View File

@ -93,29 +93,30 @@ module OneWatch
last_register = vm_sql.registers.last
seq = last_register ? last_register.seq : 0
if hr = vm['HISTORY_RECORDS']
unless hr['HISTORY'].instance_of?(Array)
if hr['HISTORY']['SEQ'] == seq
# The VM has not moved from the Host
insert_register(vm_sql, last_register, hr['HISTORY'])
return
else
hr = vm['HISTORY_RECORDS']
if hr and !hr.empty?
if hr['HISTORY']['SEQ'] == seq
# The VM has not moved from the Host
insert_register(vm_sql, last_register, hr['HISTORY'])
return
else
unless hr['HISTORY'].instance_of?(Array)
# Get the full HISTORY
vm = OpenNebula::VirtualMachine.new_with_id(vm['ID'], @client)
vm.info
vm_hash = vm.to_hash['VM']
hr = vm_hash['HISTORY_RECORDS']
# Insert a new entry for each new history record
[hr['HISTORY']].flatten.each { |history|
if history['SEQ'].to_i < seq
next
else
insert_register(vm_sql, last_register, history)
end
}
end
# Insert a new entry for each new history record
[hr['HISTORY']].flatten.each { |history|
if history['SEQ'].to_i < seq
next
else
insert_register(vm_sql, last_register, history)
end
}
end
end
end