diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 182ec50e300..25d84374ac6 100644 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -899,14 +899,6 @@ public enum Config { "0", "Default disk I/O read rate in requests per second allowed in User vm's disk.", null), - VmPasswordLength( - "Advanced", - ManagementServer.class, - Integer.class, - "vm.password.length", - "6", - "Specifies the length of a randomly generated password", - null), VmDiskThrottlingIopsWriteRate( "Advanced", ManagementServer.class, diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 69e70e6cd9e..74af277dfbd 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -770,7 +770,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("Please enter a positive value for the configuration parameter:" + name); } //TODO - better validation for all password pamameters - if ("vm.password.length".equalsIgnoreCase(name) && val < 6) { + if ("vm.password.length".equalsIgnoreCase(name) && val < 10) { throw new InvalidParameterValueException("Please enter a value greater than 6 for the configuration parameter:" + name); } } catch (final NumberFormatException e) { diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 25071a2b28f..ee6a42dd8db 100644 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -504,6 +504,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.impl.ConfigurationVO; import org.apache.cloudstack.framework.security.keystore.KeystoreManager; @@ -671,9 +672,11 @@ import com.cloud.vm.dao.SecondaryStorageVmDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; -public class ManagementServerImpl extends ManagerBase implements ManagementServer { +public class ManagementServerImpl extends ManagerBase implements ManagementServer, Configurable { public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName()); + static final ConfigKey vmPasswordLength = new ConfigKey("Advanced", Integer.class, "vm.password.length", "10", + "Specifies the length of a randomly generated password", false); @Inject public AccountManager _accountMgr; @Inject @@ -905,7 +908,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe @Override public String generateRandomPassword() { - final Integer passwordLength = Integer.parseInt(_configDao.getValue("vm.password.length")); + final Integer passwordLength = vmPasswordLength.value(); return PasswordGenerator.generateRandomPassword(passwordLength); } @@ -3021,6 +3024,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe return cmdList; } + @Override + public String getConfigComponentName() { + return ManagementServer.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {vmPasswordLength}; + } + protected class EventPurgeTask extends ManagedContextRunnable { @Override protected void runInContext() {