CS-16239: don't try to pull key information if the key was removed in the system

As a part of the commit, also checking deleteSshKeyPair name - admin was unable to delete the key on behalf of another user

Conflicts:

	server/src/com/cloud/api/ApiDBUtils.java
This commit is contained in:
Alena Prokharchyk 2012-09-11 14:33:39 -07:00 committed by Alex Huang
parent df7069d771
commit 4a8ffe34e2
2 changed files with 6 additions and 2 deletions

View File

@ -814,7 +814,11 @@ public class ApiDBUtils {
public static String getKeyPairName(String sshPublicKey) {
SSHKeyPairVO sshKeyPair = _sshKeyPairDao.findByPublicKey(sshPublicKey);
return sshKeyPair.getName();
//key might be removed prior to this point
if (sshKeyPair != null) {
return sshKeyPair.getName();
}
return null;
}
public static UserVmDetailVO findPublicKeyByVmId(long vmId) {

View File

@ -3298,7 +3298,7 @@ public class ManagementServerImpl implements ManagementServer {
throw ex;
}
return _sshKeyPairDao.deleteByName(caller.getAccountId(), caller.getDomainId(), cmd.getName());
return _sshKeyPairDao.deleteByName(owner.getAccountId(), owner.getDomainId(), cmd.getName());
}
@Override