cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/3] git commit: updated refs/heads/hotfix/4.4/upgradepath-431to441 to e57f17a
Date Thu, 04 Sep 2014 17:07:26 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/hotfix/4.4/upgradepath-431to441 [created] e57f17ae8


schema: Add upgrade path 4.3.0 to 4.3.1 picked from 51f145b

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/hotfix/4.4/upgradepath-431to441
Commit: 9d3b886da6575cb13b0251cbb8a900064fd48bf0
Parents: c900aac
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Thu Sep 4 18:40:03 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Sep 4 19:05:39 2014 +0200

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade430to431.java  | 124 +++++++++++++++++++
 1 file changed, 124 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d3b886d/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to431.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to431.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to431.java
new file mode 100644
index 0000000..b80dbe0
--- /dev/null
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to431.java
@@ -0,0 +1,124 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.upgrade.dao;
+
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+public class Upgrade430to431 implements DbUpgrade {
+    final static Logger s_logger = Logger.getLogger(Upgrade430to431.class);
+
+    @Override
+    public String[] getUpgradableVersionRange() {
+        return new String[] {"4.3.0", "4.3.1"};
+    }
+
+    @Override
+    public String getUpgradedVersion() {
+        return "4.3.1";
+    }
+
+    @Override
+    public boolean supportsRollingUpgrade() {
+        return false;
+    }
+
+    @Override
+    public File[] getPrepareScripts() {
+        return null;
+    }
+
+    @Override
+    public void performDataMigration(Connection conn) {
+        updateVlanUris(conn);
+    }
+
+    private void updateVlanUris(Connection conn) {
+        s_logger.debug("updating vlan URIs");
+        Exception thrown = null;
+        PreparedStatement selectstatement = null;
+        ResultSet results = null;
+        try{
+            selectstatement = conn.prepareStatement("SELECT id, vlan_id FROM `cloud`.`vlan`
where vlan_id not like '%:%'");
+            results = selectstatement.executeQuery();
+
+            while (results.next()) {
+                long id = results.getLong(1);
+                String vlan = results.getString(2);
+                if (vlan == null || "".equals(vlan)) {
+                    continue;
+                }
+                String vlanUri = BroadcastDomainType.Vlan.toUri(vlan).toString();
+                PreparedStatement updatestatement = conn.prepareStatement("update `cloud`.`vlan`
set vlan_id=? where id=?");
+                try {
+                    updatestatement.setString(1, vlanUri);
+                    updatestatement.setLong(2, id);
+                    updatestatement.executeUpdate();
+                } catch (SQLException e) {
+                    thrown = new CloudRuntimeException("Unable to update vlan URI " + vlanUri
+ " for vlan record " + id, e);
+                } finally {
+                    try {
+                        updatestatement.close();
+                    } catch (Exception e) {
+                        if(thrown == null) {
+                            thrown =  new CloudRuntimeException("Unable to close update statement
vlan URI " + vlanUri + " for vlan record " + id, e);
+                        } //else don't obfuscate the original exception
+                    }
+                }
+            }
+        } catch (SQLException e) {
+            if(thrown == null) {
+                thrown = new CloudRuntimeException("Unable to update vlan URIs ", e);
+            } //else don't obfuscate the original exception
+        }
+        finally
+        {
+            try {
+                if(results != null)
+                    results.close();
+            } catch (SQLException e) {
+                if(thrown == null) {
+                    thrown = new CloudRuntimeException("Unable to update vlan URIs ", e);
+                } //else don't obfuscate the original exception
+            }
+            try {
+                if (selectstatement != null)
+                    selectstatement.close();
+            } catch (SQLException e) {
+                if(thrown == null) {
+                    thrown = new CloudRuntimeException("Unable to update vlan URIs ", e);
+                } //else don't obfuscate the original exception
+            }
+        }
+        s_logger.debug("Done updateing vlan URIs");
+    }
+
+    @Override
+    public File[] getCleanupScripts() {
+        return null;
+    }
+
+}


Mime
View raw message