You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/06/30 15:15:49 UTC
git commit: updated refs/heads/4.3 to 51f145b
Repository: cloudstack
Updated Branches:
refs/heads/4.3 caa102c23 -> 51f145b56
datamigration for vlan uris
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/51f145b5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/51f145b5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/51f145b5
Branch: refs/heads/4.3
Commit: 51f145b564ed162c9ed315f28d32bd78a502c6da
Parents: caa102c
Author: Daan Hoogland <da...@onecht.net>
Authored: Mon Jun 30 15:11:09 2014 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Mon Jun 30 15:15:11 2014 +0200
----------------------------------------------------------------------
.../cloud/upgrade/DatabaseUpgradeChecker.java | 3 +
.../com/cloud/upgrade/dao/Upgrade430to431.java | 134 +++++++++++++++++++
2 files changed, 137 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51f145b5/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
index b0beedf..dc739f1 100755
--- a/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@ -65,6 +65,7 @@ import com.cloud.upgrade.dao.Upgrade40to41;
import com.cloud.upgrade.dao.Upgrade410to420;
import com.cloud.upgrade.dao.Upgrade420to421;
import com.cloud.upgrade.dao.Upgrade421to430;
+import com.cloud.upgrade.dao.Upgrade430to431;
import com.cloud.upgrade.dao.UpgradeSnapshot217to224;
import com.cloud.upgrade.dao.UpgradeSnapshot223to224;
import com.cloud.upgrade.dao.VersionDao;
@@ -193,6 +194,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
_upgradeMap.put("4.2.1", new DbUpgrade[] {new Upgrade421to430()});
+ _upgradeMap.put("4.3.0", new DbUpgrade[] {new Upgrade430to431()});
+
//CP Upgrades
_upgradeMap.put("3.0.3", new DbUpgrade[] {new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(),
new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430()});
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/51f145b5/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..7f23cad
--- /dev/null
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to431.java
@@ -0,0 +1,134 @@
+// 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 java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.utils.crypt.DBEncryptionUtil;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
+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;
+ }
+
+}