CS-15450: vmware:upgrade fails from 2.2.14GA to 3.04

CS-15414 [upgrde from 2.2.14 to 3.0.4] Need to decrypt xen.guest.network.device value before setting the traffic label after upgrade.

Reviewed-by: Alena

- This uncovered a generic case where only 1 network tag is used and other few untagged networks.
- Upgrdae 303 to 304, should create a physical network for the untagged networks.
- Earlier we were doing this only if the 303 db has multiple physical networks. But in this case the 303 db will  have just 1 physcial network (created due to the single tag used on 2.2.14).
- So  we need to create the extra physical network for the untagged networks irrespective of the number of physical networks present in 303 db.

- This commit also take care of the decryption of the xen.guest.network.device value
This commit is contained in:
prachi 2012-07-05 15:07:04 -07:00
parent 64ce2eac32
commit b818e6f68f
1 changed files with 42 additions and 37 deletions

View File

@ -20,6 +20,8 @@ import java.sql.SQLException;
import java.util.UUID;
import org.apache.log4j.Logger;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.exception.CloudRuntimeException;
public class Upgrade303to304 extends Upgrade30xBase implements DbUpgrade {
@ -88,6 +90,46 @@ public class Upgrade303to304 extends Upgrade30xBase implements DbUpgrade {
pstmtUpdate.executeUpdate();
pstmtUpdate.close();
}
//check if any networks were untagged and remaining to be mapped to a physical network
pstmt = conn.prepareStatement("SELECT count(n.id) FROM networks n WHERE n.physical_network_id IS NULL AND n.traffic_type = 'Guest' and n.data_center_id = ? and n.removed is null");
pstmt.setLong(1, zoneId);
rs = pstmt.executeQuery();
if(rs.next()){
Long count = rs.getLong(1);
if(count > 0){
// find the default tag to use from global config or use 'cloud-private'
String xenGuestLabel = getNetworkLabelFromConfig(conn, "xen.guest.network.device");
//Decrypt this value.
xenGuestLabel = DBEncryptionUtil.decrypt(xenGuestLabel);
if(xenGuestLabel == null){
xenGuestLabel = "cloud-private";
}
//Create a physical network with guest traffic type and this tag
long physicalNetworkId = addPhysicalNetworkToZone(conn, zoneId, zoneName, networkType, null, domainId);
addTrafficType(conn, physicalNetworkId, "Guest", xenGuestLabel, null, null);
addDefaultVRProvider(conn, physicalNetworkId, zoneId);
addDefaultSGProvider(conn, physicalNetworkId, zoneId, networkType, true);
PreparedStatement pstmt3 = conn.prepareStatement("SELECT n.id FROM networks n WHERE n.physical_network_id IS NULL AND n.traffic_type = 'Guest' and n.data_center_id = ? and n.removed is null");
pstmt3.setLong(1, zoneId);
ResultSet rsNet = pstmt3.executeQuery();
s_logger.debug("Adding PhysicalNetwork to VLAN");
s_logger.debug("Adding PhysicalNetwork to user_ip_address");
s_logger.debug("Adding PhysicalNetwork to networks");
while(rsNet.next()){
Long networkId = rsNet.getLong(1);
addPhysicalNtwk_To_Ntwk_IP_Vlan(conn, physicalNetworkId,networkId);
}
rsNet.close();
pstmt3.close();
}
}
rs.close();
pstmt.close();
boolean multiplePhysicalNetworks = false;
@ -107,43 +149,6 @@ public class Upgrade303to304 extends Upgrade30xBase implements DbUpgrade {
if(multiplePhysicalNetworks){
//check if any networks were untagged and remaining to be mapped to a physical network
pstmt = conn.prepareStatement("SELECT count(n.id) FROM networks n WHERE n.physical_network_id IS NULL AND n.traffic_type = 'Guest' and n.data_center_id = ? and n.removed is null");
pstmt.setLong(1, zoneId);
rs = pstmt.executeQuery();
if(rs.next()){
Long count = rs.getLong(1);
if(count > 0){
// find the default tag to use from global config or use 'cloud-private'
String xenGuestLabel = getNetworkLabelFromConfig(conn, "xen.guest.network.device");
if(xenGuestLabel == null){
xenGuestLabel = "cloud-private";
}
//Create a physical network with guest traffic type and this tag
long physicalNetworkId = addPhysicalNetworkToZone(conn, zoneId, zoneName, networkType, null, domainId);
addTrafficType(conn, physicalNetworkId, "Guest", xenGuestLabel, null, null);
addDefaultVRProvider(conn, physicalNetworkId, zoneId);
addDefaultSGProvider(conn, physicalNetworkId, zoneId, networkType, true);
PreparedStatement pstmt3 = conn.prepareStatement("SELECT n.id FROM networks n WHERE n.physical_network_id IS NULL AND n.traffic_type = 'Guest' and n.data_center_id = ? and n.removed is null");
pstmt3.setLong(1, zoneId);
ResultSet rsNet = pstmt3.executeQuery();
s_logger.debug("Adding PhysicalNetwork to VLAN");
s_logger.debug("Adding PhysicalNetwork to user_ip_address");
s_logger.debug("Adding PhysicalNetwork to networks");
while(rsNet.next()){
Long networkId = rsNet.getLong(1);
addPhysicalNtwk_To_Ntwk_IP_Vlan(conn, physicalNetworkId,networkId);
}
rsNet.close();
pstmt3.close();
}
}
rs.close();
pstmt.close();
//add tags to the physical networks if not present and clone offerings
pstmt = conn.prepareStatement("SELECT pn.id as pid , ptag.tag as tag FROM `cloud`.`physical_network` pn LEFT JOIN `cloud`.`physical_network_tags` ptag ON pn.id = ptag.physical_network_id where pn.data_center_id = ?");