Updated Branches:
  refs/heads/master 263b8eec1 -> f25a78111

CLOUDSTACK-493: 22x-30 upgrade for Advance SG enabled zone

* enable SG provider if the zone is SG enabled
* don't create public traffic type for the zone if there is no public network 
exist in the zone in 2.2.x


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f25a7811
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f25a7811
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f25a7811

Branch: refs/heads/master
Commit: f25a78111f3e74fbc78096df986c59683b8d4079
Parents: 263b8ee
Author: Alena Prokharchyk <[email protected]>
Authored: Fri Nov 16 09:57:01 2012 -0800
Committer: Alena Prokharchyk <[email protected]>
Committed: Fri Nov 16 10:00:45 2012 -0800

----------------------------------------------------------------------
 .../src/com/cloud/upgrade/dao/Upgrade2214to30.java |   24 ++++++++++++--
 .../src/com/cloud/upgrade/dao/Upgrade30xBase.java  |    7 +---
 2 files changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f25a7811/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java 
b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
index 8c4dbec..88370c1 100755
--- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
@@ -161,9 +161,17 @@ public class Upgrade2214to30 extends Upgrade30xBase 
implements DbUpgrade {
                 pstmtUpdate.setLong(2, zoneId);
                 pstmtUpdate.executeUpdate();
                 pstmtUpdate.close();
-
-                //check if there are multiple guest networks configured using 
network_tags
                 
+                //check if public network needs to be created
+                boolean crtPbNtwk = false;
+                pstmt = conn.prepareStatement("SELECT * FROM 
`cloud`.`networks` where traffic_type=\"public\" and data_center_id=?");
+                pstmt.setLong(1, zoneId);
+                ResultSet rs1 = pstmt.executeQuery();
+                if (rs1.next()) {
+                    crtPbNtwk = true;
+                }
+                
+                //check if there are multiple guest networks configured using 
network_tags
                 PreparedStatement pstmt2 = conn.prepareStatement("SELECT 
distinct tag FROM `cloud`.`network_tags` t JOIN `cloud`.`networks` n ON 
t.network_id = n.id WHERE n.data_center_id = ? and n.removed IS NULL");
                 pstmt2.setLong(1, zoneId);
                 ResultSet rsTags = pstmt2.executeQuery();
@@ -235,7 +243,11 @@ public class Upgrade2214to30 extends Upgrade30xBase 
implements DbUpgrade {
                         long physicalNetworkId = 
addPhysicalNetworkToZone(conn, zoneId, zoneName, networkType, 
(isFirstPhysicalNtwk) ? vnet : null, domainId);
                         //add Traffic types
                         if(isFirstPhysicalNtwk){
-                            addTrafficType(conn, physicalNetworkId, "Public", 
xenPublicLabel, kvmPublicLabel, vmwarePublicLabel);
+                            if (crtPbNtwk) {
+                                addTrafficType(conn, physicalNetworkId, 
"Public", xenPublicLabel, kvmPublicLabel, vmwarePublicLabel);
+                            } else {
+                                s_logger.debug("Skip adding public traffic 
type to zone id=" + zoneId);
+                            }
                             addTrafficType(conn, physicalNetworkId, 
"Management", xenPrivateLabel, kvmPrivateLabel, vmwarePrivateLabel);
                             addTrafficType(conn, physicalNetworkId, "Storage", 
xenStorageLabel, null, null);
                         }
@@ -270,7 +282,11 @@ public class Upgrade2214to30 extends Upgrade30xBase 
implements DbUpgrade {
                     //default to one physical network
                     long physicalNetworkId = addPhysicalNetworkToZone(conn, 
zoneId, zoneName, networkType, vnet, domainId);
                     // add traffic types
-                    addTrafficType(conn, physicalNetworkId, "Public", 
xenPublicLabel, kvmPublicLabel, vmwarePublicLabel);
+                    if (crtPbNtwk) {
+                        addTrafficType(conn, physicalNetworkId, "Public", 
xenPublicLabel, kvmPublicLabel, vmwarePublicLabel);  
+                    } else {
+                        s_logger.debug("Skip adding public traffic type to 
zone id=" + zoneId);
+                    }
                     addTrafficType(conn, physicalNetworkId, "Management", 
xenPrivateLabel, kvmPrivateLabel, vmwarePrivateLabel);
                     addTrafficType(conn, physicalNetworkId, "Storage", 
xenStorageLabel, null, null);
                     addTrafficType(conn, physicalNetworkId, "Guest", 
xenGuestLabel, kvmGuestLabel, vmwareGuestLabel);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f25a7811/server/src/com/cloud/upgrade/dao/Upgrade30xBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade30xBase.java 
b/server/src/com/cloud/upgrade/dao/Upgrade30xBase.java
index 585e086..36ae3c5 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade30xBase.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade30xBase.java
@@ -193,11 +193,8 @@ public abstract class Upgrade30xBase implements DbUpgrade{
                 pstmtUpdate.setString(1, UUID.randomUUID().toString());
                 pstmtUpdate.setLong(2, physicalNetworkId);
                 pstmtUpdate.setString(3, "SecurityGroupProvider");
-                if ("Advanced".equals(networkType)) {
-                    pstmtUpdate.setString(4, "Disabled");
-                }else{
-                    pstmtUpdate.setString(4, "Enabled");
-                }
+                pstmtUpdate.setString(4, "Enabled");
+                
                 pstmtUpdate.executeUpdate();
                 pstmtUpdate.close();
             }

Reply via email to