Search in sources :

Example 6 with VirtualPool

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

the class ExportUtils method getBlockObjectVirtualPool.

/**
 * Get the Virtual Pool for a Block Object.
 *
 * @param blockObject
 * @param dbClient
 * @return VirtualPool or null if could not locate
 */
public static VirtualPool getBlockObjectVirtualPool(BlockObject blockObject, DbClient dbClient) {
    Volume volume = null;
    if (blockObject instanceof BlockSnapshot) {
        BlockSnapshot snapshot = (BlockSnapshot) blockObject;
        volume = dbClient.queryObject(Volume.class, snapshot.getParent());
    } else if (blockObject instanceof Volume) {
        volume = (Volume) blockObject;
    }
    if (volume != null) {
        VirtualPool vpool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        return vpool;
    }
    return null;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 7 with VirtualPool

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

the class VPlexUtil method getHAMirrorVpool.

/**
 * Convenience method to get HA MirrorVpool if it's set.
 *
 * @param sourceVirtualPool A Reference to VPLEX Volume source virtual pool
 * @param associatedVolumeIds Set of associated backend volumes for a VPLEX volume
 * @param dbClient an instance of {@link DbClient}
 *
 * @return returns HA mirror vpool if its set for the HA Vpool else returns null
 */
public static VirtualPool getHAMirrorVpool(VirtualPool sourceVirtualPool, StringSet associatedVolumeIds, DbClient dbClient) {
    VirtualPool haMirrorVpool = null;
    StringMap haVarrayVpoolMap = sourceVirtualPool.getHaVarrayVpoolMap();
    if (associatedVolumeIds.size() > 1 && haVarrayVpoolMap != null && !haVarrayVpoolMap.isEmpty()) {
        String haVarray = haVarrayVpoolMap.keySet().iterator().next();
        String haVpoolStr = haVarrayVpoolMap.get(haVarray);
        if (haVpoolStr != null && !(haVpoolStr.equals(NullColumnValueGetter.getNullURI().toString()))) {
            VirtualPool haVpool = dbClient.queryObject(VirtualPool.class, URI.create(haVpoolStr));
            if (haVpool.getMirrorVirtualPool() != null) {
                haMirrorVpool = dbClient.queryObject(VirtualPool.class, URI.create(haVpool.getMirrorVirtualPool()));
            }
        }
    }
    return haMirrorVpool;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 8 with VirtualPool

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

the class VPlexUtil method validateMirrorCountForVplexDistVolume.

/**
 * This method validates if the count requested by user to create
 * mirror(s) for a volume is valid.
 *
 * @param sourceVolume The reference to volume for which mirrors needs to be created
 * @param sourceVPool The reference to virtual pool to which volume is is associated
 * @param count The number of mirrors requested to be created
 * @param currentMirrorCount The current count of the mirror associated with the sourceVolume
 * @param requestedMirrorCount Represent currentMirrorCount + count
 * @param dbClient dbClient an instance of {@link DbClient}
 */
public static void validateMirrorCountForVplexDistVolume(Volume sourceVolume, VirtualPool sourceVPool, int count, int currentMirrorCount, int requestedMirrorCount, DbClient dbClient) {
    int sourceVpoolMaxCC = sourceVPool.getMaxNativeContinuousCopies() != null ? sourceVPool.getMaxNativeContinuousCopies() : 0;
    VirtualPool haVpool = VirtualPool.getHAVPool(sourceVPool, dbClient);
    int haVpoolMaxCC = 0;
    if (haVpool != null) {
        haVpoolMaxCC = haVpool.getMaxNativeContinuousCopies();
    }
    if ((currentMirrorCount > 0 && (sourceVpoolMaxCC + haVpoolMaxCC) < requestedMirrorCount) || (sourceVpoolMaxCC > 0 && sourceVpoolMaxCC < count) || (haVpoolMaxCC > 0 && haVpoolMaxCC < count)) {
        if (sourceVpoolMaxCC > 0 && haVpoolMaxCC > 0) {
            Integer currentSourceMirrorCount = getSourceOrHAContinuousCopyCount(sourceVolume, sourceVPool, dbClient);
            Integer currentHAMirrorCount = getSourceOrHAContinuousCopyCount(sourceVolume, haVpool, dbClient);
            throw APIException.badRequests.invalidParameterBlockMaximumCopiesForVolumeExceededForSourceAndHA(sourceVpoolMaxCC, haVpoolMaxCC, sourceVolume.getLabel(), sourceVPool.getLabel(), haVpool.getLabel(), currentSourceMirrorCount, currentHAMirrorCount);
        } else if (sourceVpoolMaxCC > 0 && haVpoolMaxCC == 0) {
            Integer currentSourceMirrorCount = getSourceOrHAContinuousCopyCount(sourceVolume, sourceVPool, dbClient);
            throw APIException.badRequests.invalidParameterBlockMaximumCopiesForVolumeExceededForSource(sourceVpoolMaxCC, sourceVolume.getLabel(), sourceVPool.getLabel(), currentSourceMirrorCount);
        } else if (sourceVpoolMaxCC == 0 && haVpoolMaxCC > 0) {
            Integer currentHAMirrorCount = getSourceOrHAContinuousCopyCount(sourceVolume, haVpool, dbClient);
            throw APIException.badRequests.invalidParameterBlockMaximumCopiesForVolumeExceededForHA(haVpoolMaxCC, sourceVolume.getLabel(), haVpool.getLabel(), currentHAMirrorCount);
        }
    }
}
Also used : VirtualPool(com.emc.storageos.db.client.model.VirtualPool) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 9 with VirtualPool

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

the class ControllerUtils method getVolumeURIHLUArray.

public static VolumeURIHLU[] getVolumeURIHLUArray(String storageType, Map<URI, Integer> volumeMap, DbClient dbClient) {
    // Have a non-null default value
    VolumeURIHLU[] volURIsHlus = EMPTY_VOLUME_URI_HLU_ARRAY;
    if (volumeMap != null && !volumeMap.keySet().isEmpty()) {
        boolean convertFromHex = storageType.equals(DiscoveredDataObject.Type.vmax.name());
        int entryCount = volumeMap.keySet().size();
        volURIsHlus = new VolumeURIHLU[entryCount];
        int index = 0;
        Map<URI, String> blockURIToLabelMap = new HashMap<URI, String>();
        Map<String, URI> nativeIdToURIMap = new HashMap<String, URI>();
        for (URI uri : volumeMap.keySet()) {
            BlockObject blockObject = BlockObject.fetch(dbClient, uri);
            Integer nativeId;
            String nativeIdString = blockObject.getNativeId();
            if (convertFromHex) {
                nativeId = Integer.parseInt(blockObject.getNativeId(), 16);
                nativeIdString = String.format("%04d", nativeId);
            } else if (!storageType.equals(DiscoveredDataObject.Type.vnxe.name()) && !storageType.equals(DiscoveredDataObject.Type.unity.name()) && blockObject.getNativeId().matches("\\d+")) {
                nativeId = Integer.parseInt(blockObject.getNativeId());
                nativeIdString = String.format("%04d", nativeId);
            }
            nativeIdToURIMap.put(nativeIdString, blockObject.getId());
            blockURIToLabelMap.put(blockObject.getId(), blockObject.getLabel());
        }
        Set<String> orderedByNativeId = new TreeSet<String>(nativeIdToURIMap.keySet());
        for (String nativeId : orderedByNativeId) {
            URI uri = nativeIdToURIMap.get(nativeId);
            Integer entryHLU = volumeMap.get(uri);
            String hluString = null;
            if (storageType.equals(DiscoveredDataObject.Type.unity.name())) {
                // Don't change to hex string for Unity
                hluString = (entryHLU != null) ? Integer.toString(entryHLU) : ExportGroup.LUN_UNASSIGNED_STR;
            } else {
                hluString = (entryHLU != null) ? Integer.toHexString(entryHLU) : ExportGroup.LUN_UNASSIGNED_STR;
            }
            String volLabel = blockURIToLabelMap.get(uri);
            if (storageType.equals(DiscoveredDataObject.Type.hds.name()) || storageType.equals(DiscoveredDataObject.Type.xtremio.name())) {
                // @TODO setting the policy name as null for now. We should handle when we support tiering.
                volURIsHlus[index++] = new VolumeURIHLU(uri, String.valueOf(entryHLU), null, volLabel);
            } else {
                String policyName = getAutoTieringPolicyName(uri, dbClient);
                VolumeURIHLU volumeURLHLU = new VolumeURIHLU(uri, hluString, policyName, volLabel);
                if (storageType.equals(DiscoveredDataObject.Type.vmax.name())) {
                    BlockObject blockObject = BlockObject.fetch(dbClient, uri);
                    if (blockObject instanceof Volume) {
                        Volume volume = (Volume) blockObject;
                        VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
                        volumeURLHLU = new VolumeURIHLU(uri, hluString, policyName, volLabel, virtualPool.getHostIOLimitBandwidth(), virtualPool.getHostIOLimitIOPs());
                        // Set the compression attribute as well
                        volumeURLHLU.setCompression(virtualPool.getCompressionEnabled());
                    }
                }
                volURIsHlus[index++] = volumeURLHLU;
            }
        }
        s_logger.info(String.format("getVolumeURIHLUArray = %s", Joiner.on(',').join(volURIsHlus)));
    }
    return volURIsHlus;
}
Also used : HashMap(java.util.HashMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) BigInteger(java.math.BigInteger) Volume(com.emc.storageos.db.client.model.Volume) TreeSet(java.util.TreeSet) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 10 with VirtualPool

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

the class FileDeviceController method createFS.

@Override
public void createFS(URI storage, URI pool, URI fs, String nativeId, String opId) throws ControllerException {
    FileObject fileObject = null;
    FileShare fsObj = null;
    StorageSystem storageObj = null;
    try {
        ControllerUtils.setThreadLocalLogData(fs, opId);
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        String[] params = { storage.toString(), pool.toString(), fs.toString() };
        _log.info("Create FS: {}, {}, {}", params);
        StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
        fsObj = _dbClient.queryObject(FileShare.class, fs);
        VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, fsObj.getVirtualPool());
        fileObject = fsObj;
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        args.addFileShare(fsObj);
        args.addStoragePool(poolObj);
        args.setVPool(vPool);
        args.setNativeDeviceFsId(nativeId);
        args.setOpId(opId);
        Project proj = _dbClient.queryObject(Project.class, fsObj.getProject());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, fsObj.getTenant());
        setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
        args.setTenantOrg(tenant);
        args.setProject(proj);
        // work flow and we need to add TaskCompleter(TBD for vnxfile)
        WorkflowStepCompleter.stepExecuting(opId);
        acquireStepLock(storageObj, opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateFS(storageObj, args);
        if (!result.getCommandPending()) {
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        } else {
            // we need to add task completer
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        }
        if (result.isCommandSuccess()) {
            fsObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, fsObj));
            fsObj.setInactive(false);
            WorkflowStepCompleter.stepSucceded(opId);
        } else if (!result.getCommandPending()) {
            fsObj.setInactive(true);
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        _dbClient.updateObject(fsObj);
        if (!result.getCommandPending()) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, result.isCommandSuccess(), "", "", fsObj);
        }
    } catch (Exception e) {
        String[] params = { storage.toString(), pool.toString(), fs.toString(), e.getMessage() };
        _log.error("Unable to create file system: storage {}, pool {}, FS {}: {}", params);
        // work flow fail
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        if ((fsObj != null) && (storageObj != null)) {
            fsObj.setInactive(true);
            _dbClient.updateObject(fsObj);
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, false, e.getMessage(), "", fsObj, storageObj);
        }
        updateTaskStatus(opId, fileObject, e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VirtualPool (com.emc.storageos.db.client.model.VirtualPool)339 URI (java.net.URI)189 ArrayList (java.util.ArrayList)122 Volume (com.emc.storageos.db.client.model.Volume)103 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)92 NamedURI (com.emc.storageos.db.client.model.NamedURI)88 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)88 StringSet (com.emc.storageos.db.client.model.StringSet)76 Project (com.emc.storageos.db.client.model.Project)65 StoragePool (com.emc.storageos.db.client.model.StoragePool)57 StringMap (com.emc.storageos.db.client.model.StringMap)53 HashMap (java.util.HashMap)52 Produces (javax.ws.rs.Produces)50 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)45 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)44 List (java.util.List)44 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)42 Path (javax.ws.rs.Path)42 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)37 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)37