Search in sources :

Example 1 with StringMap

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

the class MigrationService method getVirtualPoolForMigrationTarget.

/**
 * Gets the VirtualPool for the migration target.
 *
 * @param requestedCosURI The VirtualPool specified in the migration request.
 * @param vplexVolume A reference to the VPlex virtual volume.
 * @param migrationSrc A reference to the migration source.
 *
 * @return A reference to the VirtualPool for the migration target volume.
 */
private VirtualPool getVirtualPoolForMigrationTarget(URI requestedCosURI, Volume vplexVolume, Volume migrationSrc) {
    // Get the VirtualPool for the migration source.
    VirtualPool cosForMigrationSrc = _permissionsHelper.getObjectById(migrationSrc.getVirtualPool(), VirtualPool.class);
    // Determine the VirtualPool for the migration target based on
    // the VirtualPool specified in the request, if any. Note that the
    // VirtualPool specified in the request should be the new VirtualPool for
    // the passed VPlex volume after the migration is complete.
    VirtualPool cosForMigrationTgt = null;
    if (requestedCosURI != null) {
        // Get the new VirtualPool for the virtual volume verifying
        // that the VirtualPool is valid for the project's tenant and
        // set it initially as the VirtualPool for the migration
        // target.
        Project vplexVolumeProject = _permissionsHelper.getObjectById(vplexVolume.getProject(), Project.class);
        cosForMigrationTgt = BlockService.getVirtualPoolForRequest(vplexVolumeProject, requestedCosURI, _dbClient, _permissionsHelper);
        // Now get the VirtualArray of the migration source volume.
        // We need to know if this is the primary volume or the HA
        // volume.
        URI migrationNhURI = migrationSrc.getVirtualArray();
        if (!migrationNhURI.toString().equals(vplexVolume.getVirtualArray().toString())) {
            // The HA backend volume is being migrated.
            // The VirtualPool for the HA volume is potentially
            // specified by the HA VirtualPool map in the requested
            // VirtualPool. If not, then the VirtualPool for the HA volume
            // is the same as that of the VPlex volume.
            StringMap haNhCosMap = cosForMigrationTgt.getHaVarrayVpoolMap();
            if ((haNhCosMap != null) && (haNhCosMap.containsKey(migrationNhURI.toString()))) {
                cosForMigrationTgt = BlockService.getVirtualPoolForRequest(vplexVolumeProject, URI.create(haNhCosMap.get(migrationNhURI.toString())), _dbClient, _permissionsHelper);
            }
            // Now verify the VirtualPool change is legitimate.
            VirtualPoolChangeAnalyzer.verifyVirtualPoolChangeForTechRefresh(cosForMigrationSrc, cosForMigrationTgt);
        } else {
            // The primary or source volume is being migrated.
            // The VirtualPool for the primary volume is the same as
            // that for the VPlex volume. We still need to verify
            // this is a legitimate VirtualPool change.
            VirtualPoolChangeAnalyzer.verifyVirtualPoolChangeForTechRefresh(cosForMigrationSrc, cosForMigrationTgt);
        }
    } else {
        // A new VirtualPool was not specified for the virtual volume, so
        // the VirtualPool for the migration target will be the same as that
        // for the migration source.
        cosForMigrationTgt = cosForMigrationSrc;
    }
    return cosForMigrationTgt;
}
Also used : Project(com.emc.storageos.db.client.model.Project) StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 2 with StringMap

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

the class ConsistencyGroupService method deleteConsistencyGroup.

/**
 * Delete consistency group
 *
 * @param openstackTenantId openstack tenant id
 * @param consistencyGroupId consistency group id
 * @param param pojo class to bind request
 * @param isV1Call cinder V1 api
 * @param header HTTP header
 * @brief delete Consistency group
 * @return Response
 */
