Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F86210F91 for ; Tue, 27 Aug 2013 20:14:03 +0000 (UTC) Received: (qmail 41199 invoked by uid 500); 27 Aug 2013 20:14:01 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 41045 invoked by uid 500); 27 Aug 2013 20:14:00 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 40335 invoked by uid 99); 27 Aug 2013 20:13:54 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Aug 2013 20:13:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6DCC246414; Tue, 27 Aug 2013 20:13:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: animesh@apache.org To: commits@cloudstack.apache.org Date: Tue, 27 Aug 2013 20:14:02 -0000 Message-Id: In-Reply-To: <0ba57699e8fc454aad65de868a86c315@git.apache.org> References: <0ba57699e8fc454aad65de868a86c315@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/12] git commit: updated refs/heads/4.2 to 41d2fb3 CLOUDSTACK-4443 [VMWARE]Failed to deploy VM's on VMWARE Standard vSwitch Legacy Zone after upgrade While upgrading to 4.2 to support existing clusters working over standard vswitch or nexus dvswitch should be supported as is. To ensure this while upgrading to 4.2, existing cluster's vswitch configuration needs to be persisted to database. If zone level traffic label is empty then default vswitch name would be used. Signed-off-by: Sateesh Chodapuneedi (cherry picked from commit 808183fdcc24fd6417d7bb806ee58a84b84868f4) Signed-off-by: animesh Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a48e6685 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a48e6685 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a48e6685 Branch: refs/heads/4.2 Commit: a48e6685a125344d0b683a28eadfa2147f59cca8 Parents: bba9801 Author: Sateesh Chodapuneedi Authored: Tue Aug 27 16:54:29 2013 +0530 Committer: animesh Committed: Tue Aug 27 12:56:08 2013 -0700 ---------------------------------------------------------------------- .../com/cloud/upgrade/dao/Upgrade410to420.java | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a48e6685/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java index 81f11f0..5db6420 100755 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java @@ -39,6 +39,7 @@ import org.apache.log4j.Logger; import com.cloud.deploy.DeploymentPlanner; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.network.Networks.TrafficType; import com.cloud.network.vpc.NetworkACL; import com.cloud.utils.Pair; import com.cloud.utils.exception.CloudRuntimeException; @@ -147,6 +148,10 @@ public class Upgrade410to420 implements DbUpgrade { boolean nexusEnabled = false; String publicVswitchType = VMWARE_STANDARD_VSWITCH; String guestVswitchType = VMWARE_STANDARD_VSWITCH; + String defaultPublicVswitchName = "vSwitch0"; + String defaultGuestVswitchName = "vSwitch0"; + String publicVswitchName = null; + String guestVswitchName = null; Map>> detailsMap = new HashMap>>(); List> detailsList; @@ -163,13 +168,27 @@ public class Upgrade410to420 implements DbUpgrade { nexusEnabled = true; } } + // Set default values if cloud level setting is turned on for nexus 1000v. if (nexusEnabled) { publicVswitchType = NEXUS_1000V_DVSWITCH; guestVswitchType = NEXUS_1000V_DVSWITCH; + defaultPublicVswitchName = "publicEthernetPortProfile"; + defaultGuestVswitchName = "guestEthernetPortProfile"; + } + // Read zone level settings from zone wide traffic labels for guest traffic and public traffic + guestVswitchName = getDefaultTrafficLabel(conn, TrafficType.Guest.toString()); + publicVswitchName = getDefaultTrafficLabel(conn, TrafficType.Public.toString()); + if (guestVswitchName == null) { + guestVswitchName = defaultGuestVswitchName; + } + if (publicVswitchName == null) { + publicVswitchName = defaultPublicVswitchName; } detailsList = new ArrayList>(); detailsList.add(new Pair(ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, guestVswitchType)); + detailsList.add(new Pair(ApiConstants.VSWITCH_NAME_GUEST_TRAFFIC, guestVswitchName)); detailsList.add(new Pair(ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, publicVswitchType)); + detailsList.add(new Pair(ApiConstants.VSWITCH_NAME_PUBLIC_TRAFFIC, publicVswitchName)); detailsMap.put(clusterId, detailsList); updateClusterDetails(conn, detailsMap); @@ -237,6 +256,34 @@ public class Upgrade410to420 implements DbUpgrade { } } + private String getDefaultTrafficLabel(Connection conn, String trafficType) { + ResultSet rs = null; + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("select vmware_network_label from physical_network_traffic_types where vmware_network_label is not NULL and traffic_type='" + trafficType + "';"); + rs = pstmt.executeQuery(); + + while (rs.next()) { + String label = rs.getString("vmware_network_label"); + // Handle case of label specified as [vswitch_name,vlan_id] + return label.split(",")[0]; + } + } catch (SQLException e) { + throw new CloudRuntimeException("Unable read default traffic label for " + trafficType + ". ", e); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + return null; + } + private String getConfigurationParameter(Connection conn, String category, String paramName) { ResultSet rs = null; PreparedStatement pstmt = null;