@Override public String getConfigValue(long id, ConfigKey<?> key) { AccountDetailVO vo = findDetail(id, key.key()); return vo == null ? null : vo.getValue(); } }
@Override public Map<String, String> findDetails(long accountId) { QueryBuilder<AccountDetailVO> sc = QueryBuilder.create(AccountDetailVO.class); sc.and(sc.entity().getAccountId(), Op.EQ, accountId); List<AccountDetailVO> results = sc.list(); Map<String, String> details = new HashMap<String, String>(results.size()); for (AccountDetailVO r : results) { details.put(r.getName(), r.getValue()); } return details; }
public static AccountDetailVO getAccountDetail(long csAccountId, long storagePoolId, AccountDetailsDao accountDetailsDao) { AccountDetailVO accountDetail = accountDetailsDao.findDetail(csAccountId, SolidFireUtil.getAccountKey(storagePoolId)); if (accountDetail == null || accountDetail.getValue() == null) { accountDetail = accountDetailsDao.findDetail(csAccountId, SolidFireUtil.ACCOUNT_ID); } return accountDetail; }
@Override public long getSolidFireAccountId(String csAccountUuid, String storagePoolUuid) { long csAccountId = util.getAccountIdForAccountUuid(csAccountUuid); long storagePoolId = util.getStoragePoolIdForStoragePoolUuid(storagePoolUuid); AccountDetailVO accountDetail = accountDetailsDao.findDetail(csAccountId, SolidFireUtil.getAccountKey(storagePoolId)); if (accountDetail == null) { throw new CloudRuntimeException("Unable to find SF account for storage " + storagePoolUuid + " for CS account " + csAccountUuid); } String sfAccountId = accountDetail.getValue(); return Long.parseLong(sfAccountId); }
private long getCreateSolidFireAccountId(SolidFireUtil.SolidFireConnection sfConnection, long csAccountId, long storagePoolId) { AccountDetailVO accountDetail = SolidFireUtil.getAccountDetail(csAccountId, storagePoolId, accountDetailsDao); if (accountDetail == null || accountDetail.getValue() == null) { AccountVO account = accountDao.findById(csAccountId); String sfAccountName = SolidFireUtil.getSolidFireAccountName(account.getUuid(), account.getAccountId()); SolidFireUtil.SolidFireAccount sfAccount = SolidFireUtil.getAccount(sfConnection, sfAccountName); if (sfAccount == null) { sfAccount = createSolidFireAccount(sfConnection, sfAccountName); } SolidFireUtil.updateCsDbWithSolidFireAccountInfo(account.getId(), sfAccount, storagePoolId, accountDetailsDao); accountDetail = SolidFireUtil.getAccountDetail(csAccountId, storagePoolId, accountDetailsDao); } return Long.parseLong(accountDetail.getValue()); }