[one-users] onedb upgrade and XML

Carlos Martín Sánchez cmartin at opennebula.org
Wed Apr 16 06:08:34 PDT 2014


Hi,

Your approach looks correct. The cpu element should also work with simple
text instead of cdata.
Refer to the REXML docs for more information:
http://ruby-doc.org/stdlib-2.1.1/libdoc/rexml/rdoc/index.html

Regards

--
Carlos Martín, MSc
Project Engineer
OpenNebula - Flexible Enterprise Cloud Made Simple
www.OpenNebula.org | cmartin at opennebula.org |
@OpenNebula<http://twitter.com/opennebula><cmartin at opennebula.org>


On Tue, Apr 15, 2014 at 11:11 PM, Hyun Woo Kim <hyunwoo at fnal.gov> wrote:

>  I have found one possible solution
>
>  I modified /usr/lib/one/ruby/onedb/3.8.5_to_3.9.30.rb as follows;
>
>          @db.fetch("SELECT * FROM old_template_pool") do |row|
>             doc = Document.new(row[:body])
>             template = nil
>             doc.root.each_element("TEMPLATE") do |e|
>                 template = e
>             end
>
>              doc.root.each_element("TEMPLATE") do |e|
>                elem = e.delete_element("REQUIREMENTS")
>                if !elem.nil?
>                     template.add_element("SCHED_REQUIREMENTS").text =
> elem.text
>                 end
>
>                  elem = e.delete_element("RANK")
>                 if !elem.nil?
>                     template.add_element("SCHED_RANK").text = elem.text
>                 end
>
>  # NEW>     e.add_element("CPU").text = "1"
>             end
>
>  # NEW>   doc.root.each_element("TEMPLATE/GRAPHICS") { |e|
> # NEW>       e.delete_element("PORT")
> # NEW >  }
>
>
>  The second part to delete PORT works!
>
>  The issue is the first part. With the above code, the body field of
> template_pool shows a new entry <CPU>1</CPU>
> while I expect it to be <CPU><![CDATA[1]]></CPU>
>
>  So, I am thinking of modifying as follows instead;
>  e.add_element("CPU").text = "<![CDATA[1]]>"
>
>  I believe this will result in the DB as <CPU><![CDATA[1]]></CPU>
>
>  What do you ON developers think?
>
>  Thanks,
> Hyunwoo
> FermiCloud
>
>   From: Hyunwoo Kim <hyunwoo at fnal.gov>
> Date: Tuesday, April 15, 2014 10:08 AM
> To: users <users at lists.opennebula.org>
> Cc: Hyunwoo Kim <hyunwoo at fnal.gov>
> Subject: onedb upgrade and XML
>
>   Hello,
>
>  onedb upgrade command of ON44 against an old DB
> fails to do the following two tasks.
> 1. <CPU> </CPU> should have been inserted, but missing
> 2. <PORT> </PORT> in /VMTEMPLATE/TEMPLATE/GRAPHICS/ should have been
> removed, but still there..
>
>  What should I do about these?
>
>  I am investigating a possibility to use xpath command
> with mysql -h localhost -u root -e "select body from template_pool limit
> 1" open nebula
> or something, but I am not sure if this is any good solution..
>
>  Any advice will be very appreciated.
> Thanks,
>
>  Hyunwoo KIM
> FermiCloud
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20140416/9df9b5f1/attachment-0002.htm>


More information about the Users mailing list