@Override
  public boolean destroySecStorageVm(long vmId) {
    SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId);

    try {
      return _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
    } catch (ResourceUnavailableException e) {
      s_logger.warn("Unable to expunge " + ssvm, e);
      return false;
    }
  }
Пример #2
0
  @Override
  public VirtualRouter destroyRouter(
      final long routerId, final Account caller, final Long callerUserId)
      throws ResourceUnavailableException, ConcurrentOperationException {

    if (s_logger.isDebugEnabled()) {
      s_logger.debug("Attempting to destroy router " + routerId);
    }

    final DomainRouterVO router = _routerDao.findById(routerId);
    if (router == null) {
      return null;
    }

    _accountMgr.checkAccess(caller, null, true, router);

    _itMgr.expunge(router.getUuid());
    _routerDao.remove(router.getId());
    return router;
  }
  void garbageCollectUnusedElbVms() {
    List<DomainRouterVO> unusedElbVms = _elbVmMapDao.listUnusedElbVms();
    if (unusedElbVms != null && unusedElbVms.size() > 0)
      s_logger.info("Found " + unusedElbVms.size() + " unused ELB vms");
    Set<Long> currentGcCandidates = new HashSet<Long>();
    for (DomainRouterVO elbVm : unusedElbVms) {
      currentGcCandidates.add(elbVm.getId());
    }
    _gcCandidateElbVmIds.retainAll(currentGcCandidates);
    currentGcCandidates.removeAll(_gcCandidateElbVmIds);
    User user = _accountService.getSystemUser();
    for (Long elbVmId : _gcCandidateElbVmIds) {
      DomainRouterVO elbVm = _routerDao.findById(elbVmId);
      boolean gceed = false;

      try {
        s_logger.info("Attempting to stop ELB VM: " + elbVm);
        stop(elbVm, true, user, _systemAcct);
        gceed = true;
      } catch (ConcurrentOperationException e) {
        s_logger.warn("Unable to stop unused ELB vm " + elbVm + " due to ", e);
      } catch (ResourceUnavailableException e) {
        s_logger.warn("Unable to stop unused ELB vm " + elbVm + " due to ", e);
        continue;
      }
      if (gceed) {
        try {
          s_logger.info("Attempting to destroy ELB VM: " + elbVm);
          _itMgr.expunge(elbVm, user, _systemAcct);
        } catch (ResourceUnavailableException e) {
          s_logger.warn("Unable to destroy unused ELB vm " + elbVm + " due to ", e);
          gceed = false;
        }
      }
      if (!gceed) {
        currentGcCandidates.add(elbVm.getId());
      }
    }
    _gcCandidateElbVmIds = currentGcCandidates;
  }