protected BlockVirtualPoolRestRep doSave() {
   BlockVirtualPoolRestRep virtualPool;
   if (isNew()) {
     BlockVirtualPoolBuilder builder = apply(new BlockVirtualPoolBuilder());
     virtualPool = VirtualPoolUtils.create(builder.getVirtualPool());
     this.id = ResourceUtils.stringId(virtualPool);
   } else {
     BlockVirtualPoolRestRep oldVirtualPool = VirtualPoolUtils.getBlockVirtualPool(id);
     BlockVirtualPoolUpdateBuilder builder =
         apply(new BlockVirtualPoolUpdateBuilder(oldVirtualPool));
     virtualPool = VirtualPoolUtils.update(id, builder.getVirtualPoolUpdate());
     List<NamedRelatedResourceRep> matchingPools =
         VirtualPoolUtils.refreshMatchingPools(virtualPool);
     Logger.info(
         "Refreshed Block Virtual Pool '%s' matching pools: %d",
         virtualPool.getName(), matchingPools.size());
   }
   virtualPool = saveStoragePools(virtualPool);
   return virtualPool;
 }
 public MatchingBlockStoragePoolsCall matchingStoragePools() {
   BlockVirtualPoolBuilder builder = new BlockVirtualPoolBuilder();
   apply(builder);
   builder.setUseMatchedPools(true);
   return new MatchingBlockStoragePoolsCall(builder.getVirtualPool());
 }
  private BlockVirtualPoolBuilder apply(BlockVirtualPoolBuilder builder) {
    applyCommon(builder);
    builder.setMinPaths(defaultInt(minPaths, 1));
    builder.setMaxPaths(defaultInt(maxPaths, 1));
    builder.setPathsPerInitiator(defaultInt(initiatorPaths, 1));
    builder.setDriveType(driveType);
    builder.setAutoTieringPolicyName(autoTierPolicy);
    builder.setExpandable(defaultBoolean(expandable));
    builder.setFastExpansion(defaultBoolean(fastExpansion));
    builder.setMultiVolumeConsistency(defaultBoolean(multiVolumeConsistency));
    builder.setSnapshots(maxSnapshots);
    builder.setContinuousCopies(maxContinuousCopies, uri(continuousCopyVirtualPool));
    builder.setThinVolumePreAllocationPercentage(thinPreAllocationPercent);
    builder.setUniquePolicyNames(defaultBoolean(uniqueAutoTierPolicyNames));
    builder.setRaidLevels(raidLevels);
    builder.setHostIOLimitBandwidth(defaultInt(hostIOLimitBandwidth, 0));
    builder.setHostIOLimitIOPs(defaultInt(hostIOLimitIOPs, 0));

    if (ProtectionSystemTypes.isRecoverPoint(remoteProtection)) {
      builder.enableRecoverPoint(RPCopyForm.formatJournalSize(rpJournalSize, rpJournalSizeUnit));
      builder.setRecoverPointRemoteCopyMode(rpRemoteCopyMode);
      builder.setRecoverPointRpo(rpRpoValue, rpRpoType);
      Set<VirtualPoolProtectionVirtualArraySettingsParam> copies = Sets.newLinkedHashSet();
      for (RPCopyForm rpCopy : rpCopies) {
        if (rpCopy != null && rpCopy.isEnabled()) {
          copies.add(rpCopy.write());
        }
      }
      builder.setRecoverPointCopies(copies);
      // Set journal varray and vpool default for source
      builder.setJournalVarrayAndVpool(uri(sourceJournalVArray), uri(sourceJournalVPool));
    }

    if (ProtectionSystemTypes.isSRDF(remoteProtection)) {
      if (srdfCopies != null) {
        List<VirtualPoolRemoteProtectionVirtualArraySettingsParam> copies = Lists.newArrayList();
        for (SrdfCopyForm srdfCopyForm : srdfCopies) {
          if (srdfCopyForm != null && srdfCopyForm.isEnabled()) {
            copies.add(srdfCopyForm.write(srdfCopyMode));
          }
        }
        builder.setRemoteCopies(copies);
      }
    }

    if (HighAvailability.isHighAvailability(highAvailability)) {
      URI virtualArrayId = uri(haVirtualArray);
      URI virtualPoolId = uri(haVirtualPool);
      boolean activeProtectionAtHASite = BooleanUtils.isTrue(protectHASite);
      boolean metroPoint = false;
      if (BooleanUtils.isTrue(protectSourceSite) && BooleanUtils.isTrue(protectHASite)) {
        metroPoint = true;
        activeProtectionAtHASite =
            StringUtils.equalsIgnoreCase(activeSite, HighAvailability.VPLEX_HA);
        builder.setJournalVarrayAndVpool(uri(sourceJournalVArray), uri(sourceJournalVPool));
        builder.setStandByJournalVArrayVpool(uri(haJournalVArray), uri(haJournalVPool));
      } else {
        if (activeProtectionAtHASite) {
          builder.setJournalVarrayAndVpool(uri(haJournalVArray), uri(haJournalVPool));
        } else {
          builder.setJournalVarrayAndVpool(uri(sourceJournalVArray), uri(sourceJournalVPool));
        }
      }
      builder.setHighAvailability(
          highAvailability,
          enableAutoCrossConnExport,
          virtualArrayId,
          virtualPoolId,
          activeProtectionAtHASite,
          metroPoint);
    }
    return builder;
  }