mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
upgrade data center is done.
This commit is contained in:
parent
1014f93009
commit
e3438d2ff0
@ -26,7 +26,6 @@ import java.util.ArrayList;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade217to22 implements DbUpgrade {
|
||||
@ -41,9 +40,39 @@ public class Upgrade217to22 implements DbUpgrade {
|
||||
return file;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected void upgradeDataCenter() {
|
||||
|
||||
protected void upgradeDataCenter(Connection conn) {
|
||||
PreparedStatement pstmt;
|
||||
try {
|
||||
pstmt = conn.prepareStatement("SELECT value FROM configuration WHERE name='direct.attach.untagged.vlan.enabled'");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
boolean basicZone = !(rs.next() && Boolean.parseBoolean(rs.getString(1)));
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("UPDATE data_center SET networktype=?, dns_provider=?, gateway_provider=?, firewall_provider=?, dhcp_provider=?, lb_provider=?, vpn_provider=?, userdata_provider=?");
|
||||
if (basicZone) {
|
||||
pstmt.setString(1, "Basic");
|
||||
pstmt.setString(2, "DhcpServer");
|
||||
pstmt.setString(3, null);
|
||||
pstmt.setString(4, null);
|
||||
pstmt.setString(5, "DhcpServer");
|
||||
pstmt.setString(6, null);
|
||||
pstmt.setString(7, null);
|
||||
pstmt.setString(8, "DhcpServer");
|
||||
} else {
|
||||
pstmt.setString(1, "Advanced");
|
||||
pstmt.setString(2, "VirtualRouter");
|
||||
pstmt.setString(3, "VirtualRouter");
|
||||
pstmt.setString(4, "VirtualRouter");
|
||||
pstmt.setString(5, "VirtualRouter");
|
||||
pstmt.setString(6, "VirtualRouter");
|
||||
pstmt.setString(7, "VirtualRouter");
|
||||
pstmt.setString(8, "VirtualRouter");
|
||||
}
|
||||
pstmt.executeUpdate();
|
||||
pstmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Can't update data center ", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void upgradeNetworks(Connection conn) {
|
||||
@ -97,6 +126,7 @@ public class Upgrade217to22 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
upgradeDataCenter(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -18,6 +18,11 @@
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@ -29,6 +34,8 @@ import org.junit.Before;
|
||||
import com.cloud.upgrade.dao.VersionVO.Step;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DbTestUtils;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class VersionDaoImplTest extends TestCase {
|
||||
private static final Logger s_logger = Logger.getLogger(VersionDaoImplTest.class);
|
||||
@ -61,6 +68,31 @@ public class VersionDaoImplTest extends TestCase {
|
||||
s_logger.warn("Exception: ", e);
|
||||
assert false : "The test failed. Check logs";
|
||||
}
|
||||
|
||||
Connection conn = Transaction.getStandaloneConnection();
|
||||
PreparedStatement pstmt;
|
||||
try {
|
||||
pstmt = conn.prepareStatement("SELECT version FROm version");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
assert rs.next() : "No version selected";
|
||||
assert rs.getString(1).equals("2.2.1") : "VERSION stored is not 2.2.1: " + rs.getString(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT COUNT(*) FROM network_offerings");
|
||||
rs = pstmt.executeQuery();
|
||||
assert rs.next() : "Unable to get the count of network offerings.";
|
||||
assert (rs.getInt(1) == 7) : "Didn't find 7 network offerings but found " + rs.getInt(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT DISTINCT networktype FROM data_center");
|
||||
rs = pstmt.executeQuery();
|
||||
assert rs.next() && rs.getString(1).equals("Advanced") : "Network type is not advanced? " + rs.getString(1);
|
||||
assert !rs.next() : "Why do we have another one? " + rs.getString(1);
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Problem checking upgrade version", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user