1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

B #5492: change-body modifies db instead of API data

This commit is contained in:
Javi Fontan 2017-10-27 16:54:12 +02:00
parent 82c8fcbf97
commit c631781bef

View File

@ -343,8 +343,20 @@ class OneDBLive
next unless check_expr(o, options[:expr])
end
o.info
doc = Nokogiri::XML(o.to_xml, nil, NOKOGIRI_ENCODING) do |c|
# Get body from the database
begin
db_data = select(table, "oid = #{o.id}")
rescue => e
STDERR.puts "Error getting object id #{o.id}"
STDERR.puts e.message
STDERR.puts e.backtrace
next
end
row = db_data.first
body = Base64.decode64(row['body64'])
doc = Nokogiri::XML(body, nil, NOKOGIRI_ENCODING) do |c|
c.default_xml.noblanks
end
@ -361,7 +373,14 @@ class OneDBLive
if options[:dry]
puts xml
else
update_body(table, xml, "oid = #{o.id}", federate)
begin
update_body(table, xml, "oid = #{o.id}", federate)
rescue => e
STDERR.puts "Error updating object id #{o.id}"
STDERR.puts e.message
STDERR.puts e.backtrace
next
end
end
end
end