Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ public boolean saveSSHKey(final Network network, final NicProfile nic, final Vir

final boolean canHandle = canHandle(network.getTrafficType());

if (canHandle) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since password is not reset when reset sshkey (in #4819 ), it is not needed to save password in vm details.

storePasswordInVmDetails(vm);
}

return canHandle;
}

Expand Down
11 changes: 4 additions & 7 deletions 11 server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ public UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableExce
throw new InvalidParameterValueException("unable to find a virtual machine by id" + cmd.getId());
}

_vmDao.loadDetails(userVm);
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(userVm.getTemplateId());

// Do parameters input validation
Expand Down Expand Up @@ -886,16 +885,14 @@ public UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableExce
throw new CloudRuntimeException("Failed to reset SSH Key for the virtual machine ");
}

removeEncryptedPasswordFromUserVmVoDetails(userVm);
removeEncryptedPasswordFromUserVmVoDetails(vmId);

_vmDao.loadDetails(userVm);
return userVm;
}

protected void removeEncryptedPasswordFromUserVmVoDetails(UserVmVO userVmVo) {
Map<String, String> details = userVmVo.getDetails();
details.remove(VmDetailConstants.ENCRYPTED_PASSWORD);
userVmVo.setDetails(details);
_vmDao.saveDetails(userVmVo);
protected void removeEncryptedPasswordFromUserVmVoDetails(long vmId) {
userVmDetailsDao.removeDetail(vmId, VmDetailConstants.ENCRYPTED_PASSWORD);
}

private boolean resetVMSSHKeyInternal(Long vmId, String sshPublicKey) throws ResourceUnavailableException, InsufficientCapacityException {
Expand Down
13 changes: 0 additions & 13 deletions 13 server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,17 +558,4 @@ private DiskOfferingVO prepareDiskOffering(long rootSize, long diskOfferingId, l
Mockito.when(newRootDiskOffering.getName()).thenReturn("OfferingName");
return newRootDiskOffering;
}

@Test
public void validateRemoveEncryptedPasswordFromUserVmVoDetails(){
Map<String, String> detailsMock = Mockito.mock(HashMap.class);

Mockito.doReturn(detailsMock).when(userVmVoMock).getDetails();
Mockito.doNothing().when(userVmDao).saveDetails(userVmVoMock);
userVmManagerImpl.removeEncryptedPasswordFromUserVmVoDetails(userVmVoMock);

Mockito.verify(detailsMock, Mockito.times(1)).remove(VmDetailConstants.ENCRYPTED_PASSWORD);
Mockito.verify(userVmVoMock, Mockito.times(1)).setDetails(detailsMock);
Mockito.verify(userVmDao, Mockito.times(1)).saveDetails(userVmVoMock);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.