|
35 | 35 | import javax.inject.Inject; |
36 | 36 | import javax.naming.ConfigurationException; |
37 | 37 |
|
| 38 | +import com.cloud.server.ManagementService; |
38 | 39 | import org.apache.commons.codec.binary.Base64; |
39 | 40 | import org.apache.log4j.Logger; |
40 | 41 |
|
@@ -457,6 +458,8 @@ public enum UserVmCloneType { |
457 | 458 | VolumeApiService _volumeService; |
458 | 459 | @Inject |
459 | 460 | DataStoreManager _dataStoreMgr; |
| 461 | + @Inject |
| 462 | + ManagementService _mgr; |
460 | 463 |
|
461 | 464 | protected ScheduledExecutorService _executor = null; |
462 | 465 | protected int _expungeInterval; |
@@ -642,7 +645,7 @@ public UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableExce |
642 | 645 | String password = null; |
643 | 646 | String sshPublicKey = s.getPublicKey(); |
644 | 647 | if (template != null && template.getEnablePassword()) { |
645 | | - password = generateRandomPassword(); |
| 648 | + password = _mgr.generateRandomPassword(); |
646 | 649 | } |
647 | 650 |
|
648 | 651 | boolean result = resetVMSSHKeyInternal(vmId, sshPublicKey, password); |
@@ -3353,10 +3356,6 @@ public void finalizeStop(VirtualMachineProfile profile, Answer answer) { |
3353 | 3356 | } |
3354 | 3357 | } |
3355 | 3358 |
|
3356 | | - public String generateRandomPassword() { |
3357 | | - return PasswordGenerator.generateRandomPassword(6); |
3358 | | - } |
3359 | | - |
3360 | 3359 | @Override |
3361 | 3360 | public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMachine(long vmId, Long hostId, Map<VirtualMachineProfile.Param, Object> additionalParams, String deploymentPlannerToUse) |
3362 | 3361 | throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { |
@@ -3431,7 +3430,7 @@ public Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMach |
3431 | 3430 |
|
3432 | 3431 | String password = "saved_password"; |
3433 | 3432 | if (template.getEnablePassword()) { |
3434 | | - password = generateRandomPassword(); |
| 3433 | + password = _mgr.generateRandomPassword(); |
3435 | 3434 | } |
3436 | 3435 |
|
3437 | 3436 | if (!validPassword(password)) { |
@@ -4705,7 +4704,7 @@ public UserVm restoreVMInternal(Account caller, UserVmVO vm, Long newTemplateId) |
4705 | 4704 | } |
4706 | 4705 |
|
4707 | 4706 | if (template.getEnablePassword()) { |
4708 | | - String password = generateRandomPassword(); |
| 4707 | + String password = _mgr.generateRandomPassword(); |
4709 | 4708 | boolean result = resetVMPasswordInternal(vmId, password); |
4710 | 4709 | if (result) { |
4711 | 4710 | vm.setPassword(password); |
|
0 commit comments