Skip to content

Commit f531881

Browse files
committed
CLOUDSTACK-8868: change the default vm.password.length to 10
also moved it to ConfigDepot
1 parent 97a5d6b commit f531881

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎server/src/com/cloud/configuration/Config.java‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -899,14 +899,6 @@ public enum Config {
899899
"0",
900900
"Default disk I/O read rate in requests per second allowed in User vm's disk.",
901901
null),
902-
VmPasswordLength(
903-
"Advanced",
904-
ManagementServer.class,
905-
Integer.class,
906-
"vm.password.length",
907-
"6",
908-
"Specifies the length of a randomly generated password",
909-
null),
910902
VmDiskThrottlingIopsWriteRate(
911903
"Advanced",
912904
ManagementServer.class,

‎server/src/com/cloud/configuration/ConfigurationManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ private String validateConfigurationValue(final String name, String value, final
770770
throw new InvalidParameterValueException("Please enter a positive value for the configuration parameter:" + name);
771771
}
772772
//TODO - better validation for all password pamameters
773-
if ("vm.password.length".equalsIgnoreCase(name) && val < 6) {
773+
if ("vm.password.length".equalsIgnoreCase(name) && val < 10) {
774774
throw new InvalidParameterValueException("Please enter a value greater than 6 for the configuration parameter:" + name);
775775
}
776776
} catch (final NumberFormatException e) {

‎server/src/com/cloud/server/ManagementServerImpl.java‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@
504504
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
505505
import org.apache.cloudstack.framework.config.ConfigDepot;
506506
import org.apache.cloudstack.framework.config.ConfigKey;
507+
import org.apache.cloudstack.framework.config.Configurable;
507508
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
508509
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
509510
import org.apache.cloudstack.framework.security.keystore.KeystoreManager;
@@ -671,9 +672,11 @@
671672
import com.cloud.vm.dao.UserVmDao;
672673
import com.cloud.vm.dao.VMInstanceDao;
673674

674-
public class ManagementServerImpl extends ManagerBase implements ManagementServer {
675+
public class ManagementServerImpl extends ManagerBase implements ManagementServer, Configurable {
675676
public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
676677

678+
static final ConfigKey<Integer> vmPasswordLength = new ConfigKey<Integer>("Advanced", Integer.class, "vm.password.length", "10",
679+
"Specifies the length of a randomly generated password", false);
677680
@Inject
678681
public AccountManager _accountMgr;
679682
@Inject
@@ -905,7 +908,7 @@ protected Map<String, String> getConfigs() {
905908

906909
@Override
907910
public String generateRandomPassword() {
908-
final Integer passwordLength = Integer.parseInt(_configDao.getValue("vm.password.length"));
911+
final Integer passwordLength = vmPasswordLength.value();
909912
return PasswordGenerator.generateRandomPassword(passwordLength);
910913
}
911914

@@ -3021,6 +3024,16 @@ public List<Class<?>> getCommands() {
30213024
return cmdList;
30223025
}
30233026

3027+
@Override
3028+
public String getConfigComponentName() {
3029+
return ManagementServer.class.getSimpleName();
3030+
}
3031+
3032+
@Override
3033+
public ConfigKey<?>[] getConfigKeys() {
3034+
return new ConfigKey<?>[] {vmPasswordLength};
3035+
}
3036+
30243037
protected class EventPurgeTask extends ManagedContextRunnable {
30253038
@Override
30263039
protected void runInContext() {

0 commit comments

Comments
 (0)