Skip to content

Commit c1e5cb3

Browse files
committed
Merge remote-tracking branch 'origin/4.9' into 4.10
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents 2b06f1d + c566aba commit c1e5cb3

6 files changed

Lines changed: 34 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,17 @@ public boolean deleteSSHKeyPair(final DeleteSSHKeyPairCmd cmd) {
35783578
final Long domainId = cmd.getDomainId();
35793579
final Long projectId = cmd.getProjectId();
35803580

3581-
final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, projectId);
3581+
Account owner = null;
3582+
try {
3583+
owner = _accountMgr.finalizeOwner(caller, accountName, domainId, projectId);
3584+
} catch (InvalidParameterValueException ex) {
3585+
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && accountName != null && domainId != null) {
3586+
owner = _accountDao.findAccountIncludingRemoved(accountName, domainId);
3587+
}
3588+
if (owner == null) {
3589+
throw ex;
3590+
}
3591+
}
35823592

35833593
final SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), cmd.getName());
35843594
if (s == null) {

server/src/com/cloud/storage/StorageManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ public void createCapacityEntry(StoragePoolVO storagePool, short capacityType, l
991991
_capacityDao.persist(capacity);
992992
} else {
993993
CapacityVO capacity = capacities.get(0);
994-
if (capacity.getTotalCapacity() != totalOverProvCapacity || allocated != 0L || capacity.getCapacityState() != capacityState) {
994+
if (capacity.getTotalCapacity() != totalOverProvCapacity || allocated != capacity.getUsedCapacity() || capacity.getCapacityState() != capacityState) {
995995
capacity.setTotalCapacity(totalOverProvCapacity);
996996
capacity.setUsedCapacity(allocated);
997997
capacity.setCapacityState(capacityState);

server/src/com/cloud/user/AccountManagerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
import com.cloud.template.VirtualMachineTemplate;
8888
import com.cloud.user.Account.State;
8989
import com.cloud.user.dao.AccountDao;
90+
import com.cloud.user.dao.SSHKeyPairDao;
9091
import com.cloud.user.dao.UserAccountDao;
9192
import com.cloud.user.dao.UserDao;
9293
import com.cloud.utils.ConstantTimeComparator;
@@ -263,6 +264,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
263264
private DedicatedResourceDao _dedicatedDao;
264265
@Inject
265266
private GlobalLoadBalancerRuleDao _gslbRuleDao;
267+
@Inject
268+
private SSHKeyPairDao _sshKeyPairDao;
266269

267270
List<QuerySelector> _querySelectors;
268271

@@ -924,6 +927,12 @@ protected boolean cleanupAccount(AccountVO account, long callerUserId, Account c
924927
// Delete resource count and resource limits entries set for this account (if there are any).
925928
_resourceCountDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account);
926929
_resourceLimitDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account);
930+
931+
// Delete ssh keypairs
932+
List<SSHKeyPairVO> sshkeypairs = _sshKeyPairDao.listKeyPairs(accountId, account.getDomainId());
933+
for (SSHKeyPairVO keypair: sshkeypairs) {
934+
_sshKeyPairDao.remove(keypair.getId());
935+
}
927936
return true;
928937
} catch (Exception ex) {
929938
s_logger.warn("Failed to cleanup account " + account + " due to ", ex);

server/test/com/cloud/user/AccountManagerImplTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.net.UnknownHostException;
2121
import java.util.ArrayList;
2222
import java.util.Arrays;
23+
import java.util.List;
2324

2425
import com.cloud.acl.DomainChecker;
2526
import com.cloud.exception.PermissionDeniedException;
@@ -105,6 +106,13 @@ public void deleteUserAccount() {
105106
.thenReturn(true);
106107
Mockito.when(_vmSnapshotDao.listByAccountId(Mockito.anyLong())).thenReturn(new ArrayList<VMSnapshotVO>());
107108

109+
List<SSHKeyPairVO> sshkeyList = new ArrayList<SSHKeyPairVO>();
110+
SSHKeyPairVO sshkey = new SSHKeyPairVO();
111+
sshkey.setId(1l);
112+
sshkeyList.add(sshkey);
113+
Mockito.when(_sshKeyPairDao.listKeyPairs(Mockito.anyLong(), Mockito.anyLong())).thenReturn(sshkeyList);
114+
Mockito.when(_sshKeyPairDao.remove(Mockito.anyLong())).thenReturn(true);
115+
108116
Assert.assertTrue(accountManager.deleteUserAccount(42));
109117
// assert that this was a clean delete
110118
Mockito.verify(_accountDao, Mockito.never()).markForCleanup(

server/test/com/cloud/user/AccountManagetImplTestBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import com.cloud.storage.snapshot.SnapshotManager;
7070
import com.cloud.template.TemplateManager;
7171
import com.cloud.user.dao.AccountDao;
72+
import com.cloud.user.dao.SSHKeyPairDao;
7273
import com.cloud.user.dao.UserAccountDao;
7374
import com.cloud.user.dao.UserDao;
7475
import com.cloud.vm.VirtualMachineManager;
@@ -189,7 +190,8 @@ public class AccountManagetImplTestBase {
189190
ServiceOfferingDao _offeringDao;
190191
@Mock
191192
OrchestrationService _orchSrvc;
192-
193+
@Mock
194+
SSHKeyPairDao _sshKeyPairDao;
193195

194196
AccountManagerImpl accountManager;
195197

systemvm/patches/debian/config/opt/cloud/bin/checkbatchs2svpn.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ for i in $*
2020
do
2121
info=`/opt/cloud/bin/checks2svpn.sh $i`
2222
ret=$?
23-
echo -n "$i:$ret:$info&"
23+
batchInfo+="$i:$ret:$info&"
2424
done
25-
25+
echo -n $batchInfo

0 commit comments

Comments
 (0)