From 302485e8ef039cd91523934a67374d7f4584351a Mon Sep 17 00:00:00 2001 From: prachi Date: Mon, 16 Jul 2012 15:30:25 -0700 Subject: [PATCH] CS-15578 (spinned off from 15495) Upgrade from 2.2.14 -> 3.0.3-> 3.04 failed with exception"mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException reviewed-by: kishan - Add physical network to the removed data_center as well and mark it as removed, to avoid foreign constraint failures - Since rest all stuff related to multiple physcial networks is done based on networks having non-null removed field, nothing will apply to this zone. --- .../src/com/cloud/upgrade/dao/Upgrade2214to30.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java index 2c96323041b..36450789368 100755 --- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java @@ -142,7 +142,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade { String vmwarePrivateLabel = getNetworkLabelFromConfig(conn, "vmware.private.vswitch"); String vmwareGuestLabel = getNetworkLabelFromConfig(conn, "vmware.guest.vswitch"); - pstmt = conn.prepareStatement("SELECT id, domain_id, networktype, vnet, name FROM `cloud`.`data_center` WHERE removed IS NULL"); + pstmt = conn.prepareStatement("SELECT id, domain_id, networktype, vnet, name, removed FROM `cloud`.`data_center`"); rs = pstmt.executeQuery(); while (rs.next()) { long zoneId = rs.getLong(1); @@ -150,6 +150,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade { String networkType = rs.getString(3); String vnet = rs.getString(4); String zoneName = rs.getString(5); + String removed = rs.getString(6); //set uuid for the zone String uuid = UUID.randomUUID().toString(); @@ -303,6 +304,15 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade { pstmtUpdate = conn.prepareStatement(updateNet); pstmtUpdate.executeUpdate(); pstmtUpdate.close(); + + + //mark this physical network as removed if the zone is removed. + if(removed != null){ + pstmtUpdate = conn.prepareStatement("UPDATE `cloud`.`physical_network` SET removed = now() WHERE id = ?"); + pstmtUpdate.setLong(1, physicalNetworkId); + pstmtUpdate.executeUpdate(); + pstmtUpdate.close(); + } } }