public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCenterId) {
    ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId);
    if (zoneHostInfo != null
        && (zoneHostInfo.getFlags() & RunningHostInfoAgregator.ZoneHostInfo.ROUTING_HOST_MASK)
            != 0) {
      VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId);
      HostVO secHost = _hostDao.findSecondaryStorageHost(dataCenterId);
      if (secHost == null) {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug(
              "No secondary storage available in zone "
                  + dataCenterId
                  + ", wait until it is ready to launch secondary storage vm");
        }
        return false;
      }

      boolean templateReady = false;
      if (template != null) {
        VMTemplateHostVO templateHostRef =
            _vmTemplateHostDao.findByHostTemplate(secHost.getId(), template.getId());
        templateReady =
            (templateHostRef != null) && (templateHostRef.getDownloadState() == Status.DOWNLOADED);
      }

      if (templateReady) {

        List<Pair<Long, Integer>> l =
            _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !_useLocalStorage);
        if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {

          return true;
        } else {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug(
                "Primary storage is not ready, wait until it is ready to launch secondary storage vm");
          }
        }
      } else {
        if (s_logger.isTraceEnabled()) {
          s_logger.trace("Zone host is ready, but secondary storage vm template is not ready");
        }
      }
    }
    return false;
  }
  @DB
  @Override
  public boolean deleteDataStore(DataStore store) {
    List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(store.getId());
    StoragePool pool = (StoragePool) store;
    boolean deleteFlag = false;
    // find the hypervisor where the storage is attached to.
    HypervisorType hType = null;
    if (hostPoolRecords.size() > 0) {
      hType = getHypervisorType(hostPoolRecords.get(0).getHostId());
    }

    // Remove the SR associated with the Xenserver
    for (StoragePoolHostVO host : hostPoolRecords) {
      DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(pool);
      final Answer answer = agentMgr.easySend(host.getHostId(), deleteCmd);

      if (answer != null && answer.getResult()) {
        deleteFlag = true;
        // if host is KVM hypervisor then send deleteStoragepoolcmd to all the kvm hosts.
        if (HypervisorType.KVM != hType) {
          break;
        }
      } else {
        if (answer != null) {
          s_logger.debug("Failed to delete storage pool: " + answer.getResult());
        }
      }
    }

    if (!deleteFlag) {
      throw new CloudRuntimeException("Failed to delete storage pool on host");
    }

    return dataStoreHelper.deletePrimaryDataStore(store);
  }
  @Override
  protected List<StoragePool> select(
      DiskProfile dskCh,
      VirtualMachineProfile vmProfile,
      DeploymentPlan plan,
      ExcludeList avoid,
      int returnUpTo) {

    List<StoragePool> suitablePools = new ArrayList<StoragePool>();

    s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm");

    if (!dskCh.useLocalStorage()) {
      return suitablePools;
    }

    // data disk and host identified from deploying vm (attach volume case)
    if (dskCh.getType() == Volume.Type.DATADISK && plan.getHostId() != null) {
      List<StoragePoolHostVO> hostPools = _poolHostDao.listByHostId(plan.getHostId());
      for (StoragePoolHostVO hostPool : hostPools) {
        StoragePoolVO pool = _storagePoolDao.findById(hostPool.getPoolId());
        if (pool != null && pool.isLocal()) {
          StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
          if (filter(avoid, pol, dskCh, plan)) {
            s_logger.debug(
                "Found suitable local storage pool " + pool.getId() + ", adding to list");
            suitablePools.add(pol);
          } else {
            avoid.addPool(pool.getId());
          }
        }

        if (suitablePools.size() == returnUpTo) {
          break;
        }
      }
    } else {
      if (plan.getPodId() == null) {
        // zone wide primary storage deployment
        return null;
      }
      List<StoragePoolVO> availablePools =
          _storagePoolDao.findLocalStoragePoolsByTags(
              plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), dskCh.getTags());
      for (StoragePoolVO pool : availablePools) {
        if (suitablePools.size() == returnUpTo) {
          break;
        }
        StoragePool pol = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
        if (filter(avoid, pol, dskCh, plan)) {
          suitablePools.add(pol);
        } else {
          avoid.addPool(pool.getId());
        }
      }

      // add remaining pools in cluster, that did not match tags, to avoid
      // set
      List<StoragePoolVO> allPools =
          _storagePoolDao.findLocalStoragePoolsByTags(
              plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), null);
      allPools.removeAll(availablePools);
      for (StoragePoolVO pool : allPools) {
        avoid.addPool(pool.getId());
      }
    }

    if (s_logger.isDebugEnabled()) {
      s_logger.debug(
          "LocalStoragePoolAllocator returning "
              + suitablePools.size()
              + " suitable storage pools");
    }

    return suitablePools;
  }