diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java index 3630c00b8dc..614cf14cafe 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java @@ -907,7 +907,6 @@ public class Upgrade412to420 implements DbUpgrade { Long vmwareDcId = 1L; Long zoneId; Long clusterId; - String clusterHypervisorType; boolean legacyZone; boolean ignoreZone; Long count; @@ -929,7 +928,7 @@ public class Upgrade412to420 implements DbUpgrade { while (rs.next()) { zoneId = rs.getLong("id"); - clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL AND data_center_id=?"); + clustersQuery = conn.prepareStatement("select id from `cloud`.`cluster` where removed is NULL AND data_center_id=? AND hypervisor_type='VMware'"); clustersQuery.setLong(1, zoneId); legacyZone = false; ignoreZone = true; @@ -943,39 +942,36 @@ public class Upgrade412to420 implements DbUpgrade { dcOfPreviousCluster = null; dcOfCurrentCluster = null; do { - clusterHypervisorType = clusters.getString("hypervisor_type"); clusterId = clusters.getLong("id"); - if (clusterHypervisorType.equalsIgnoreCase("VMware")) { - ignoreZone = false; - clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?"); - clusterDetailsQuery.setLong(1, clusterId); - clusterDetails = clusterDetailsQuery.executeQuery(); - clusterDetails.next(); - url = clusterDetails.getString("value"); - tokens = url.split("/"); // url format - http://vcenter/dc/cluster - vc = tokens[2]; - dcName = tokens[3]; - dcOfPreviousCluster = dcOfCurrentCluster; - dcOfCurrentCluster = dcName + "@" + vc; - if (count > 0) { - if (!dcOfPreviousCluster.equalsIgnoreCase(dcOfCurrentCluster)) { - legacyZone = true; - s_logger.debug("Marking the zone " + zoneId + " as legacy zone."); - } + ignoreZone = false; + clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?"); + clusterDetailsQuery.setLong(1, clusterId); + clusterDetails = clusterDetailsQuery.executeQuery(); + clusterDetails.next(); + url = clusterDetails.getString("value"); + tokens = url.split("/"); // url format - http://vcenter/dc/cluster + vc = tokens[2]; + dcName = tokens[3]; + dcOfPreviousCluster = dcOfCurrentCluster; + dcOfCurrentCluster = dcName + "@" + vc; + if (count > 0) { + if (!dcOfPreviousCluster.equalsIgnoreCase(dcOfCurrentCluster)) { + legacyZone = true; + s_logger.debug("Marking the zone " + zoneId + " as legacy zone."); } - } else { - s_logger.debug("Ignoring zone " + zoneId + " with hypervisor type " + clusterHypervisorType); - break; } count++; } while (clusters.next()); + + // Ignore the zone without even one VMware cluster. if (ignoreZone) { - continue; // Ignore the zone with hypervisors other than VMware + continue; } } if (legacyZone) { listOfLegacyZones.add(zoneId); } else { + // Associate DC with the zone. assert(clusterDetails != null) : "Couldn't retrieve details of cluster!"; s_logger.debug("Discovered non-legacy zone " + zoneId + ". Processing the zone to associate with VMware datacenter.");