Revision 59f4331b

View differences:

src/onedb/3.8.1_to_3.9.80.rb
402 402

  
403 403
        ########################################################################
404 404
        # Feature #1556: New elem USER_TEMPLATE
405
        #
406
        # Feature #1483: Move scheduling attributes
407
        #   /VM/TEMPLATE/REQUIREMENTS -> USER_TEMPLATE/SCHED_REQUIREMENTS
408
        #   /VM/TEMPLATE/RANK -> USER_TEMPLATE/SCHED_RANK
405 409
        ########################################################################
406 410

  
407 411
        @db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
......
410 414
        @db.fetch("SELECT * FROM old_vm_pool") do |row|
411 415

  
412 416
            doc = Document.new(row[:body])
413
            doc.root.add_element("USER_TEMPLATE")
417
            user_template = doc.root.add_element("USER_TEMPLATE")
418

  
419
            doc.root.each_element("TEMPLATE") do |e|
420
                elem = e.delete_element("REQUIREMENTS")
421

  
422
                if !elem.nil?
423
                    user_template.add_element("SCHED_REQUIREMENTS").text = elem.text
424
                end
425

  
426
                elem = e.delete_element("RANK")
427

  
428
                if !elem.nil?
429
                    user_template.add_element("SCHED_RANK").text = elem.text
430
                end
431
            end
414 432

  
415 433
            @db[:vm_pool].insert(
416 434
                :oid        => row[:oid],
......
430 448

  
431 449

  
432 450
        ########################################################################
451
        # Feature #1483: Move scheduling attributes
452
        #   /VMTEMPLATE/TEMPLATE/REQUIREMENTS -> /VMTEMPLATE/TEMPLATE/SCHED_REQUIREMENTS
453
        #   /VMTEMPLATE/TEMPLATE/RANK -> /VMTEMPLATE/TEMPLATE/SCHED_RANK
454
        ########################################################################
455

  
456
        @db.run "ALTER TABLE template_pool RENAME TO old_template_pool;"
457
        @db.run "CREATE TABLE template_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
458

  
459
        @db.fetch("SELECT * FROM old_template_pool") do |row|
460

  
461
            doc = Document.new(row[:body])
462

  
463
            template = nil
464

  
465
            doc.root.each_element("TEMPLATE") do |e|
466
                template = e
467
            end
468

  
469
            doc.root.each_element("TEMPLATE") do |e|
470
                elem = e.delete_element("REQUIREMENTS")
471

  
472
                if !elem.nil?
473
                    template.add_element("SCHED_REQUIREMENTS").text = elem.text
474
                end
475

  
476
                elem = e.delete_element("RANK")
477

  
478
                if !elem.nil?
479
                    template.add_element("SCHED_RANK").text = elem.text
480
                end
481
            end
482

  
483
            @db[:template_pool].insert(
484
                :oid        => row[:oid],
485
                :name       => row[:name],
486
                :body       => doc.root.to_s,
487
                :uid        => row[:uid],
488
                :gid        => row[:gid],
489
                :owner_u    => row[:owner_u],
490
                :group_u    => row[:group_u],
491
                :other_u    => row[:other_u])
492
        end
493

  
494
        @db.run "DROP TABLE old_template_pool;"
495

  
496

  
497
        ########################################################################
433 498
        #
434 499
        # Banner for the new /var/lib/one/vms directory
435 500
        #

Also available in: Unified diff