You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
s_logger.debug("Upgrading user ip address for data center " + dcId + " network " + networkId + " vlan type " + vlanType);
625
-
PreparedStatementpstmt =
626
-
conn.prepareStatement("UPDATE user_ip_address INNER JOIN vlan ON user_ip_address.vlan_db_id=vlan.id SET user_ip_address.source_network_id=vlan.network_id WHERE user_ip_address.data_center_id=? AND vlan.vlan_type=?");
627
-
pstmt.setLong(1, dcId);
628
-
pstmt.setString(2, vlanType);
629
-
pstmt.executeUpdate();
630
-
pstmt.close();
631
-
632
-
pstmt =
633
-
conn.prepareStatement("SELECT user_ip_address.id, user_ip_address.public_ip_address, user_ip_address.account_id, user_ip_address.allocated FROM user_ip_address INNER JOIN vlan ON vlan.id=user_ip_address.vlan_db_id WHERE user_ip_address.data_center_id = ? AND vlan.vlan_type=?");
conn.prepareStatement("UPDATE user_ip_address INNER JOIN vlan ON user_ip_address.vlan_db_id=vlan.id SET user_ip_address.source_network_id=vlan.network_id WHERE user_ip_address.data_center_id=? AND vlan.vlan_type=?");) {
623
+
pstmt.setLong(1, dcId);
624
+
pstmt.setString(2, vlanType);
625
+
pstmt.executeUpdate();
645
626
}
646
-
rs.close();
647
-
pstmt.close();
648
-
649
-
s_logger.debug("Marking " + allocatedIps.size() + " ip addresses to belong to network " + networkId);
650
-
s_logger.debug("Updating mac addresses for data center id=" + dcId + ". Found " + allocatedIps.size() + " ip addresses to update");
651
-
652
-
for (Object[] allocatedIp : allocatedIps) {
653
-
pstmt = conn.prepareStatement("SELECT mac_address FROM data_center WHERE id = ?");
627
+
try (PreparedStatementpstmt =
628
+
conn.prepareStatement("SELECT user_ip_address.id, user_ip_address.public_ip_address, user_ip_address.account_id, user_ip_address.allocated FROM user_ip_address INNER JOIN vlan ON vlan.id=user_ip_address.vlan_db_id WHERE user_ip_address.data_center_id = ? AND vlan.vlan_type=?");) {
654
629
pstmt.setLong(1, dcId);
655
-
rs = pstmt.executeQuery();
656
-
if (!rs.next()) {
657
-
thrownewCloudRuntimeException("Unable to get mac address for data center " + dcId);
s_logger.debug("Upgrading user ip address for data center " + dcId + " network " + networkId + " vlan type " + vlanType);
678
-
PreparedStatementpstmt =
679
-
conn.prepareStatement("UPDATE user_ip_address INNER JOIN vlan ON user_ip_address.vlan_db_id=vlan.id SET source_network_id=? WHERE user_ip_address.data_center_id=? AND vlan.vlan_type=?");
680
-
pstmt.setLong(1, networkId);
681
-
pstmt.setLong(2, dcId);
682
-
pstmt.setString(3, vlanType);
683
-
pstmt.executeUpdate();
684
-
pstmt.close();
685
-
686
-
pstmt = conn.prepareStatement("UPDATE vlan SET network_id = ? WHERE data_center_id=? AND vlan_type=?");
687
-
pstmt.setLong(1, networkId);
688
-
pstmt.setLong(2, dcId);
689
-
pstmt.setString(3, vlanType);
690
-
pstmt.executeUpdate();
691
-
pstmt.close();
692
-
693
-
pstmt =
694
-
conn.prepareStatement("SELECT user_ip_address.id, user_ip_address.public_ip_address, user_ip_address.account_id, user_ip_address.allocated FROM user_ip_address INNER JOIN vlan ON vlan.id=user_ip_address.vlan_db_id WHERE user_ip_address.data_center_id = ? AND vlan.vlan_type='VirtualNetwork'");
conn.prepareStatement("UPDATE user_ip_address INNER JOIN vlan ON user_ip_address.vlan_db_id=vlan.id SET source_network_id=? WHERE user_ip_address.data_center_id=? AND vlan.vlan_type=?");) {
671
+
pstmt.setLong(1, networkId);
672
+
pstmt.setLong(2, dcId);
673
+
pstmt.setString(3, vlanType);
674
+
pstmt.executeUpdate();
705
675
}
706
-
rs.close();
707
-
pstmt.close();
708
-
709
-
for (Object[] allocatedIp : allocatedIps) {
710
-
pstmt = conn.prepareStatement("SELECT mac_address FROM data_center WHERE id = ?");
711
-
pstmt.setLong(1, dcId);
712
-
rs = pstmt.executeQuery();
713
-
if (!rs.next()) {
714
-
thrownewCloudRuntimeException("Unable to get mac address for data center " + dcId);
715
-
}
716
-
longmac = rs.getLong(1);
717
-
rs.close();
718
-
pstmt.close();
719
-
720
-
pstmt = conn.prepareStatement("UPDATE data_center SET mac_address=mac_address+1 WHERE id = ?");
721
-
pstmt.setLong(1, dcId);
676
+
try (PreparedStatementpstmt = conn.prepareStatement("UPDATE vlan SET network_id = ? WHERE data_center_id=? AND vlan_type=?");) {
677
+
pstmt.setLong(1, networkId);
678
+
pstmt.setLong(2, dcId);
679
+
pstmt.setString(3, vlanType);
722
680
pstmt.executeUpdate();
723
-
pstmt.close();
724
-
725
-
LongassociatedNetworkId = null;
726
-
if (allocatedIp[3] != null && allocatedIp[2] != null) {
727
-
pstmt = conn.prepareStatement("SELECT id FROM networks WHERE data_center_id=? AND account_id=?");
728
-
pstmt.setLong(1, dcId);
729
-
pstmt.setLong(2, (Long)allocatedIp[2]);
730
-
rs = pstmt.executeQuery();
731
-
if (!rs.next()) {
732
-
thrownewCloudRuntimeException("Unable to find a network for account " + allocatedIp[2] + " in dc " + dcId);
681
+
}
682
+
try (PreparedStatementpstmt =
683
+
conn.prepareStatement("SELECT user_ip_address.id, user_ip_address.public_ip_address, user_ip_address.account_id, user_ip_address.allocated FROM user_ip_address INNER JOIN vlan ON vlan.id=user_ip_address.vlan_db_id WHERE user_ip_address.data_center_id = ? AND vlan.vlan_type='VirtualNetwork'");) {
0 commit comments