コード例 #1
0
  @Override
  public boolean deleteHost(Long hostId) {
    List<SnapshotVO> snapshots = _snapshotDao.listByHostId(hostId);
    if (snapshots != null && !snapshots.isEmpty()) {
      throw new CloudRuntimeException(
          "Can not delete this secondary storage due to there are still snapshots on it ");
    }
    List<Long> list = _templateDao.listPrivateTemplatesByHost(hostId);
    if (list != null && !list.isEmpty()) {
      throw new CloudRuntimeException(
          "Can not delete this secondary storage due to there are still private template on it ");
    }
    _vmTemplateHostDao.deleteByHost(hostId);
    HostVO host = _hostDao.findById(hostId);
    host.setGuid(null);
    _hostDao.update(hostId, host);
    _hostDao.remove(hostId);

    return true;
  }