Search in sources :

Example 16 with VirtualArray

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

the class AbstractBlockServiceApiImpl method getVirtualArrayConnectivity.

/**
 * Determines the Virtual Storage Array Connectivity of the given Virtual Storage Array
 *
 * @param dbClient
 *            - Static method needs DbClient
 * @param varrayUID
 *            - UID of the varray to find the connectivity for
 * @return A Set of VirtualArrayConnectivityRestRep
 */
public static Set<VirtualArrayConnectivityRestRep> getVirtualArrayConnectivity(DbClient dbClient, URI varrayUID) {
    Set<VirtualArrayConnectivityRestRep> varrayConnectivity = new HashSet<VirtualArrayConnectivityRestRep>();
    for (String key : getProtectionImplementations().keySet()) {
        Set<URI> varrays = getProtectionImplementations().get(key).getConnectedVarrays(varrayUID);
        Iterator<URI> it = varrays.iterator();
        while (it.hasNext()) {
            URI currentVirtualArrayUID = it.next();
            VirtualArray varray = dbClient.queryObject(VirtualArray.class, currentVirtualArrayUID);
            if (varray != null) {
                VirtualArrayConnectivityRestRep connection = new VirtualArrayConnectivityRestRep();
                connection.setVirtualArray(toNamedRelatedResource(ResourceTypeEnum.VARRAY, varray.getId(), varray.getLabel()));
                StringSet connectivity = new StringSet();
                connectivity.add(key);
                connection.setConnectionType(connectivity);
                varrayConnectivity.add(connection);
            }
        }
    }
    return varrayConnectivity;
}
Also used : VirtualArrayConnectivityRestRep(com.emc.storageos.model.varray.VirtualArrayConnectivityRestRep) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) HashSet(java.util.HashSet)

Example 17 with VirtualArray

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

the class BlockConsistencyGroupService method performProtectionAction.

/**
 * Since all of the protection operations are very similar, this method does all of the work.
 * We keep the actual REST methods separate mostly for the purpose of documentation generators.
 *
 * @param consistencyGroupId the URI of the BlockConsistencyGroup to perform the protection action against.
 * @param targetVarrayId the target virtual array.
 * @param pointInTime any point in time, specified in UTC.
 *            Allowed values: "yyyy-MM-dd_HH:mm:ss" formatted date or datetime in milliseconds.
 * @param op operation to perform (pause, stop, failover, etc)
 * @return task resource rep
 * @throws InternalException
 */
private TaskResourceRep performProtectionAction(URI consistencyGroupId, Copy copy, String op) throws InternalException {
    ArgValidator.checkFieldUriType(consistencyGroupId, BlockConsistencyGroup.class, "id");
    ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
    // Get the BlockConsistencyGroup and target VirtualArray associated with the request.
    final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
    final VirtualArray targetVirtualArray = _permissionsHelper.getObjectById(copy.getCopyID(), VirtualArray.class);
    ArgValidator.checkEntity(consistencyGroup, consistencyGroupId, true);
    ArgValidator.checkEntity(targetVirtualArray, copy.getCopyID(), true);
    // The consistency group needs to be associated with RecoverPoint in order to perform the operation.
    if (!consistencyGroup.checkForType(Types.RP)) {
        // Attempt to do protection link management on unprotected CG
        throw APIException.badRequests.consistencyGroupMustBeRPProtected(consistencyGroupId);
    }
    if (op.equalsIgnoreCase(ProtectionOp.SWAP.getRestOp()) && !NullColumnValueGetter.isNullURI(consistencyGroupId)) {
        ExportUtils.validateConsistencyGroupBookmarksExported(_dbClient, consistencyGroupId);
    }
    // Catch any attempts to use an invalid access mode
    if (op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) && !Copy.ImageAccessMode.DIRECT_ACCESS.name().equalsIgnoreCase(copy.getAccessMode())) {
        throw APIException.badRequests.unsupportedAccessMode(copy.getAccessMode());
    }
    // Verify that the supplied target Virtual Array is being referenced by at least one target volume in the CG.
    List<Volume> targetVolumes = getTargetVolumes(consistencyGroup, copy.getCopyID());
    if (targetVolumes == null || targetVolumes.isEmpty()) {
        // The supplied target varray is not referenced by any target volumes in the CG.
        throw APIException.badRequests.targetVirtualArrayDoesNotMatch(consistencyGroupId, copy.getCopyID());
    }
    // Get the first target volume
    Volume targetVolume = targetVolumes.get(0);
    String task = UUID.randomUUID().toString();
    Operation status = new Operation();
    status.setResourceType(ProtectionOp.getResourceOperationTypeEnum(op));
    _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroupId, task, status);
    ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, targetVolume.getProtectionController());
    String deviceType = system.getSystemType();
    if (!deviceType.equals(DiscoveredDataObject.Type.rp.name())) {
        throw APIException.badRequests.protectionForRpClusters();
    }
    RPController controller = getController(RPController.class, system.getSystemType());
    controller.performProtectionOperation(system.getId(), consistencyGroupId, targetVolume.getId(), copy.getPointInTime(), copy.getAccessMode(), op, task);
    /*
         * auditOp(OperationTypeEnum.PERFORM_PROTECTION_ACTION, true, AuditLogManager.AUDITOP_BEGIN,
         * op, copyID.toString(), id.toString(), system.getId().toString());
         */
    return toTask(consistencyGroup, task, status);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) Operation(com.emc.storageos.db.client.model.Operation) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 18 with VirtualArray

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

