From 10f1499438d8bb9d508eeb02086322e88a99e7e4 Mon Sep 17 00:00:00 2001 From: anthony Date: Fri, 15 Jul 2011 18:17:53 -0700 Subject: [PATCH] bug 10680: changing guest.network.device in global config also change existing hosts guest.network.device, reconnect will use network information in host_details status 10680: resolved fixed --- .../ConfigurationManagerImpl.java | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 55c7694c3c7..81b0adc6a70 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -91,6 +91,7 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.ResourceUnavailableException; +import com.cloud.host.dao.HostDetailsDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network; import com.cloud.network.Network.GuestIpType; @@ -164,6 +165,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura @Inject VlanDao _vlanDao; @Inject + HostDetailsDao _hostDetailsDao; + @Inject IPAddressDao _publicIpAddressDao; @Inject DataCenterIpAddressDao _privateIpAddressDao; @@ -270,6 +273,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } @Override + @DB public void updateConfiguration(long userId, String name, String value) { if (value != null && (value.trim().isEmpty() || value.equals("null"))) { value = null; @@ -286,8 +290,72 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value); throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support."); } + if ( Config.XenGuestNetwork.key().equals(name) ) { + String sql = "update host_details set value=? where name=?"; + Transaction txn = Transaction.currentTxn(); + PreparedStatement pstmt = null; + try { + pstmt = txn.prepareAutoCloseStatement(sql); + pstmt.setString(1, value); + pstmt.setString(2, "guest.network.device"); - if (Config.SystemVMUseLocalStorage.key().equalsIgnoreCase(name)) { + pstmt.executeUpdate(); + } catch (SQLException e) { + } catch (Throwable e) { + } + } else if ( Config.XenPrivateNetwork.key().equals(name) ) { + String sql = "update host_details set value=? where name=?"; + Transaction txn = Transaction.currentTxn(); + PreparedStatement pstmt = null; + try { + pstmt = txn.prepareAutoCloseStatement(sql); + pstmt.setString(1, value); + pstmt.setString(2, "private.network.device"); + + pstmt.executeUpdate(); + } catch (SQLException e) { + } catch (Throwable e) { + } + } else if ( Config.XenPublicNetwork.key().equals(name) ) { + String sql = "update host_details set value=? where name=?"; + Transaction txn = Transaction.currentTxn(); + PreparedStatement pstmt = null; + try { + pstmt = txn.prepareAutoCloseStatement(sql); + pstmt.setString(1, value); + pstmt.setString(2, "public.network.device"); + + pstmt.executeUpdate(); + } catch (SQLException e) { + } catch (Throwable e) { + } + } else if ( Config.XenStorageNetwork1.key().equals(name) ) { + String sql = "update host_details set value=? where name=?"; + Transaction txn = Transaction.currentTxn(); + PreparedStatement pstmt = null; + try { + pstmt = txn.prepareAutoCloseStatement(sql); + pstmt.setString(1, value); + pstmt.setString(2, "storage.network.device1"); + + pstmt.executeUpdate(); + } catch (SQLException e) { + } catch (Throwable e) { + } + } else if ( Config.XenStorageNetwork2.key().equals(name) ) { + String sql = "update host_details set value=? where name=?"; + Transaction txn = Transaction.currentTxn(); + PreparedStatement pstmt = null; + try { + pstmt = txn.prepareAutoCloseStatement(sql); + pstmt.setString(1, value); + pstmt.setString(2, "storage.network.device2"); + + pstmt.executeUpdate(); + } catch (SQLException e) { + } catch (Throwable e) { + } + } else if (Config.SystemVMUseLocalStorage.key().equalsIgnoreCase(name)) { if (s_logger.isDebugEnabled()) { s_logger.debug("Config 'system.vm.use.local.storage' changed to value:" + value + ", need to update System VM offerings"); }