Revision e833df26 src/onedb/3.8.1_to_3.9.80.rb

View differences:

src/onedb/3.8.1_to_3.9.80.rb
113 113
        @db.run("ALTER TABLE image_pool_new RENAME TO image_pool")
114 114

  
115 115
        ########################################################################
116
        # Feature #1565: New cid column in host, ds and vnet tables
117
        ########################################################################
118

  
119
        @db.run "ALTER TABLE host_pool RENAME TO old_host_pool;"
120
        @db.run "CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, last_mon_time INTEGER, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name));"
121

  
122
        @db.fetch("SELECT * FROM old_host_pool") do |row|
123
            doc = Document.new(row[:body])
124

  
125
            cluster_id = doc.root.get_text('CLUSTER_ID').to_s
126

  
127
            @db[:host_pool].insert(
128
                :oid            => row[:oid],
129
                :name           => row[:name],
130
                :body           => row[:body],
131
                :state          => row[:state],
132
                :last_mon_time  => row[:last_mon_time],
133
                :uid            => row[:uid],
134
                :gid            => row[:gid],
135
                :owner_u        => row[:owner_u],
136
                :group_u        => row[:group_u],
137
                :other_u        => row[:other_u],
138
                :cid            => cluster_id)
139
        end
140

  
141
        @db.run "DROP TABLE old_host_pool;"
142

  
143
        @db.run "ALTER TABLE network_pool RENAME TO old_network_pool;"
144
        @db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name,uid));"
145

  
146
        @db.fetch("SELECT * FROM old_network_pool") do |row|
147
            doc = Document.new(row[:body])
148

  
149
            cluster_id = doc.root.get_text('CLUSTER_ID').to_s
150

  
151
            @db[:network_pool].insert(
152
                :oid            => row[:oid],
153
                :name           => row[:name],
154
                :body           => row[:body],
155
                :uid            => row[:uid],
156
                :gid            => row[:gid],
157
                :owner_u        => row[:owner_u],
158
                :group_u        => row[:group_u],
159
                :other_u        => row[:other_u],
160
                :cid            => cluster_id)
161
        end
162

  
163
        @db.run "DROP TABLE old_network_pool;"
164

  
165
        ########################################################################
116 166
        # Feature #1617
117 167
        # New datastore, 2 "files"
118 168
        # DATASTORE/SYSTEM is now DATASTORE/TYPE
169
        #
170
        # Feature #1565: New cid column in host, ds and vnet tables
119 171
        ########################################################################
120 172

  
121 173
        @db.run "ALTER TABLE datastore_pool RENAME TO old_datastore_pool;"
122
        @db.run "CREATE TABLE datastore_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name));"
174
        @db.run "CREATE TABLE datastore_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, cid INTEGER, UNIQUE(name));"
123 175

  
124 176
        @db.fetch("SELECT * FROM old_datastore_pool") do |row|
125 177
            doc = Document.new(row[:body])
......
139 191
                e.add_element("TYPE").text = type == "0" ? "IMAGE_DS" : "SYSTEM_DS"
140 192
            end
141 193

  
194
            cluster_id = doc.root.get_text('CLUSTER_ID').to_s
195

  
142 196
            @db[:datastore_pool].insert(
143 197
                :oid        => row[:oid],
144 198
                :name       => row[:name],
......
147 201
                :gid        => row[:gid],
148 202
                :owner_u    => row[:owner_u],
149 203
                :group_u    => row[:group_u],
150
                :other_u    => row[:other_u])
204
                :other_u    => row[:other_u],
205
                :cid        => cluster_id)
151 206
        end
152 207

  
153 208
        @db.run "DROP TABLE old_datastore_pool;"
......
176 231
            end
177 232
        end
178 233

  
179
        @db.run "INSERT INTO datastore_pool VALUES(2,'files','<DATASTORE><ID>2</ID><UID>0</UID><GID>0</GID><UNAME>#{user_0_name}</UNAME><GNAME>#{group_0_name}</GNAME><NAME>files</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>1</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>1</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><DS_MAD>fs</DS_MAD><TM_MAD>ssh</TM_MAD><BASE_PATH>#{base_path}</BASE_PATH><TYPE>2</TYPE><DISK_TYPE>0</DISK_TYPE><CLUSTER_ID>-1</CLUSTER_ID><CLUSTER></CLUSTER><IMAGES></IMAGES><TEMPLATE><DS_MAD><![CDATA[fs]]></DS_MAD><TM_MAD><![CDATA[ssh]]></TM_MAD><TYPE><![CDATA[FILE_DS]]></TYPE></TEMPLATE></DATASTORE>',0,0,1,1,1);"
234
        @db.run "INSERT INTO datastore_pool VALUES(2,'files','<DATASTORE><ID>2</ID><UID>0</UID><GID>0</GID><UNAME>#{user_0_name}</UNAME><GNAME>#{group_0_name}</GNAME><NAME>files</NAME><PERMISSIONS><OWNER_U>1</OWNER_U><OWNER_M>1</OWNER_M><OWNER_A>0</OWNER_A><GROUP_U>1</GROUP_U><GROUP_M>0</GROUP_M><GROUP_A>0</GROUP_A><OTHER_U>1</OTHER_U><OTHER_M>0</OTHER_M><OTHER_A>0</OTHER_A></PERMISSIONS><DS_MAD>fs</DS_MAD><TM_MAD>ssh</TM_MAD><BASE_PATH>#{base_path}</BASE_PATH><TYPE>2</TYPE><DISK_TYPE>0</DISK_TYPE><CLUSTER_ID>-1</CLUSTER_ID><CLUSTER></CLUSTER><IMAGES></IMAGES><TEMPLATE><DS_MAD><![CDATA[fs]]></DS_MAD><TM_MAD><![CDATA[ssh]]></TM_MAD><TYPE><![CDATA[FILE_DS]]></TYPE></TEMPLATE></DATASTORE>',0,0,1,1,1,-1);"
180 235

  
181 236

  
182 237
        ########################################################################

Also available in: Unified diff