Revision d00e3798 src/onedb/local/4.90.0_to_5.3.80.rb

View differences:

src/onedb/local/4.90.0_to_5.3.80.rb
105 105
    # Adds UID, GID and REQUEST_ID to history records
106 106
    ############################################################################
107 107
    def feature_5005
108
        #TODO ADD VALUES TO HISTORY POOL TABLE
109 108
        @db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
110 109
        create_table(:vm_pool)
111 110

  
......
136 135
        end
137 136

  
138 137
        @db.run "DROP TABLE old_vm_pool;"
138

  
139
        @db.run "ALTER TABLE history RENAME TO old_history;"
140
        create_table(:history)
141

  
142
        @db.transaction do
143
            @db.fetch("SELECT * FROM old_history") do |row|
144
                doc = Nokogiri::XML(row[:body], nil, NOKOGIRI_ENCODING) { |c|
145
                    c.default_xml.noblanks
146
                }
147

  
148
                h = doc.root
149

  
150
                reason = h.xpath("REASON")
151
                reason.unlink if !reason.nil?
152

  
153
                uid = doc.create_element "UID", -1
154
                gid = doc.create_element "GID", -1
155
                rid = doc.create_element "REQUEST_ID", -1
156

  
157
                h.add_child(uid)
158
                h.add_child(gid)
159
                h.add_child(rid)
160

  
161
                row[:body] = doc.root.to_s
162

  
163
                @db[:history].insert(row)
164
            end
165
        end
166

  
167
        @db.run "DROP TABLE old_history;"
139 168
    end
140 169

  
141 170
    def feature_2347
......
182 211
    # Simplify HA management in OpenNebula
183 212
    ############################################################################
184 213
    def feature_4809
185
        #
186
        # TODO NEEDS TO ADD <SERVER_POOL> TO EACH ZONE
187
        #
188 214
        create_table(:logdb)
189 215
        create_table(:fed_logdb)
216

  
217
        @db.run "ALTER TABLE zone_pool RENAME TO old_zone_pool;"
218
        create_table(:zone_pool)
219

  
220
        @db.transaction do
221
            @db.fetch("SELECT * FROM old_zone_pool") do |row|
222
                doc = Nokogiri::XML(row[:body], nil, NOKOGIRI_ENCODING) { |c|
223
                    c.default_xml.noblanks
224
                }
225

  
226
                zedp = xpath(doc, "TEMPLATE/ENDPOINT")
227

  
228
                server_pool = doc.create_element "SERVER_POOL"
229
                server      = doc.create_element "SERVER"
230

  
231
                id   = doc.create_element "ID", 0
232
                name = doc.create_element "NAME", "zone_server"
233
                edp  = doc.create_element "ENDPOINT", zedp
234

  
235
                server.add_child(id)
236
                server.add_child(name)
237
                server.add_child(edp)
238

  
239
                server_pool.add_child(server)
240

  
241
                doc.root.add_child(server_pool)
242

  
243
                row[:body] = doc.root.to_s
244

  
245
                @db[:zone_pool].insert(row)
246
            end
247
        end
248

  
249
        @db.run "DROP TABLE old_zone_pool;"
250

  
190 251
    end
191 252
end

Also available in: Unified diff