use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StorageSystemService method deregisterStorageSystem.
/**
* Allows the user register the storage system with the passed id.
*
* @param id the URN of a ViPR storage system.
*
* @brief Deregister storage system
* @return A StorageSystemRestRep reference specifying the data for the
* updated storage system.
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deregister")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StorageSystemRestRep deregisterStorageSystem(@PathParam("id") URI id) throws ControllerException {
// Validate the storage system.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntity(storageSystem, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(storageSystem.getRegistrationStatus())) {
storageSystem.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.updateObject(storageSystem);
stopStorageSystem(storageSystem);
}
// Deregister all Pools.
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(id), storagePoolURIs);
Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
List<StoragePool> modifiedPools = new ArrayList<StoragePool>();
while (storagePoolIter.hasNext()) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, storagePoolIter.next());
modifiedPools.add(pool);
if (pool.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(pool.getRegistrationStatus())) {
continue;
}
// Setting status to UNREGISTERED.
pool.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.updateObject(pool);
auditOp(OperationTypeEnum.DEREGISTER_STORAGE_POOL, true, null, id.toString());
}
// Deregister all Ports.
URIQueryResultList storagePortURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
Iterator<URI> storagePortIter = storagePortURIs.iterator();
while (storagePortIter.hasNext()) {
StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortIter.next());
if (port.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(port.getRegistrationStatus())) {
continue;
}
// Setting status to UNREGISTERED.
port.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
_dbClient.updateObject(port);
auditOp(OperationTypeEnum.DEREGISTER_STORAGE_PORT, true, null, port.getLabel(), port.getId().toString());
}
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(modifiedPools, _dbClient, _coordinator, errorMessage);
auditOp(OperationTypeEnum.DEREGISTER_STORAGE_SYSTEM, true, null, storageSystem.getId().toString(), id.toString());
return map(storageSystem);
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StorageSystemService method registerStoragePool.
/**
* Manually register the discovered storage pool with the passed id on the
* registered storage system with the passed id.
*
* @param id the URN of a ViPR storage system.
* @param poolId The id of the storage pool.
*
* @brief Register storage system storage pool
* @return A reference to a StoragePoolRestRep specifying the data for the
* registered storage pool.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{id}/storage-pools/{poolId}/register")
public StoragePoolRestRep registerStoragePool(@PathParam("id") URI id, @PathParam("poolId") URI poolId) {
// Make sure storage system is registered.
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
queryRegisteredSystem(id);
ArgValidator.checkFieldUriType(poolId, StoragePool.class, "poolId");
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolId);
ArgValidator.checkEntity(pool, poolId, isIdEmbeddedInURL(poolId));
if (!id.equals(pool.getStorageDevice())) {
throw APIException.badRequests.poolNotBelongingToSystem(poolId, id);
}
// if not register, registered it. Otherwise, dont do anything
if (RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(pool.getRegistrationStatus())) {
registerStoragePool(pool);
StringBuffer errorMessage = new StringBuffer();
// Pool registration also update its varray relationship, so, we should also update vpool to pool relation.
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(Arrays.asList(pool), _dbClient, _coordinator, errorMessage);
}
return StoragePoolService.toStoragePoolRep(pool, _dbClient, _coordinator);
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class ObjectVirtualPoolService method getMatchingPoolsForVirtualPoolAttributes.
/**
* Return the matching pools for a given set of VirtualPool attributes.
* This API is useful for user to find the matching pools before creating a VirtualPool.
*
* @param param : VirtualPoolAttributeParam
* @brief List pools matching specified properties in Object store VirtualPool
* @return : matching pools.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/matching-pools")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StoragePoolList getMatchingPoolsForVirtualPoolAttributes(ObjectVirtualPoolParam param) {
StoragePoolList poolList = new StoragePoolList();
VirtualPool vpool = prepareVirtualPool(param);
List<URI> poolURIs = _dbClient.queryByType(StoragePool.class, true);
List<StoragePool> allPools = _dbClient.queryObject(StoragePool.class, poolURIs);
StringBuffer errorMessage = new StringBuffer();
List<StoragePool> matchedPools = ImplicitPoolMatcher.getMatchedPoolWithStoragePools(vpool, allPools, null, null, null, _dbClient, _coordinator, AttributeMatcher.VPOOL_MATCHERS, errorMessage);
for (StoragePool pool : matchedPools) {
poolList.getPools().add(toNamedRelatedResource(pool, pool.getNativeGuid()));
}
return poolList;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class SRDFBlockServiceApiImpl method prepareVolume.
/**
* Prepare Volume for an SRDF protected volume
*
* @param volume
* pre-created volume from the api service
* @param param
* volume request
* @param project
* project requested
* @param varray
* varray requested
* @param vpool
* vpool requested
* @param size
* size of the volume
* @param placement
* recommendation for placement
* @param label
* volume label
* @param consistencyGroup
* consistency group
* @param token
* task id
* @param remote
* is this a target volume
* @param personality
* normal volume or metadata
* @param srcVolumeId
* source volume ID; only for target volumes
* @param raGroupURI
* RDF Group of the source array to use
* @param copyMode
* copy policy, like async or sync
*
* @return a persisted volume
*/
private Volume prepareVolume(Volume volume, final Project project, final VirtualArray varray, final VirtualPool vpool, final String size, final Recommendation placement, final String label, final BlockConsistencyGroup consistencyGroup, final String token, final boolean remote, final Volume.PersonalityTypes personality, final URI srcVolumeId, final URI raGroupURI, final String copyMode) {
boolean newVolume = false;
if (volume == null) {
// check for duplicate label
validateVolumeLabel(label, project);
newVolume = true;
volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setOpStatus(new OpStatusMap());
} else {
volume = _dbClient.queryObject(Volume.class, volume.getId());
}
volume.setLabel(label);
volume.setCapacity(SizeUtil.translateSize(size));
volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
volume.setVirtualPool(vpool.getId());
volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
volume.setVirtualArray(varray.getId());
volume.setSrdfGroup(raGroupURI);
volume.setSrdfCopyMode(copyMode);
if (null != placement.getSourceStoragePool()) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, placement.getSourceStoragePool());
if (null != pool) {
volume.setProtocol(new StringSet());
volume.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
}
}
volume.setPersonality(personality.toString());
if (personality.equals(Volume.PersonalityTypes.SOURCE)) {
volume.setAccessState(VolumeAccessState.READWRITE.name());
} else if (personality.equals(Volume.PersonalityTypes.TARGET)) {
volume.setAccessState(VolumeAccessState.NOT_READY.name());
}
URI storageSystemUri = null;
if (!remote) {
storageSystemUri = placement.getSourceStorageSystem();
volume.setStorageController(storageSystemUri);
volume.setPool(placement.getSourceStoragePool());
} else {
storageSystemUri = ((SRDFRecommendation) placement).getVirtualArrayTargetMap().get(varray.getId()).getTargetStorageDevice();
volume.setStorageController(storageSystemUri);
volume.setPool(((SRDFRecommendation) placement).getVirtualArrayTargetMap().get(varray.getId()).getTargetStoragePool());
}
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemUri);
String systemType = storageSystem.checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : storageSystem.getSystemType();
volume.setSystemType(systemType);
volume.setOpStatus(new OpStatusMap());
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
op.setStartTime(Calendar.getInstance());
volume.getOpStatus().put(token, op);
if (consistencyGroup != null) {
volume.setConsistencyGroup(consistencyGroup.getId());
volume.setReplicationGroupInstance(consistencyGroup.getLabel());
}
if (null != vpool.getAutoTierPolicyName()) {
URI autoTierPolicyUri = StorageScheduler.getAutoTierPolicy(volume.getPool(), vpool.getAutoTierPolicyName(), _dbClient);
if (null != autoTierPolicyUri) {
volume.setAutoTieringPolicyUri(autoTierPolicyUri);
}
}
// Keep track of target volumes associated with the source volume
if (srcVolumeId != null) {
Volume srcVolume = _dbClient.queryObject(Volume.class, srcVolumeId);
if (srcVolume.getSrdfTargets() == null) {
srcVolume.setSrdfTargets(new StringSet());
}
// This is done in prepare, but the source volume may be a cos change volume that didn't
// go through that process.
srcVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
srcVolume.getSrdfTargets().add(volume.getId().toString());
_dbClient.updateObject(srcVolume);
volume.setSrdfParent(new NamedURI(srcVolume.getId(), srcVolume.getLabel()));
computeCapacityforSRDFV3ToV2(volume, vpool);
}
if (newVolume) {
_dbClient.createObject(volume);
} else {
_dbClient.updateObject(volume);
}
return volume;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class SRDFBlockServiceApiImpl method computeCapacityforSRDFV3ToV2.
/**
* SRDF between VMAX3 to VMAX2 is failing due to configuration mismatch (OPT#475186).
* As a workaround, calculate the VMAX2 volume size based on the VMAX3 cylinder size.
*
* @param targetVolume
* @param vpool
*/
private void computeCapacityforSRDFV3ToV2(Volume targetVolume, final VirtualPool vpool) {
if (targetVolume == null) {
return;
}
StorageSystem targetSystem = _dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
StoragePool targetPool = _dbClient.queryObject(StoragePool.class, targetVolume.getPool());
Volume sourceVolume = _dbClient.queryObject(Volume.class, targetVolume.getSrdfParent());
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
StoragePool sourcePool = _dbClient.queryObject(StoragePool.class, sourceVolume.getPool());
if (sourceSystem != null && targetSystem != null) {
boolean isCapacityReset = false;
if (sourcePool != null && targetPool != null) {
// Meta Versus Non Meta
MetaVolumeRecommendation sourceVolumeRecommendation = MetaVolumeUtils.getCreateRecommendation(sourceSystem, sourcePool, sourceVolume.getCapacity(), sourceVolume.getThinlyProvisioned(), vpool.getFastExpansion(), null);
MetaVolumeRecommendation targetVolumeRecommendation = MetaVolumeUtils.getCreateRecommendation(targetSystem, targetPool, targetVolume.getCapacity(), targetVolume.getThinlyProvisioned(), vpool.getFastExpansion(), null);
isCapacityReset = computeCapacityforSRDFV3ToV2Meta(sourcePool, targetPool, sourceVolume, targetVolume, sourceVolumeRecommendation, targetVolumeRecommendation);
}
// Source : VMAX3 & Target : VMAX2 case
if (sourceSystem.checkIfVmax3() && !targetSystem.checkIfVmax3() && !isCapacityReset) {
Long cylinderCount = (long) Math.ceil((double) targetVolume.getCapacity() / V3CYLINDERSIZE);
targetVolume.setCapacity(cylinderCount * V3CYLINDERSIZE);
_log.info("Cylinder Count : {}, VMAX2 volume Capacity : {}", cylinderCount, targetVolume.getCapacity());
}
}
}
Aggregations