mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Allow for length of password on VMs to be set via global settings
Conflicts:
server/src/com/cloud/vm/UserVmManagerImpl.java
setup/db/db/schema-430to440.sql
This commit is contained in:
parent
08d7b46be7
commit
d4428a93a8
@ -895,7 +895,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
|
||||
@Override
|
||||
public String generateRandomPassword() {
|
||||
return PasswordGenerator.generateRandomPassword(6);
|
||||
Integer passwordLength = Integer.parseInt(_configDao.getValue("vm.password.length"));
|
||||
return PasswordGenerator.generateRandomPassword(passwordLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,6 +35,7 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.server.ManagementService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -482,6 +483,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
@Inject
|
||||
VolumeOrchestrationService volumeMgr;
|
||||
|
||||
@Inject
|
||||
ManagementService _mgr;
|
||||
|
||||
@Override
|
||||
public UserVmVO getVirtualMachine(long vmId) {
|
||||
return _vmDao.findById(vmId);
|
||||
@ -643,7 +647,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
String password = null;
|
||||
String sshPublicKey = s.getPublicKey();
|
||||
if (template != null && template.getEnablePassword()) {
|
||||
password = generateRandomPassword();
|
||||
password = _mgr.generateRandomPassword();
|
||||
}
|
||||
|
||||
boolean result = resetVMSSHKeyInternal(vmId, sshPublicKey, password);
|
||||
@ -3362,10 +3366,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
}
|
||||
}
|
||||
|
||||
public String generateRandomPassword() {
|
||||
return PasswordGenerator.generateRandomPassword(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
@ -3443,7 +3443,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
if (vm.getDetail("password") != null) {
|
||||
password = DBEncryptionUtil.decrypt(vm.getDetail("password"));
|
||||
} else {
|
||||
password = generateRandomPassword();
|
||||
password = _mgr.generateRandomPassword();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4733,7 +4733,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
String password = null;
|
||||
|
||||
if (template.getEnablePassword()) {
|
||||
password = generateRandomPassword();
|
||||
password = _mgr.generateRandomPassword();
|
||||
boolean result = resetVMPasswordInternal(vmId, password);
|
||||
if (result) {
|
||||
vm.setPassword(password);
|
||||
|
||||
@ -2494,3 +2494,5 @@ CREATE TABLE `cloud`.`snapshot_policy_details` (
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_snapshot_policy_details__snapshot_policy_id` FOREIGN KEY `fk_snapshot_policy_details__snapshot_policy_id`(`policy_id`) REFERENCES `snapshot_policy`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('Secure', 'DEFAULT', 'management-server', 'vm.password.length', '6', 'Specifies the length of a randomly generated password', '6') ON DUPLICATE KEY UPDATE category='Secure';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user