CS-16030: set UUID when persist public ip address

This commit is contained in:
Alena Prokharchyk 2012-08-16 10:12:24 -07:00
parent 6331bcb190
commit 0bf6de3eb2

View File

@ -23,9 +23,9 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.Vector; import java.util.Vector;
import com.cloud.network.IpAddress;
import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.db.DB; import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction; import com.cloud.utils.db.Transaction;
@ -448,7 +448,7 @@ public class IPRangeConfig {
} }
public Vector<String> savePublicIPRange(Transaction txn, long startIP, long endIP, long zoneId, long vlanDbId, Long sourceNetworkId, long physicalNetworkId) { public Vector<String> savePublicIPRange(Transaction txn, long startIP, long endIP, long zoneId, long vlanDbId, Long sourceNetworkId, long physicalNetworkId) {
String insertSql = "INSERT INTO `cloud`.`user_ip_address` (public_ip_address, data_center_id, vlan_db_id, mac_address, source_network_id, physical_network_id) VALUES (?, ?, ?, (select mac_address from `cloud`.`data_center` where id=?), ?, ?)"; String insertSql = "INSERT INTO `cloud`.`user_ip_address` (public_ip_address, data_center_id, vlan_db_id, mac_address, source_network_id, physical_network_id, uuid) VALUES (?, ?, ?, (select mac_address from `cloud`.`data_center` where id=?), ?, ?, ?)";
String updateSql = "UPDATE `cloud`.`data_center` set mac_address = mac_address+1 where id=?"; String updateSql = "UPDATE `cloud`.`data_center` set mac_address = mac_address+1 where id=?";
Vector<String> problemIPs = new Vector<String>(); Vector<String> problemIPs = new Vector<String>();
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -469,6 +469,7 @@ public class IPRangeConfig {
stmt.setLong(4, zoneId); stmt.setLong(4, zoneId);
stmt.setLong(5, sourceNetworkId); stmt.setLong(5, sourceNetworkId);
stmt.setLong(6, physicalNetworkId); stmt.setLong(6, physicalNetworkId);
stmt.setString(7, UUID.randomUUID().toString());
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
stmt = conn.prepareStatement(updateSql); stmt = conn.prepareStatement(updateSql);