@@ -979,40 +979,40 @@ public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidP
979979 return _configDao .findByName (name );
980980 }
981981
982- String scope = null ;
982+ ConfigKey . Scope scope = ConfigKey . Scope . Global ;
983983 Long id = null ;
984984 int paramCountCheck = 0 ;
985985
986986 if (zoneId != null ) {
987- scope = ConfigKey .Scope .Zone . toString () ;
987+ scope = ConfigKey .Scope .Zone ;
988988 id = zoneId ;
989989 paramCountCheck ++;
990990 }
991991 if (clusterId != null ) {
992- scope = ConfigKey .Scope .Cluster . toString () ;
992+ scope = ConfigKey .Scope .Cluster ;
993993 id = clusterId ;
994994 paramCountCheck ++;
995995 }
996996 if (accountId != null ) {
997997 Account account = _accountMgr .getAccount (accountId );
998998 _accountMgr .checkAccess (caller , null , false , account );
999- scope = ConfigKey .Scope .Account . toString () ;
999+ scope = ConfigKey .Scope .Account ;
10001000 id = accountId ;
10011001 paramCountCheck ++;
10021002 }
10031003 if (domainId != null ) {
10041004 _accountMgr .checkAccess (caller , _domainDao .findById (domainId ));
1005- scope = ConfigKey .Scope .Domain . toString () ;
1005+ scope = ConfigKey .Scope .Domain ;
10061006 id = domainId ;
10071007 paramCountCheck ++;
10081008 }
10091009 if (storagepoolId != null ) {
1010- scope = ConfigKey .Scope .StoragePool . toString () ;
1010+ scope = ConfigKey .Scope .StoragePool ;
10111011 id = storagepoolId ;
10121012 paramCountCheck ++;
10131013 }
10141014 if (imageStoreId != null ) {
1015- scope = ConfigKey .Scope .ImageStore . toString () ;
1015+ scope = ConfigKey .Scope .ImageStore ;
10161016 id = imageStoreId ;
10171017 paramCountCheck ++;
10181018 }
@@ -1026,8 +1026,15 @@ public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidP
10261026 if (value .isEmpty () || value .equals ("null" )) {
10271027 value = (id == null ) ? null : "" ;
10281028 }
1029- final String updatedValue = updateConfiguration (userId , name , category , value , scope , id );
1029+
1030+ String currentValueInScope = getConfigurationValueInScope (config , name , scope , id );
1031+ final String updatedValue = updateConfiguration (userId , name , category , value , scope .name (), id );
10301032 if (value == null && updatedValue == null || updatedValue .equalsIgnoreCase (value )) {
1033+ logger .debug ("Config: {} value is updated from: {} to {} for scope: {}" , name ,
1034+ encryptEventValueIfConfigIsEncrypted (config , currentValueInScope ),
1035+ encryptEventValueIfConfigIsEncrypted (config , value ),
1036+ scope != null ? scope : ConfigKey .Scope .Global .name ());
1037+
10311038 return _configDao .findByName (name );
10321039 } else {
10331040 throw new CloudRuntimeException ("Unable to update configuration parameter " + name );
@@ -1120,6 +1127,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
11201127
11211128 String newValue = null ;
11221129 ConfigKey .Scope scopeVal = ConfigKey .Scope .valueOf (scope );
1130+ String currentValueInScope = getConfigurationValueInScope (config , name , scopeVal , id );
11231131 switch (scopeVal ) {
11241132 case Zone :
11251133 final DataCenterVO zone = _zoneDao .findById (id );
@@ -1205,12 +1213,28 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
12051213 newValue = optionalValue .isPresent () ? optionalValue .get ().toString () : defaultValue ;
12061214 }
12071215
1216+ logger .debug ("Config: {} value is updated from: {} to {} for scope: {}" , name ,
1217+ encryptEventValueIfConfigIsEncrypted (config , currentValueInScope ),
1218+ encryptEventValueIfConfigIsEncrypted (config , newValue ), scopeVal );
1219+
12081220 _configDepot .invalidateConfigCache (name , scopeVal , id );
12091221
12101222 CallContext .current ().setEventDetails (" Name: " + name + " New Value: " + (name .toLowerCase ().contains ("password" ) ? "*****" : defaultValue == null ? "" : defaultValue ));
12111223 return new Pair <Configuration , String >(_configDao .findByName (name ), newValue );
12121224 }
12131225
1226+ private String getConfigurationValueInScope (ConfigurationVO config , String name , ConfigKey .Scope scope , Long id ) {
1227+ String configValue ;
1228+ if (ConfigKey .Scope .Global .equals (scope )) {
1229+ configValue = config .getValue ();
1230+ } else {
1231+ ConfigKey <?> configKey = _configDepot .get (name );
1232+ Object currentValue = configKey .valueInScope (scope , id );
1233+ configValue = currentValue != null ? currentValue .toString () : null ;
1234+ }
1235+ return configValue ;
1236+ }
1237+
12141238 /**
12151239 * Validates whether a value is valid for the specified configuration. This includes type and range validation.
12161240 * @param name name of the configuration.
0 commit comments