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;
}
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");
}
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);
}
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();
}
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();
}
Aggregations