CS-15396: [2.2.14 to 3.0.4 upgrade] data_center table doesn't contain "uuid" after upgrade

Reviewed-By: Sheng Yang

Changes:
- Add uuid to data_center while upgrading from 2.2.14 to 3.0x.
- For previous setups that have already been updated, correctly add the uuid in 304 upgrade
This commit is contained in:
prachi 2012-07-02 13:47:10 -07:00
parent db894da7b5
commit aeee0f6d33
2 changed files with 23 additions and 2 deletions

View File

@ -150,6 +150,15 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
String networkType = rs.getString(3);
String vnet = rs.getString(4);
String zoneName = rs.getString(5);
//set uuid for the zone
String uuid = UUID.randomUUID().toString();
String updateUuid = "UPDATE `cloud`.`data_center` SET uuid = ? WHERE id = ?";
pstmtUpdate = conn.prepareStatement(updateUuid);
pstmtUpdate.setString(1, uuid);
pstmtUpdate.setLong(2, zoneId);
pstmtUpdate.executeUpdate();
pstmtUpdate.close();
//check if there are multiple guest networks configured using network_tags

View File

@ -69,15 +69,27 @@ public class Upgrade303to304 extends Upgrade30xBase implements DbUpgrade {
//add ntwk service map entries
//update all guest networks of 1 physical network having this offering id to this new offering id
pstmtZone = conn.prepareStatement("SELECT id, domain_id, networktype, name FROM `cloud`.`data_center`");
pstmtZone = conn.prepareStatement("SELECT id, domain_id, networktype, name, uuid FROM `cloud`.`data_center`");
rsZone = pstmtZone.executeQuery();
while (rsZone.next()) {
long zoneId = rsZone.getLong(1);
Long domainId = rsZone.getLong(2);
String networkType = rsZone.getString(3);
String zoneName = rsZone.getString(4);
String uuid = rsZone.getString(5);
PreparedStatement pstmtUpdate = null;
if(uuid == null){
uuid = UUID.randomUUID().toString();
String updateUuid = "UPDATE `cloud`.`data_center` SET uuid = ? WHERE id = ?";
pstmtUpdate = conn.prepareStatement(updateUuid);
pstmtUpdate.setString(1, uuid);
pstmtUpdate.setLong(2, zoneId);
pstmtUpdate.executeUpdate();
pstmtUpdate.close();
}
boolean multiplePhysicalNetworks = false;
pstmt = conn.prepareStatement("SELECT count(*) FROM `cloud`.`physical_network_traffic_types` pntt JOIN `cloud`.`physical_network` pn ON pntt.physical_network_id = pn.id WHERE pntt.traffic_type ='Guest' and pn.data_center_id = ?");