@POST
@Path("/{consistencyGroup_id}/delete")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response deleteConsistencyGroup(@PathParam("tenant_id") String openstackTenantId, @PathParam("consistencyGroup_id") String consistencyGroupId, ConsistencyGroupDeleteRequest param, @HeaderParam("X-Cinder-V1-Call") String isV1Call, @Context HttpHeaders header) {
    boolean isForced = param.consistencygroup.force;
    final BlockConsistencyGroup consistencyGroup = findConsistencyGroup(consistencyGroupId, openstackTenantId);
    if (consistencyGroup == null) {
        _log.error("Not Found : No Such Consistency Group Found {}", consistencyGroupId);
        return CinderApiUtils.createErrorResponse(404, "Not Found : No Such Consistency Group Found");
    } else if (!consistencyGroupId.equals(CinderApiUtils.splitString(consistencyGroup.getId().toString(), ":", 3))) {
        _log.error("Bad Request : There is no consistency group with id {} , please retry with correct consistency group id", consistencyGroupId);
        return CinderApiUtils.createErrorResponse(400, "Bad Request : There is no consistency group exist, please retry with correct consistency group id");
    }
    String task = UUID.randomUUID().toString();
    TaskResourceRep taskRep = null;
    if (getCinderHelper().verifyConsistencyGroupHasSnapshot(consistencyGroup)) {
        _log.error("Bad Request : Consistency Group {} has Snapshot", consistencyGroupId);
        return CinderApiUtils.createErrorResponse(400, "Bad Request : Consistency Group has Snapshot ");
    }
    if (isForced) {
        final URIQueryResultList cgVolumesResults = new URIQueryResultList();
        _dbClient.queryByConstraint(getVolumesByConsistencyGroup(consistencyGroup.getId()), cgVolumesResults);
        while (cgVolumesResults.iterator().hasNext()) {
            Volume volume = _dbClient.queryObject(Volume.class, cgVolumesResults.iterator().next());
            if (!volume.getInactive()) {
                BlockServiceApi api = BlockService.getBlockServiceImpl(volume, _dbClient);
                URI systemUri = volume.getStorageController();
                List<URI> volumeURIs = new ArrayList<URI>();
                volumeURIs.add(volume.getId());
                api.deleteVolumes(systemUri, volumeURIs, "FULL", null);
                if (volume.getExtensions() == null) {
                    volume.setExtensions(new StringMap());
                }
                volume.getExtensions().put("status", CinderConstants.ComponentStatus.DELETING.getStatus().toLowerCase());
                volume.setInactive(true);
                _dbClient.updateObject(volume);
            }
        }
    }
    try {
        ArgValidator.checkReference(BlockConsistencyGroup.class, consistencyGroup.getId(), checkForDelete(consistencyGroup));
    } catch (APIException e) {
        _log.error("Bad Request : Consistency Group Contains active references of type : {}", e.getMessage());
        return CinderApiUtils.createErrorResponse(400, "Bad Request : Consistency Group Contains active references");
    }
    // RP + VPlex CGs cannot be be deleted without VPlex controller intervention.
    if (!consistencyGroup.getTypes().contains(Types.VPLEX.toString()) || canDeleteConsistencyGroup(consistencyGroup)) {
        final URIQueryResultList cgVolumesResults = new URIQueryResultList();
        _dbClient.queryByConstraint(getVolumesByConsistencyGroup(consistencyGroup.getId()), cgVolumesResults);
        while (cgVolumesResults.iterator().hasNext()) {
            Volume volume = _dbClient.queryObject(Volume.class, cgVolumesResults.iterator().next());
            if (!volume.getInactive()) {
                return CinderApiUtils.createErrorResponse(400, "Bad Request : Try to delete consistency group with --force");
            }
        }
        consistencyGroup.setStorageController(null);
        consistencyGroup.setInactive(true);
        _dbClient.updateObject(consistencyGroup);
        taskRep = finishDeactivateTask(consistencyGroup, task);
        if (taskRep.getState().equals("ready") || taskRep.getState().equals("pending")) {
            return Response.status(202).build();
        }
    }
    final StorageSystem storageSystem = consistencyGroup.created() ? _permissionsHelper.getObjectById(consistencyGroup.getStorageController(), StorageSystem.class) : null;
    // If the consistency group has been created, and the system
    // is a VPlex, then we need to do VPlex related things to destroy
    // the consistency groups on the system. If the consistency group
    // has not been created on the system or the system is not a VPlex
    // revert to the default.
    BlockServiceApi blockServiceApi = BlockService.getBlockServiceImpl("group");
    if (storageSystem != null) {
        String systemType = storageSystem.getSystemType();
        if (DiscoveredDataObject.Type.vplex.name().equals(systemType)) {
            blockServiceApi = BlockService.getBlockServiceImpl(systemType);
        }
        _log.info(String.format("BlockConsistencyGroup %s is associated to StorageSystem %s. Going to delete it on that array.", consistencyGroup.getLabel(), storageSystem.getNativeGuid()));
        // Otherwise, invoke operation to delete CG from the array.
        taskRep = blockServiceApi.deleteConsistencyGroup(storageSystem, consistencyGroup, task);
        if (taskRep.getState().equals("ready") || taskRep.getState().equals("pending")) {
            return Response.status(202).build();
        }
    }
    if (taskRep == null) {
        _log.info(String.format("BlockConsistencyGroup %s was not associated with any storage. Deleting it from ViPR only.", consistencyGroup.getLabel()));
        TaskResourceRep resp = finishDeactivateTask(consistencyGroup, task);
        if (resp.getState().equals("ready") || resp.getState().equals("pending")) {
            return Response.status(202).build();
        }
    }
    return CinderApiUtils.createErrorResponse(400, "Bad Request");
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) BlockServiceApi(com.emc.storageos.api.service.impl.resource.BlockServiceApi) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 3 with StringMap

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

the class ExportService method processUnReserveRequest.

private void processUnReserveRequest(Volume vol, String openstackTenantId) {
    StringMap extensions = vol.getExtensions();
    if (extensions == null) {
        extensions = new StringMap();
    }
    extensions.put("status", ComponentStatus.AVAILABLE.getStatus().toLowerCase());
    vol.setExtensions(extensions);
    _dbClient.updateObject(vol);
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap)

Example 4 with StringMap

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

the class ExportService method getVolExtensions.

private StringMap getVolExtensions(Volume vol) {
    StringMap extensions = vol.getExtensions();
    if (extensions == null) {
        extensions = new StringMap();
        vol.setExtensions(extensions);
    }
    return vol.getExtensions();
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap)

Example 5 with StringMap

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

the class ExportService method changeVolumeStatus.

/**
 * This method is used to change the status of volume on administrator request
 *
 * @param vol : Volume created on ViPR
 * @param input : json input
 * @return Response object if valid then 202 otherwise 404
 */
private Response changeVolumeStatus(Volume vol, String jsonInput) {
    String vol_status = getRequestedStatusFromRequest(jsonInput);
    _log.info("Changing the status of volume : " + vol + " to " + vol_status);
    StringMap extensions = vol.getExtensions();
    extensions.put(STATUS, vol_status);
    _dbClient.updateObject(vol);
    return Response.status(202).build();
}
Also used : 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