Search in sources :

Example 56 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class VPlexXIVMaskingOrchestrator method deleteOrRemoveVolumesFromExportMask.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.impl.block.
     * VplexBackEndMaskingOrchestrator#deleteOrRemoveVolumesFromExportMask(java.net.URI,
     * java.net.URI, java.net.URI, java.util.List,
     * java.lang.String)
     */
@Override
public void deleteOrRemoveVolumesFromExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumes, List<URI> initiatorURIs, String stepId) {
    ExportTaskCompleter completer = null;
    try {
        completer = new ExportMaskOnlyRemoveVolumeCompleter(exportGroupURI, exportMaskURI, volumes, stepId);
        WorkflowStepCompleter.stepExecuting(stepId);
        StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
        BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        // If the exportMask isn't found, or has been deleted, nothing to do.
        if (exportMask == null || exportMask.getInactive()) {
            _log.info(String.format("ExportMask %s inactive, returning success", exportMaskURI));
            completer.ready(_dbClient);
            return;
        }
        // Protect concurrent operations by locking {host, array} duple.
        // Lock will be released when work-flow step completes.
        List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
        getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
        // Refresh the ExportMask
        if (exportMask.getNativeId() != null) {
            exportMask = refreshExportMask(array, device, exportMask);
        }
        // Determine if we're deleting the last volume in the mask.
        StringMap maskVolumesMap = exportMask.getVolumes();
        Set<String> remainingVolumes = new HashSet<String>();
        List<URI> passedVolumesInMask = new ArrayList<>(volumes);
        if (maskVolumesMap != null) {
            remainingVolumes.addAll(maskVolumesMap.keySet());
        }
        for (URI volume : volumes) {
            remainingVolumes.remove(volume.toString());
            // are not in the mask to handle this condition.
            if ((maskVolumesMap != null) && (!maskVolumesMap.keySet().contains(volume.toString()))) {
                passedVolumesInMask.remove(volume);
            }
        }
        // None of the volumes is in the export mask, so we are done.
        if (passedVolumesInMask.isEmpty()) {
            _log.info("None of these volumes {} are in export mask {}", volumes, exportMask.forDisplay());
            completer.ready(_dbClient);
            return;
        }
        // If it is last volume and there are no existing volumes, delete the ExportMask.
        if (remainingVolumes.isEmpty() && !exportMask.hasAnyExistingVolumes()) {
            device.doExportDelete(array, exportMask, passedVolumesInMask, initiatorURIs, completer);
        } else {
            List<Initiator> initiators = null;
            if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
                initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
            }
            device.doExportRemoveVolumes(array, exportMask, passedVolumesInMask, initiators, completer);
        }
        completer.ready(_dbClient);
    } catch (Exception ex) {
        _log.error("Failed to delete or remove volumes to export mask for XIV: ", ex);
        VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForDeleteVolumesFailed(ex);
        completer.error(_dbClient, vplexex);
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ExportMaskOnlyRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 57 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class RecoverPointScheduler method initializeSwapContainer.

/**
 * This function will swap src and ha varrays and src and ha vpools IF
 * the src vpool has specified this.
 *
 * @param srcVarray Source varray
 * @param srcVpool Source vpool
 * @param haVarray HA varray
 * @param haVpool HA vpool
 * @param dbClient DB Client reference
 */
public static SwapContainer initializeSwapContainer(SwapContainer container, DbClient dbClient) {
    // Refresh vpools in case previous activities have changed their temporal representation.
    VirtualArray srcVarray = container.getSrcVarray();
    VirtualPool srcVpool = dbClient.queryObject(VirtualPool.class, container.getSrcVpool().getId());
    VirtualArray haVarray = container.getHaVarray();
    VirtualPool haVpool = container.getHaVpool();
    // as the RP Source.
    if (VirtualPool.isRPVPlexProtectHASide(srcVpool)) {
        // Get the HA Varray connected to RP
        haVarray = dbClient.queryObject(VirtualArray.class, URI.create(srcVpool.getHaVarrayConnectedToRp()));
        _log.info(String.format("Source Vpool[%s] indicates that we should use HA Varray[%s] as RP Source.", srcVpool.getLabel(), haVarray.getLabel()));
        String haVpoolId = srcVpool.getHaVarrayVpoolMap().get(srcVpool.getHaVarrayConnectedToRp());
        if (haVpoolId != null && !haVpoolId.isEmpty() && !haVpoolId.equals(NullColumnValueGetter.getNullStr())) {
            haVpool = dbClient.queryObject(VirtualPool.class, URI.create(haVpoolId));
            _log.info(String.format("HA Vpool has been defined [%s]", haVpool.getLabel()));
            // Temporarily inherit the HA and Protection Settings/RP specific info from Source Vpool.
            // These modifications will not be persisted to the db.
            haVpool.setProtectionVarraySettings(srcVpool.getProtectionVarraySettings());
            haVpool.setRpCopyMode(srcVpool.getRpCopyMode());
            haVpool.setRpRpoType(srcVpool.getRpRpoType());
            haVpool.setRpRpoValue(srcVpool.getRpRpoValue());
            haVpool.setMultivolumeConsistency(srcVpool.getMultivolumeConsistency());
            haVpool.setHighAvailability(srcVpool.getHighAvailability());
            haVpool.setMetroPoint(srcVpool.getMetroPoint());
            haVpool.setHaVarrayConnectedToRp(srcVarray.getId().toString());
            haVpool.setJournalSize(NullColumnValueGetter.isNotNullValue(srcVpool.getJournalSize()) ? srcVpool.getJournalSize() : null);
        } else {
            _log.info(String.format("HA Vpool has not been defined, using Source Vpool[%s].", srcVpool.getLabel()));
            // Use source vpool. That means the source vpool will have to have the HA varray
            // added to it, otherwise this will not work. That is done during vpool create via the UI
            // by the user.
            // This is the same behaviour as VPLEX. So we're just reusing that behaviour.
            // If not done, placement will fail.
            haVpool = srcVpool;
        }
        // Ensure that we define the haVarrayVpoolMap on the haVpool to use srcVarray and srcVpool.
        StringMap haVarrayVpoolMap = new StringMap();
        haVarrayVpoolMap.put(srcVarray.getId().toString(), srcVpool.getId().toString());
        haVpool.setHaVarrayVpoolMap(haVarrayVpoolMap);
        _log.info(String.format("HA Varray[%s] and HA Vpool[%s] will be used as Source Varray and Source Vpool.", haVarray.getLabel(), haVpool.getLabel()));
        _log.info(String.format("Source Varray[%s] and Source Vpool[%s] will be used as HA Varray and HA Vpool.", srcVarray.getLabel(), srcVpool.getLabel()));
        // Now HA becomes Source and Source becomes HA.
        VirtualArray tempVarray = srcVarray;
        VirtualPool tempVpool = srcVpool;
        container.setSrcVarray(haVarray);
        container.setSrcVpool(haVpool);
        container.setHaVarray(tempVarray);
        container.setHaVpool(tempVpool);
    }
    return container;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 58 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class RecoverPointScheduler method fireProtectionPlacementRules.

/**
 * Executes a set of business rules against the <code>List</code> of <code>ProtectionPoolMapping</code> objects to determine if they are
 * capable to perform
 * volume protection. The statistics are pulled from the <code>ProtectionSystem</code> and are used in executing the following business
 * rules:
 * <p>
 * <ul>
 * <li>The RP cluster (ProtectionSystem) must have the capacity to create a single CG.</li>
 * <li>Each RP site must have the volume capacity to create the required number of volumes.</li>
 * </ul>
 *
 * @param protectionSystem
 * @param rpRec
 * @param resourceCount number of volumes being requested for creation/protection
 * @return true if recommendation can be handled by protection system
 */
private boolean fireProtectionPlacementRules(ProtectionSystem protectionSystem, RPProtectionRecommendation rpRec, Integer resourceCount) {
    // Log messages used within this method - Use String.format()
    final String cgCountLog = "CG count for Protection System %s is %s/%s";
    final String cgNoCapacityLog = "Protection System %s does not have the CG capacity to protect volumes.";
    final String sourceSiteVolumeCountLog = "Volume count for Protection System %s/site %s (source) is %s/%s";
    final String destSiteVolumeCountLog = "Volume count for Protection System %s/site %s (destination) is %s/%s";
    final String sourceSiteVolumeNoCapacityLog = "Protection System %s/site %s (source) does not have the volume capacity to protect volumes. " + "Requires capacity for %s volume(s).";
    final String destSiteVolumeNoCapacityLog = "Protection System %s/site %s (destination) does not have the volume capacity to protect volumes. " + "Requires capacity for %s volume(s).";
    final String parseSiteStatsLog = "A problem occurred parsing site volume statistics for Protection System %s.  " + "Protection system is unable to protect volumes: %s";
    final String missingProtectionSystemMetric = "RecoverPoint metric '%s' for Protection System %s cannot be found. " + "Unable to determine if the protection system is capable of protection volumes.";
    final String missingSiteMetric = "RecoverPoint metric '%s' for Protection System %s/Site %s cannot be found. Unable " + "to determine if the protection system is capable of protection volumes.";
    final String validProtectionSystem = "RecoverPoint Protection System '%s' is capable of protecting the requested volumes.";
    final String inValidProtectionSystem = "RecoverPoint Protection System '%s' is not capable of protecting the requested volumes.";
    final String validatingProtection = "Validating protection systems to ensure they are capable of handling a protection for %s" + " production volume(s).";
    _log.info(String.format(validatingProtection, resourceCount));
    boolean isValid = true;
    Long rpCGCapacity = protectionSystem.getCgCapacity();
    Long rpCurrentCGCount = protectionSystem.getCgCount();
    if (rpCGCapacity == null) {
        _log.warn(String.format(missingProtectionSystemMetric, "CG Capacity", protectionSystem));
        rpCGCapacity = -1L;
    }
    if (rpCurrentCGCount == null) {
        _log.warn(String.format(missingProtectionSystemMetric, "CG Count", protectionSystem));
        rpCurrentCGCount = -1L;
    }
    long rpAvailableCGCapacity = rpCGCapacity - rpCurrentCGCount;
    // Log the CG count.
    _log.info(String.format(cgCountLog, protectionSystem.getLabel(), rpCurrentCGCount, rpCGCapacity));
    // Is there enough CG capacity on the RP cluster?
    if (rpAvailableCGCapacity < 1) {
        isValid = false;
        _log.info(String.format(cgNoCapacityLog, protectionSystem));
        rpRec.setProtectionSystemCriteriaError(String.format(cgNoCapacityLog, protectionSystem));
    }
    // Only process the site statistics if the Protection System statistics
    // are adequate for protection.
    StringMap siteVolumeCapacity = protectionSystem.getSiteVolumeCapacity();
    StringMap siteVolumeCount = protectionSystem.getSiteVolumeCount();
    List<RPRecommendation> sourceRecommendation = rpRec.getSourceRecommendations();
    String sourceInternalSiteName = sourceRecommendation.iterator().next().getInternalSiteName();
    if (siteVolumeCount != null && siteVolumeCount.size() > 0) {
        String sourceSiteVolumeCount = siteVolumeCount.get(String.valueOf(sourceInternalSiteName));
        String sourceSiteVolumeCapacity = siteVolumeCapacity.get(String.valueOf(sourceInternalSiteName));
        if (sourceSiteVolumeCount == null) {
            _log.warn(String.format(missingSiteMetric, "Source Site Volume Count", protectionSystem, rpRec.getResourceCount()));
            sourceSiteVolumeCount = "-1";
        }
        if (sourceSiteVolumeCapacity == null) {
            _log.warn(String.format(missingSiteMetric, "Source Site Volume Capacity", protectionSystem, sourceInternalSiteName));
            sourceSiteVolumeCapacity = "-1";
        }
        try {
            // Get the source site available capacity.
            long sourceSiteAvailableVolCapacity = Long.parseLong(sourceSiteVolumeCapacity) - Long.parseLong(sourceSiteVolumeCount);
            _log.debug(String.format(sourceSiteVolumeCountLog, protectionSystem, sourceInternalSiteName, sourceSiteVolumeCount, sourceSiteVolumeCapacity));
            // If the source site available capacity is not adequate, log a message.
            if (sourceSiteAvailableVolCapacity < rpRec.getNumberOfVolumes(sourceInternalSiteName)) {
                isValid = false;
                _log.info(String.format(sourceSiteVolumeNoCapacityLog, protectionSystem, sourceInternalSiteName, resourceCount));
                rpRec.setProtectionSystemCriteriaError(String.format(sourceSiteVolumeNoCapacityLog, protectionSystem, sourceInternalSiteName, resourceCount));
            }
        } catch (NumberFormatException nfe) {
            // Catch any exceptions that occur while parsing the site specific values
            isValid = false;
            _log.info(String.format(parseSiteStatsLog, protectionSystem, nfe.getMessage()));
            rpRec.setProtectionSystemCriteriaError(String.format(parseSiteStatsLog, protectionSystem, nfe.getMessage()));
        }
        for (RPRecommendation sourceRec : rpRec.getSourceRecommendations()) {
            for (RPRecommendation targetRec : sourceRec.getTargetRecommendations()) {
                String internalSiteName = targetRec.getInternalSiteName();
                String destSiteVolumeCount = siteVolumeCount.get(String.valueOf(internalSiteName));
                String destSiteVolumeCapacity = siteVolumeCapacity.get(String.valueOf(internalSiteName));
                if (destSiteVolumeCount == null) {
                    _log.warn(String.format(missingSiteMetric, "Destination Site Volume Count", protectionSystem, internalSiteName));
                    destSiteVolumeCount = "-1";
                }
                if (destSiteVolumeCapacity == null) {
                    _log.warn(String.format(missingSiteMetric, "Destination Site Volume Capacity", protectionSystem, internalSiteName));
                    destSiteVolumeCapacity = "-1";
                }
                try {
                    // Get the destination site available capacity.
                    long destSiteAvailableVolCapacity = Long.parseLong(destSiteVolumeCapacity) - Long.parseLong(destSiteVolumeCount);
                    _log.debug(String.format(destSiteVolumeCountLog, protectionSystem, internalSiteName, destSiteVolumeCount, destSiteVolumeCapacity));
                    // If the destination site available capacity is not adequate, log a message.
                    if (destSiteAvailableVolCapacity < rpRec.getNumberOfVolumes(targetRec.getInternalSiteName())) {
                        isValid = false;
                        _log.info(String.format(destSiteVolumeNoCapacityLog, protectionSystem, internalSiteName, rpRec.getResourceCount()));
                        rpRec.setProtectionSystemCriteriaError(String.format(destSiteVolumeNoCapacityLog, protectionSystem, internalSiteName, rpRec.getResourceCount()));
                    }
                } catch (NumberFormatException nfe) {
                    // Catch any exceptions that occur while parsing the site specific values
                    isValid = false;
                    _log.info(String.format(parseSiteStatsLog, protectionSystem, nfe.getMessage()));
                    rpRec.setProtectionSystemCriteriaError(String.format(parseSiteStatsLog, protectionSystem, nfe.getMessage()));
                }
            }
        }
    } else {
        // There are no site volume statistics available so assume volume
        // protection cannot be achieved.
        isValid = false;
        _log.warn(String.format(missingProtectionSystemMetric, "Site Volume Capacity/Count", protectionSystem));
        rpRec.setProtectionSystemCriteriaError(String.format(missingProtectionSystemMetric, "Site Volume Capacity/Count", protectionSystem));
    }
    // log a message is the protection system is valid.
    if (isValid) {
        _log.debug(String.format(validProtectionSystem, protectionSystem));
    } else {
        _log.debug(String.format(inValidProtectionSystem, protectionSystem));
    }
    return isValid;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation)

Example 59 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class ExportGroupService method getVolumes.

// This was originally in the ExportGroupRestRep
private Map<String, Integer> getVolumes(ExportGroup exportGroup) {
    Map<String, Integer> volumesMap = new HashMap<String, Integer>();
    StringMap volumes = exportGroup.getVolumes();
    for (ExportMask exportMask : ExportMaskUtils.getExportMasks(_dbClient, exportGroup)) {
        try {
            if (exportMask != null && exportMask.getVolumes() != null) {
                for (Map.Entry<String, String> entry : exportMask.getVolumes().entrySet()) {
                    if (!volumesMap.containsKey(entry.getKey()) && (entry.getValue() != null)) {
                        // ensure that this volume is referenced by this export group
                        if (volumes != null && volumes.containsKey(entry.getKey())) {
                            volumesMap.put(entry.getKey(), Integer.valueOf(entry.getValue()));
                        }
                    }
                }
            }
        } catch (Exception e) {
            _log.error("Error getting volumes for export group {}", exportGroup.getId(), e);
        }
    }
    /*
         * Now include any volumes that might be a part of the Export Group
         * but not of the Export Mask.
         */
    if (volumes != null) {
        for (Map.Entry<String, String> entry : volumes.entrySet()) {
            if (!volumesMap.containsKey(entry.getKey()) && (entry.getValue() != null)) {
                volumesMap.put(entry.getKey(), Integer.valueOf(entry.getValue()));
            }
        }
    }
    return volumesMap;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) PlacementException(com.emc.storageos.volumecontroller.placement.PlacementException)

Example 60 with StringMap

use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.

the class DbObjectMapper method map.

public static CustomConfigRestRep map(CustomConfig from) {
    if (from == null) {
        return null;
    }
    CustomConfigRestRep to = new CustomConfigRestRep();
    to.setLink(new RestLinkRep("self", RestLinkFactory.newLink(from)));
    // build the config type Link
    String service = ResourceTypeEnum.CONFIG_TYPE.getService();
    StringBuilder build = (new StringBuilder(service)).append('/').append(from.getConfigType());
    try {
        RelatedConfigTypeRep type = new RelatedConfigTypeRep();
        type.setConfigName(from.getConfigType());
        type.setSelfLink(new RestLinkRep("self", new URI(build.toString())));
        to.setConfigType(type);
    } catch (URISyntaxException e) {
    // it should not happen
    }
    to.setId(from.getId());
    to.setName(from.getLabel());
    StringMap scopeMap = from.getScope();
    ScopeParam scopeParm = new ScopeParam();
    for (Map.Entry<String, String> entry : scopeMap.entrySet()) {
        scopeParm.setType(entry.getKey());
        scopeParm.setValue(entry.getValue());
    }
    to.setScope(scopeParm);
    to.setValue(from.getValue());
    to.setRegistered(from.getRegistered());
    to.setSystemDefault(from.getSystemDefault());
    return to;
}
Also used : RelatedConfigTypeRep(com.emc.storageos.model.customconfig.RelatedConfigTypeRep) StringMap(com.emc.storageos.db.client.model.StringMap) CustomConfigRestRep(com.emc.storageos.model.customconfig.CustomConfigRestRep) RestLinkRep(com.emc.storageos.model.RestLinkRep) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) URISyntaxException(java.net.URISyntaxException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap)

Aggregations

StringMap (com.emc.storageos.db.client.model.StringMap)257 URI (java.net.URI)108 ArrayList (java.util.ArrayList)90 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)59 StringSet (com.emc.storageos.db.client.model.StringSet)57 HashMap (java.util.HashMap)57 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)48 ExportMask (com.emc.storageos.db.client.model.ExportMask)43 Volume (com.emc.storageos.db.client.model.Volume)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)41 StoragePool (com.emc.storageos.db.client.model.StoragePool)39 Initiator (com.emc.storageos.db.client.model.Initiator)38 List (java.util.List)34 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)33 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)31 HashSet (java.util.HashSet)30 Project (com.emc.storageos.db.client.model.Project)24 StoragePort (com.emc.storageos.db.client.model.StoragePort)23 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 Network (com.emc.storageos.db.client.model.Network)21