<div dir="ltr">Hi,<div><br></div><div>Your approach looks correct. The cpu element should also work with simple text instead of cdata.</div><div>Refer to the REXML docs for more information: <a href="http://ruby-doc.org/stdlib-2.1.1/libdoc/rexml/rdoc/index.html">http://ruby-doc.org/stdlib-2.1.1/libdoc/rexml/rdoc/index.html</a></div>
<div><br></div><div>Regards</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">--<br><div>Carlos Martín, MSc<br>Project Engineer</div><div>OpenNebula - Flexible Enterprise Cloud Made Simple<br><div><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:cmartin@opennebula.org" target="_blank">cmartin@opennebula.org</a> | <a href="http://twitter.com/opennebula" target="_blank">@OpenNebula</a></span><span style="border-collapse:collapse;color:rgb(136,136,136);font-family:arial,sans-serif;font-size:13px"><a href="mailto:cmartin@opennebula.org" style="color:rgb(42,93,176)" target="_blank"></a></span></div>
</div></div></div>
<br><br><div class="gmail_quote">On Tue, Apr 15, 2014 at 11:11 PM, Hyun Woo Kim <span dir="ltr"><<a href="mailto:hyunwoo@fnal.gov" target="_blank">hyunwoo@fnal.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div style="font-family:Calibri,sans-serif;font-size:14px">I have found one possible solution</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px">I modified <span style="font-size:medium">/usr/lib/one/ruby/onedb/3.8.5_to_3.9.30.rb as follows;</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium"><br>
</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium">
<div style="font-family:Calibri,sans-serif;font-size:14px"> @db.fetch("SELECT * FROM old_template_pool") do |row|</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> doc = Document.new(row[:body])</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> template = nil</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> doc.root.each_element("TEMPLATE") do |e|</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> template = e</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> end</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> doc.root.each_element("TEMPLATE") do |e|</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> elem = e.delete_element("REQUIREMENTS")</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> if !elem.nil?</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> template.add_element("SCHED_REQUIREMENTS").text = elem.text</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> end</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> elem = e.delete_element("RANK")</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> if !elem.nil?</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> template.add_element("SCHED_RANK").text = elem.text</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> end</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"># NEW> e.add_element("CPU").text = "1"</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"> end</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"># NEW> doc.root.each_element("TEMPLATE/GRAPHICS") { |e|</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"># NEW> e.delete_element("PORT")</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"># NEW > }</div>
<div><br>
</div>
</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium"><br>
</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium">The second part to delete PORT works!</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium"><br>
</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium">The issue is the first part. With the above code, the body field of template_pool shows a new entry </span><span style="font-size:medium"><CPU>1</CPU> </span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium">while I expect it to be <CPU><![CDATA[1]]></CPU></span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium"><br>
</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium">So, I am thinking of modifying as follows instead;</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><span style="font-size:medium"> e.add_element("CPU").text = "<![CDATA[1]]>"</span></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px">I believe this will result in the DB as <CPU><![CDATA[1]]></CPU></div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px">What do you ON developers think?</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<div style="font-family:Calibri,sans-serif;font-size:14px">Thanks,</div>
<div style="font-family:Calibri,sans-serif;font-size:14px">Hyunwoo</div>
<div style="font-family:Calibri,sans-serif;font-size:14px">FermiCloud</div>
<div style="font-family:Calibri,sans-serif;font-size:14px"><br>
</div>
<span style="font-size:14px;font-family:Calibri,sans-serif">
<div style="border-right:medium none;padding-right:0in;padding-left:0in;padding-top:3pt;text-align:left;font-size:11pt;border-bottom:medium none;font-family:Calibri;border-top:#b5c4df 1pt solid;padding-bottom:0in;border-left:medium none">
<span style="font-weight:bold">From: </span>Hyunwoo Kim <<a href="mailto:hyunwoo@fnal.gov" target="_blank">hyunwoo@fnal.gov</a>><br>
<span style="font-weight:bold">Date: </span>Tuesday, April 15, 2014 10:08 AM<br>
<span style="font-weight:bold">To: </span>users <<a href="mailto:users@lists.opennebula.org" target="_blank">users@lists.opennebula.org</a>><br>
<span style="font-weight:bold">Cc: </span>Hyunwoo Kim <<a href="mailto:hyunwoo@fnal.gov" target="_blank">hyunwoo@fnal.gov</a>><br>
<span style="font-weight:bold">Subject: </span>onedb upgrade and XML<br>
</div><div><div class="h5">
<div><br>
</div>
<div>
<div style="font-size:14px;font-family:Calibri,sans-serif;word-wrap:break-word">
<div>Hello,</div>
<div><br>
</div>
<div>onedb upgrade command of ON44 against an old DB</div>
<div>fails to do the following two tasks.</div>
<div>1. <CPU> </CPU> should have been inserted, but missing</div>
<div>2. <PORT> </PORT> in /VMTEMPLATE/TEMPLATE/GRAPHICS/ should have been removed, but still there..</div>
<div><br>
</div>
<div>What should I do about these?</div>
<div><br>
</div>
<div>I am investigating a possibility to use xpath command </div>
<div>with mysql -h localhost -u root -e "select body from template_pool limit 1" open nebula</div>
<div>or something, but I am not sure if this is any good solution..</div>
<div><br>
</div>
<div>Any advice will be very appreciated.</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Hyunwoo KIM</div>
<div>FermiCloud</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div></div></span>
</div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div>