mirror of https://github.com/apache/cloudstack.git
bug 9305: set Mode field for domR/CPVM/SSVM nics
status 9305: resolved fixed
This commit is contained in:
parent
204aa86686
commit
534623706d
|
|
@ -953,6 +953,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
continue;
|
||||
}
|
||||
|
||||
if (requested != null && requested.getMode() == null) {
|
||||
profile.setMode(requested.getMode());
|
||||
} else {
|
||||
profile.setMode(config.getMode());
|
||||
}
|
||||
|
||||
NicVO vo = new NicVO(guru.getName(), vm.getId(), config.getId(), vm.getType());
|
||||
|
||||
while (deviceIds[deviceId] && deviceId < deviceIds.length) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.sql.Connection;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
|
@ -58,6 +59,7 @@ public class Upgrade222to224 implements DbUpgrade {
|
|||
public void performDataMigration(Connection conn) {
|
||||
updateClusterIdInOpHostCapacity(conn);
|
||||
updateGuestOsType(conn);
|
||||
updateNicsWithMode(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -144,4 +146,33 @@ public class Upgrade222to224 implements DbUpgrade {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNicsWithMode(Connection conn) {
|
||||
try {
|
||||
HashMap<Long, Long> nicNetworkMaps = new HashMap<Long, Long>();
|
||||
PreparedStatement pstmt = conn.prepareStatement("SELECT id, network_id FROM nics WHERE mode IS NULL");
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
nicNetworkMaps.put(rs.getLong(1), rs.getLong(2));
|
||||
}
|
||||
|
||||
for (Long nic : nicNetworkMaps.keySet()) {
|
||||
pstmt = conn.prepareStatement("SELECT mode FROM networks WHERE id=?");
|
||||
pstmt.setLong(1, nicNetworkMaps.get(nic));
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
String mode = rs.getString(1);
|
||||
pstmt = conn.prepareStatement("UPDATE nics SET mode=? where id=?");
|
||||
pstmt.setString(1, mode);
|
||||
pstmt.setLong(2, nic);
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
|
||||
}catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to update the Mode field for nics as a part of 222 to 224 upgrade", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue