@Override
  public void process() {
    logger.info("Processing virtual pool auto tiering policy migration");

    DbClient dbClient = getDbClient();
    try {
      List<URI> virtualPoolUris = dbClient.queryByType(VirtualPool.class, true);
      Iterator<VirtualPool> virtualPools =
          dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolUris, true);

      while (virtualPools.hasNext()) {
        VirtualPool virtualPool = virtualPools.next();
        // If there is a FAST policy associated with the vpool, then mark the uniquePolicyNames to
        // true
        if (virtualPool.getAutoTierPolicyName() != null
            && !virtualPool.getAutoTierPolicyName().isEmpty()) {
          // No way other than using contains to differentiate NativeGuid
          if (virtualPool.getAutoTierPolicyName().contains(NATIVE_GUID_DELIMITER)) {
            virtualPool.setUniquePolicyNames(false);
          } else {
            virtualPool.setUniquePolicyNames(true);
          }
          dbClient.persistObject(virtualPool);
          logger.info(
              "Updating VirtualPool (id={}) with  unique policy names set to {}",
              virtualPool.getId().toString(),
              virtualPool.getUniquePolicyNames());
        }
      }
    } catch (Exception ex) {
      logger.error("Exception occured while migrating auto tiering policy of vpool");
      logger.error(ex.getMessage(), ex);
    }
  }
  /**
   * Checks the UnManaged Volume's policy with vPool's policy.
   *
   * @param vPool the vPool
   * @param autoTierPolicyId the auto tier policy id on unmanaged volume
   * @param system the system
   * @return true, if matching, false otherwise
   */
  public static boolean checkVPoolValidForUnManagedVolumeAutoTieringPolicy(
      VirtualPool vPool, String autoTierPolicyId, StorageSystem system) {

    _log.debug("Policy Id: {}, vPool: {}", autoTierPolicyId, vPool);
    boolean policyMatching = false;
    String policyIdfromVPool = vPool.getAutoTierPolicyName();
    if (autoTierPolicyId != null) {
      if (policyIdfromVPool != null) {
        if (vPool.getUniquePolicyNames()
            || DiscoveredDataObject.Type.vnxblock.name().equalsIgnoreCase(system.getSystemType())) {
          // Unique Policy names field will not be set for VNX. vPool will have policy name, not the
          // policy's nativeGuid
          policyIdfromVPool =
              NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(
                  system.getNativeGuid(),
                  policyIdfromVPool,
                  NativeGUIDGenerator.getTieringPolicyKeyForSystem(system));
          _log.debug("Policy Id generated: {}", policyIdfromVPool);
        }
        if (autoTierPolicyId.equalsIgnoreCase(policyIdfromVPool)) {
          policyMatching = true;
        }
      }
    } else if ((policyIdfromVPool == null) || (policyIdfromVPool.equalsIgnoreCase("none"))) {
      // if policy is not set in both unmanaged volume and vPool. Note
      // that the value in the vpool could be set to "none".
      policyMatching = true;
    }

    // Default policy for VNX - match volume with default policy to vPool with no policy as well
    if (!policyMatching
        && DiscoveredDataObject.Type.vnxblock.name().equalsIgnoreCase(system.getSystemType())) {
      if (autoTierPolicyId != null
          && autoTierPolicyId.contains(VnxFastPolicy.DEFAULT_START_HIGH_THEN_AUTOTIER.name())
          && policyIdfromVPool == null) {
        policyMatching = true;
      }
    }

    // Default policy for HDS - match volume with default policy to vPool with no policy as well
    if (!policyMatching
        && DiscoveredDataObject.Type.hds.name().equalsIgnoreCase(system.getSystemType())) {
      if (autoTierPolicyId != null
          && autoTierPolicyId.contains(HitachiTieringPolicy.All.name())
          && policyIdfromVPool == null) {
        policyMatching = true;
      }
    }

    return policyMatching;
  }
  /**
   * Filters supported vPools in UnManaged Volume based on Auto-Tiering Policy.
   *
   * @param unManagedVolume the UnManaged volume
   * @param policyName the policy name associated with UnManaged volume
   * @param system the system
   * @param dbClient the db client
   */
  public static void filterSupportedVpoolsBasedOnTieringPolicy(
      UnManagedVolume unManagedVolume, String policyName, StorageSystem system, DbClient dbClient) {

    StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
    StringSet supportedVpoolURIs =
        unManagedVolumeInformation.get(SupportedVolumeInformation.SUPPORTED_VPOOL_LIST.toString());
    List<String> vPoolsToRemove = new ArrayList<String>();
    if (supportedVpoolURIs != null) {
      Iterator<String> itr = supportedVpoolURIs.iterator();
      while (itr.hasNext()) {
        String uri = itr.next();
        VirtualPool vPool = dbClient.queryObject(VirtualPool.class, URI.create(uri));
        if (vPool != null && !vPool.getInactive()) {
          // generate unmanaged volume's policyId
          String autoTierPolicyId =
              NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(
                  system.getNativeGuid(),
                  policyName,
                  NativeGUIDGenerator.getTieringPolicyKeyForSystem(system));
          if (!checkVPoolValidForUnManagedVolumeAutoTieringPolicy(
              vPool, autoTierPolicyId, system)) {
            String msg =
                "Removing vPool %s from SUPPORTED_VPOOL_LIST in UnManagedVolume %s "
                    + "since Auto-tiering Policy %s in UnManaged Volume does not match with vPool's (%s)";
            _log.info(
                String.format(
                    msg,
                    new Object[] {
                      uri, unManagedVolume.getId(), autoTierPolicyId, vPool.getAutoTierPolicyName()
                    }));
            vPoolsToRemove.add(uri);
          }
        } else {
          // remove Inactive vPool URI
          vPoolsToRemove.add(uri);
        }
      }
    }
    for (String uri : vPoolsToRemove) { // UnManagedVolume object is persisted by caller
      supportedVpoolURIs.remove(uri);
    }
  }