1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

B OpenNebula/one#6541: onedb fsck fix Scheduled Actions (#3020)

This commit is contained in:
Pavel Czerný 2024-04-15 12:01:31 +02:00 committed by GitHub
parent 63ce359f94
commit a89ae0069a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,25 +34,37 @@ module OneDBFsck
query = 'SELECT * FROM schedaction_pool;' query = 'SELECT * FROM schedaction_pool;'
@db.fetch(query) do |row| @db.fetch(query) do |row|
update = false
doc = nokogiri_doc(row[:body], 'schedaction_pool') doc = nokogiri_doc(row[:body], 'schedaction_pool')
optional_args = ['MESSAGE', 'ARGS'] optional_args = { 'MESSAGE' => '',
optional_args.each do |att_name| 'ARGS' => '',
'DONE' => -1,
'REPEAT' => -1,
'DAYS' => '',
'END_TYPE' => -1,
'END_VALUE' => -1 }
optional_args.each do |att_name, default_value|
att = doc.root.at_xpath(att_name) att = doc.root.at_xpath(att_name)
next unless att.nil? next unless att.nil?
update = true
log_error("Scheduled action #{row[:oid]} doesn't have '#{att_name}' attribute", log_error("Scheduled action #{row[:oid]} doesn't have '#{att_name}' attribute",
true) true)
att = doc.create_element(att_name) att = doc.create_element(att_name)
doc.root.add_child(att).content = '' doc.root.add_child(att).content = default_value
end end
if update
row[:body] = doc.root.to_s row[:body] = doc.root.to_s
@to_update << row @to_update << row
end end
end end
end
# Fix broken Scheduled Actions # Fix broken Scheduled Actions
def fix_scheduled_actions def fix_scheduled_actions