database upgrade

This commit is contained in:
Alex Huang 2011-03-09 17:55:39 -08:00
parent e81f02f9b5
commit 851c3344fc
3 changed files with 11 additions and 9 deletions

View File

@ -264,14 +264,14 @@
</target>
<target name="test" description="Execute one unit test" depends="compile-tests">
<junit fork="true" printsummary="true" clonevm="true" failureproperty="junit.failure">
<junit fork="true" printsummary="true" showoutput="true" failureproperty="junit.failure">
<!-- N.b. use failureproperty instead of haltonfailure, because if we use
the former, we will get no detailed report about the failure.
If the test fails, the fail element below will still assure that
the Ant run will exit with error status.
-->
<bootclasspath refid="test.classpath"/>
<classpath refid="test.classpath"/>
<jvmarg value="${debug.jvmarg}"/>
<batchtest todir="${unittest.dir}">
<formatter type="plain"/>
<fileset dir="${utils.test.dir}">
@ -281,8 +281,12 @@
<include name="**/${test}.java"/>
</fileset>
</batchtest>
<junitreport todir="${unittest.dir}">
<fileset dir="${unittest.dir}"/>
<report todir="${unittest.dir}/test-reports"/>
</junitreport>
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</junit>
<jvmarg value="${debug.jvmarg}"/>
<junitreport todir="${unittest.dir}">
<fileset dir="${unittest.dir}"/>
<report todir="${unittest.dir}/test-reports"/>

View File

@ -319,13 +319,14 @@ public class Upgrade217to22 implements DbUpgrade {
pstmt.close();
}
pstmt = conn.prepareStatement("SELECT id, guest_network_cidr FROM data_center");
pstmt = conn.prepareStatement("SELECT id, guest_network_cidr, domain FROM data_center");
rs = pstmt.executeQuery();
ArrayList<Object[]> dcs = new ArrayList<Object[]>();
while (rs.next()) {
Object[] dc = new Object[10];
dc[0] = rs.getLong(1); // data center id
dc[1] = rs.getString(2); // guest network cidr
dc[2] = rs.getString(3); // network domain
dcs.add(dc);
}
rs.close();
@ -455,11 +456,10 @@ public class Upgrade217to22 implements DbUpgrade {
String gateway = rs.getString(3);
String netmask = rs.getString(4);
String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask);
insertNetwork(conn, "DirectNetwork" + vlanId, "Direct network created for " + vlanId, "Guest", "Vlan", "vlan://" + tag, gateway, cidr, "Dhcp", 4, dcId, "DirectNetworkGuru", "Setup", 0, 0, null, null, "DirectAttached", true, null, true, null);
long directNetworkId = insertNetwork(conn, "DirectNetwork" + vlanId, "Direct network created for " + vlanId, "Guest", "Vlan", "vlan://" + tag, gateway, cidr, "Dhcp", 7, dcId, "DirectNetworkGuru", "Setup", 1, 1, null, null, "Direct", true, (String)dc[2], true, null);
upgradeUserIpAddress(conn, dcId, directNetworkId, "DirectNetwork");
}
upgradeUserIpAddress(conn, dcId, publicNetworkId, "VirtualNetwork");
}
}

View File

@ -64,8 +64,6 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
protected VersionDaoImpl() {
super();
_upgradeMap.put(new Pair<String, String>("2.1.7", "2.2.3"), new DbUpgrade[] { new Upgrade217to22(), new UpgradeSnapshot217to223()});
_upgradeMap.put(new Pair<String, String>("2.1.7", "2.2.1"), new DbUpgrade[] { new Upgrade217to22() });
_upgradeMap.put(new Pair<String, String>("2.1.7", "2.2.3"), new DbUpgrade[] { new Upgrade217to22(), new Upgrade221to222() });
CurrentVersionSearch = createSearchBuilder(String.class);
CurrentVersionSearch.select(null, Func.FIRST, CurrentVersionSearch.entity().getVersion());