Revision e709ace8

View differences:

src/onedb/import_slave.rb
323 323
        @slave_db.run "ALTER TABLE secgroup_pool RENAME TO old_secgroup_pool;"
324 324
        @slave_db.run "CREATE TABLE secgroup_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name,uid));"
325 325

  
326
        @slave_db.run "ALTER TABLE vrouter_pool RENAME TO old_vrouter_pool;"
327
        @slave_db.run "CREATE TABLE vrouter_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
328

  
326 329
        @slave_db.run "ALTER TABLE group_quotas RENAME TO old_group_quotas;"
327 330
        @slave_db.run "CREATE TABLE group_quotas (group_oid INTEGER PRIMARY KEY, body MEDIUMTEXT);"
328 331

  
......
853 856
        @slave_db.run "DROP TABLE old_template_pool;"
854 857
        @slave_db.run "DROP TABLE old_vm_pool;"
855 858
        @slave_db.run "DROP TABLE old_secgroup_pool;"
859
        @slave_db.run "DROP TABLE old_vrouter_pool;"
856 860

  
857 861
        @slave_db.run "DROP TABLE old_group_quotas;"
858 862
        @slave_db.run "DROP TABLE old_user_quotas;"
......
1140 1144
                :other_u    => row[:other_u])
1141 1145
        end
1142 1146

  
1147
        db.fetch("SELECT * FROM old_vrouter_pool") do |row|
1148
            new_user = users[row[:uid]]
1149
            new_group = groups[row[:gid]]
1150

  
1151
            if (new_user.nil?)
1152
                new_user = users[0]
1153
                log("User ##{row[:uid]} does not exist anymore. Virtual Router ##{row[:oid]} will be assigned to user ##{new_user[:oid]}, #{new_user[:name]}")
1154
            end
1155

  
1156
            if (new_group.nil?)
1157
                new_group = groups[0]
1158
                log("Group ##{row[:gid]} does not exist anymore. Virtual Router ##{row[:oid]} will be assigned to group ##{new_group[:oid]}, #{new_group[:name]}")
1159
            end
1160

  
1161
            doc = Nokogiri::XML(row[:body],nil,NOKOGIRI_ENCODING){|c| c.default_xml.noblanks}
1162

  
1163
            doc.root.at_xpath("UID").content    = new_user[:oid]
1164
            doc.root.at_xpath("UNAME").content  = new_user[:name]
1165

  
1166
            doc.root.at_xpath("GID").content    = new_group[:oid]
1167
            doc.root.at_xpath("GNAME").content  = new_group[:name]
1168

  
1169
            db[:vrouter_pool].insert(
1170
                :oid        => row[:oid],
1171
                :name       => row[:name],
1172
                :body       => doc.root.to_s,
1173
                :uid        => new_user[:oid],
1174
                :gid        => new_group[:oid],
1175
                :owner_u    => row[:owner_u],
1176
                :group_u    => row[:group_u],
1177
                :other_u    => row[:other_u])
1178
        end
1179

  
1143 1180
    end
1144 1181
end

Also available in: Unified diff