From a9dded4d27d77b0732167a44d4e38fe3fa6870ae Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 27 Apr 2011 20:57:27 -0700 Subject: [PATCH] bug 9622: update mode for nics status 9622: resolved fixed --- .../src/com/cloud/upgrade/dao/Upgrade222to224.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade222to224.java b/server/src/com/cloud/upgrade/dao/Upgrade222to224.java index 5111e424553..aef4778125d 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade222to224.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade222to224.java @@ -57,16 +57,16 @@ public class Upgrade222to224 implements DbUpgrade { return new File[] { new File(script) }; } - + private void fixRelatedFkeyOnNetworksTable(Connection conn) throws SQLException { PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`networks` DROP FOREIGN KEY `fk_networks__related`"); - try { + try { pstmt.executeUpdate(); } catch (SQLException e) { s_logger.debug("Ignore if the key is not there."); } pstmt.close(); - + pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`networks` ADD CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE"); pstmt.executeUpdate(); pstmt.close(); @@ -120,13 +120,13 @@ public class Upgrade222to224 implements DbUpgrade { throw new CloudRuntimeException("Unable to update the guest os type for default template as a part of 222 to 224 upgrade", e); } } - + // fixes bug 9597 private void fixRecreatableVolumesProblem(Connection conn) throws SQLException { PreparedStatement pstmt = conn.prepareStatement("UPDATE volumes as v SET recreatable=(SELECT recreatable FROM disk_offering d WHERE d.id = v.disk_offering_id)"); pstmt.execute(); pstmt.close(); - + pstmt = conn.prepareStatement("UPDATE volumes SET recreatable=0 WHERE disk_offering_id is NULL"); pstmt.execute(); pstmt.close(); @@ -192,7 +192,7 @@ public class Upgrade222to224 implements DbUpgrade { HashMap nicNetworkMaps = new HashMap(); PreparedStatement pstmt = conn.prepareStatement("SELECT id, network_id FROM nics WHERE mode IS NULL"); ResultSet rs = pstmt.executeQuery(); - if (rs.next()) { + while (rs.next()) { nicNetworkMaps.put(rs.getLong(1), rs.getLong(2)); }