Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions server/src/com/cloud/network/StorageNetworkManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,19 @@ private void createStorageIpEntires(TransactionLegacy txn, long rangeId, String
String insertSql =
"INSERT INTO `cloud`.`op_dc_storage_network_ip_address` (range_id, ip_address, mac_address, taken) VALUES (?, ?, (select mac_address from `cloud`.`data_center` where id=?), ?)";
String updateSql = "UPDATE `cloud`.`data_center` set mac_address = mac_address+1 where id=?";
try (Connection conn = txn.getConnection();) {
while (startIPLong <= endIPLong) {
try (PreparedStatement stmt_insert = conn.prepareStatement(insertSql); ) {
stmt_insert.setLong(1, rangeId);
stmt_insert.setString(2, NetUtils.long2Ip(startIPLong++));
stmt_insert.setLong(3, zoneId);
stmt_insert.setNull(4, java.sql.Types.DATE);
stmt_insert.executeUpdate();
}
Connection conn = txn.getConnection();
while (startIPLong <= endIPLong) {
try (PreparedStatement stmt_insert = conn.prepareStatement(insertSql);) {
stmt_insert.setLong(1, rangeId);
stmt_insert.setString(2, NetUtils.long2Ip(startIPLong++));
stmt_insert.setLong(3, zoneId);
stmt_insert.setNull(4, java.sql.Types.DATE);
stmt_insert.executeUpdate();
}

try (PreparedStatement stmt_update = txn.prepareStatement(updateSql);) {
stmt_update.setLong(1, zoneId);
stmt_update.executeUpdate();
}
try (PreparedStatement stmt_update = txn.prepareStatement(updateSql);) {
stmt_update.setLong(1, zoneId);
stmt_update.executeUpdate();
}
}
}
Expand Down