the class BlockService method getVolumesForVirtualArrayChange.

/**
 * Get Volumes For Virtual Array Change
 *
 * @param projectURI
 * 			the URI of a ViPR project
 *
 * @param varrayURI
 * 			the URI of a ViPR vArray
 *
 * @brief Show potential volumes for virtual array change
 *
 * @return Get Volume for Virtual Array Change
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/varray-change")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public NamedVolumesList getVolumesForVirtualArrayChange(@QueryParam("project") URI projectURI, @QueryParam("targetVarray") URI varrayURI) {
    NamedVolumesList volumeList = new NamedVolumesList();
    // Get the project.
    ArgValidator.checkFieldUriType(projectURI, Project.class, "project");
    Project project = _permissionsHelper.getObjectById(projectURI, Project.class);
    ArgValidator.checkEntity(project, projectURI, false);
    _log.info("Found project {}:{}", projectURI);
    // Verify the user is authorized for the project.
    BlockServiceUtils.verifyUserIsAuthorizedForRequest(project, getUserFromContext(), _permissionsHelper);
    _log.info("User is authorized for project");
    // Get the target virtual array.
    ArgValidator.checkFieldUriType(varrayURI, VirtualArray.class, "targetVarray");
    VirtualArray tgtVarray = _permissionsHelper.getObjectById(varrayURI, VirtualArray.class);
    ArgValidator.checkEntity(tgtVarray, varrayURI, false);
    _log.info("Found target virtual array {}:{}", tgtVarray.getLabel(), varrayURI);
    // Determine all volumes in the project that could potentially
    // be moved to the target virtual array.
    URIQueryResultList volumeIds = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getProjectVolumeConstraint(projectURI), volumeIds);
    Iterator<Volume> volumeItr = _dbClient.queryIterativeObjects(Volume.class, volumeIds);
    while (volumeItr.hasNext()) {
        Volume volume = volumeItr.next();
        try {
            // Don't operate on VPLEX backend, RP Journal volumes,
            // or other internal volumes.
            BlockServiceUtils.validateNotAnInternalBlockObject(volume, false);
            // Don't operate on ingested volumes.
            VolumeIngestionUtil.checkOperationSupportedOnIngestedVolume(volume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VARRAY, _dbClient);
            // Can't change to the same varray.
            if (volume.getVirtualArray().equals(varrayURI)) {
                _log.info("Virtual array change not supported for volume {} already in the target varray", volume.getId());
                continue;
            }
            // Get the appropriate block service implementation.
            BlockServiceApi blockServiceAPI = getBlockServiceImpl(volume);
            // Verify that the virtual array change is allowed for the
            // volume and target virtual array.
            blockServiceAPI.verifyVarrayChangeSupportedForVolumeAndVarray(volume, tgtVarray);
            // If so, add it to the list.
            volumeList.getVolumes().add(toNamedRelatedResource(volume));
        } catch (Exception e) {
            _log.info("Virtual array change not supported for volume {}:{}", volume.getId(), e.getMessage());
        }
    }
    return volumeList;
}
Also used : Project(com.emc.storageos.db.client.model.Project) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) SOURCE_TO_TARGET(com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 19 with VirtualArray

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

the class BlockVirtualPoolService method updateRemoteCopyVPool.

private void updateRemoteCopyVPool(VirtualPool virtualPool, BlockVirtualPoolProtectionUpdateParam param) {
    if (param.getRemoteCopies() != null) {
        StringMap remoteCopySettingsMap = virtualPool.getProtectionRemoteCopySettings();
        if (remoteCopySettingsMap == null) {
            remoteCopySettingsMap = new StringMap();
            virtualPool.setProtectionRemoteCopySettings(remoteCopySettingsMap);
        }
        // and an add, which is buggy in the StringMap.
        if (param.getRemoteCopies().getRemove() != null && !param.getRemoteCopies().getRemove().isEmpty() && param.getRemoteCopies().getAdd() != null && !param.getRemoteCopies().getAdd().isEmpty()) {
            Iterator<VirtualPoolRemoteProtectionVirtualArraySettingsParam> removeRemoteCopies = param.getRemoteCopies().getRemove().iterator();
            Iterator<VirtualPoolRemoteProtectionVirtualArraySettingsParam> addRemoteCopies = param.getRemoteCopies().getAdd().iterator();
            while (removeRemoteCopies.hasNext()) {
                VirtualPoolRemoteProtectionVirtualArraySettingsParam removeRemoteCopySettingsParam = removeRemoteCopies.next();
                while (addRemoteCopies.hasNext()) {
                    VirtualPoolRemoteProtectionVirtualArraySettingsParam addRemoteCopySettingsParam = addRemoteCopies.next();
                    // remote copy setting from the add/remove lists so they do not get processed individually.
                    if (removeRemoteCopySettingsParam.getVarray().toString().equals(addRemoteCopySettingsParam.getVarray().toString())) {
                        String remoteCopySettingsUri = remoteCopySettingsMap.get(addRemoteCopySettingsParam.getVarray().toString());
                        VpoolRemoteCopyProtectionSettings remoteSettingsObj = _dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, URI.create(remoteCopySettingsUri));
                        if (remoteSettingsObj != null) {
                            remoteSettingsObj.setVirtualPool(addRemoteCopySettingsParam.getVpool());
                            if (null != addRemoteCopySettingsParam.getRemoteCopyMode()) {
                                if (!CopyModes.lookup(addRemoteCopySettingsParam.getRemoteCopyMode())) {
                                    throw APIException.badRequests.invalidCopyMode(addRemoteCopySettingsParam.getRemoteCopyMode());
                                }
                                remoteSettingsObj.setCopyMode(addRemoteCopySettingsParam.getRemoteCopyMode());
                            }
                            _dbClient.persistObject(remoteSettingsObj);
                            // Only remove from the add list if the remote copy setting actually
                            // exists. We will still want to add it if it does not exist.
                            param.getRemoteCopies().getAdd().remove(addRemoteCopySettingsParam);
                        }
                        // Always remove the remote copy setting from the remove list
                        param.getRemoteCopies().getRemove().remove(removeRemoteCopySettingsParam);
                    }
                }
            }
        }
        if (param.getRemoteCopies().getRemove() != null && !param.getRemoteCopies().getRemove().isEmpty()) {
            for (VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteSettings : param.getRemoteCopies().getRemove()) {
                if (remoteSettings.getVarray() != null && remoteCopySettingsMap.containsKey(remoteSettings.getVarray().toString())) {
                    String remoteCopySettingsUri = remoteCopySettingsMap.get(remoteSettings.getVarray().toString());
                    remoteCopySettingsMap.remove(remoteSettings.getVarray().toString());
                    VpoolRemoteCopyProtectionSettings remoteSettingsObj = _dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, URI.create(remoteCopySettingsUri));
                    remoteSettingsObj.setInactive(true);
                    _dbClient.persistObject(remoteSettingsObj);
                }
            }
        }
        if (param.getRemoteCopies().getAdd() != null && !param.getRemoteCopies().getAdd().isEmpty()) {
            List<VpoolRemoteCopyProtectionSettings> remoteSettingsList = new ArrayList<VpoolRemoteCopyProtectionSettings>();
            // already existing remote VArrays
            List<String> existingRemoteUris = new ArrayList<String>(remoteCopySettingsMap.keySet());
            for (VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteSettings : param.getRemoteCopies().getAdd()) {
                // CTRL-275 fix
                VirtualArray remoteVArray = _dbClient.queryObject(VirtualArray.class, remoteSettings.getVarray());
                if (null == remoteVArray || remoteVArray.getInactive()) {
                    throw APIException.badRequests.inactiveRemoteVArrayDetected(remoteSettings.getVarray());
                }
                VpoolRemoteCopyProtectionSettings remoteCopySettingsParam = new VpoolRemoteCopyProtectionSettings();
                remoteSettingsList.add(remoteCopySettingsParam);
                remoteCopySettingsParam.setId(URIUtil.createId(VpoolRemoteCopyProtectionSettings.class));
                remoteCopySettingsParam.setVirtualArray(remoteSettings.getVarray());
                if (existingRemoteUris.contains(remoteSettings.getVarray().toString()) || remoteCopySettingsMap.containsKey(remoteSettings.getVarray().toString())) {
                    throw APIException.badRequests.duplicateRemoteSettingsDetected(remoteSettings.getVarray());
                }
                remoteCopySettingsMap.put(remoteSettings.getVarray().toString(), remoteCopySettingsParam.getId().toString());
                remoteCopySettingsParam.setVirtualPool(remoteSettings.getVpool());
                if (null != remoteSettings.getRemoteCopyMode()) {
                    if (!CopyModes.lookup(remoteSettings.getRemoteCopyMode())) {
                        throw APIException.badRequests.invalidCopyMode(remoteSettings.getRemoteCopyMode());
                    }
                    remoteCopySettingsParam.setCopyMode(remoteSettings.getRemoteCopyMode());
                }
            }
            _dbClient.createObject(remoteSettingsList);
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPoolRemoteProtectionVirtualArraySettingsParam(com.emc.storageos.model.vpool.VirtualPoolRemoteProtectionVirtualArraySettingsParam) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ArrayList(java.util.ArrayList)

Example 20 with VirtualArray

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

the class BucketService method initiateBucketCreation.

private TaskResourceRep initiateBucketCreation(BucketParam param, Project project, TenantOrg tenant, DataObject.Flag[] flags) throws InternalException {
    ArgValidator.checkFieldUriType(param.getVpool(), VirtualPool.class, "vpool");
    ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
    Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
    Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
    Integer retention = Integer.valueOf(param.getRetention());
    // Hard Quota should be more than SoftQuota
    verifyQuotaValues(softQuota, hardQuota, param.getLabel());
    // check varray
    VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(neighborhood, param.getVarray(), false);
    _permissionsHelper.checkTenantHasAccessToVirtualArray(tenant.getId(), neighborhood);
    // check vpool reference
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, param.getVpool());
    _permissionsHelper.checkTenantHasAccessToVirtualPool(tenant.getId(), vpool);
    ArgValidator.checkEntity(vpool, param.getVpool(), false);
    if (!VirtualPool.Type.object.name().equals(vpool.getType())) {
        throw APIException.badRequests.virtualPoolNotForObjectStorage(VirtualPool.Type.object.name());
    }
    // verify retention. Its validated only if Retention is configured.
    if (retention != 0 && vpool.getMaxRetention() != 0 && retention > vpool.getMaxRetention()) {
        throw APIException.badRequests.insufficientRetentionForVirtualPool(vpool.getLabel(), "bucket");
    }
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, Integer.valueOf(1));
    capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.FALSE);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.QUOTA, hardQuota.toString());
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<BucketRecommendation> placement = _bucketScheduler.placeBucket(neighborhood, vpool, capabilities, attributeMap);
    if (placement.isEmpty()) {
        StringBuffer errorMessage = new StringBuffer();
        if (attributeMap.get(AttributeMatcher.ERROR_MESSAGE) != null) {
            errorMessage = (StringBuffer) attributeMap.get(AttributeMatcher.ERROR_MESSAGE);
        }
        throw APIException.badRequests.noStoragePools(neighborhood.getLabel(), vpool.getLabel(), errorMessage.toString());
    }
    // Randomly select a recommended pool
    Collections.shuffle(placement);
    BucketRecommendation recommendation = placement.get(0);
    String task = UUID.randomUUID().toString();
    Bucket bucket = prepareBucket(param, project, tenant, neighborhood, vpool, flags, recommendation);
    _log.info(String.format("createBucket --- Bucket: %1$s, StoragePool: %2$s, StorageSystem: %3$s", bucket.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
    Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.CREATE_BUCKET);
    op.setDescription("Bucket Create");
    // Controller invocation
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
    ObjectController controller = getController(ObjectController.class, system.getSystemType());
    controller.createBucket(recommendation.getSourceStorageSystem(), recommendation.getSourceStoragePool(), bucket.getId(), bucket.getName(), bucket.getNamespace(), bucket.getRetention(), bucket.getHardQuota(), bucket.getSoftQuota(), bucket.getOwner(), task);
    auditOp(OperationTypeEnum.CREATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, param.getLabel(), param.getHardQuota(), neighborhood.getId().toString(), project == null ? null : project.getId().toString());
    return toTask(bucket, task, op);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) BucketRecommendation(com.emc.storageos.api.service.impl.placement.BucketRecommendation) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) ObjectController(com.emc.storageos.volumecontroller.ObjectController) DataObject(com.emc.storageos.db.client.model.DataObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VirtualArray (com.emc.storageos.db.client.model.VirtualArray)183 URI (java.net.URI)91 ArrayList (java.util.ArrayList)91 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)84 Project (com.emc.storageos.db.client.model.Project)53 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)52 StringSet (com.emc.storageos.db.client.model.StringSet)50 Volume (com.emc.storageos.db.client.model.Volume)46 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)44 List (java.util.List)44 StoragePool (com.emc.storageos.db.client.model.StoragePool)43 HashMap (java.util.HashMap)38 StringMap (com.emc.storageos.db.client.model.StringMap)37 Recommendation (com.emc.storageos.volumecontroller.Recommendation)37 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)31 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)30 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)29 Network (com.emc.storageos.db.client.model.Network)27 VPlexRecommendation (com.emc.storageos.volumecontroller.VPlexRecommendation)27