use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolService method getStoragePools.
/**
* Gets the ids and self links for all storage pools.
*
* @brief List storage pools
* @return A StoragePoolList reference specifying the ids and self links for
* the storage pools.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePoolList getStoragePools() {
StoragePoolList storagePools = new StoragePoolList();
List<URI> ids = _dbClient.queryByType(StoragePool.class, true);
for (URI id : ids) {
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, id);
if (storagePool != null) {
storagePools.getPools().add(toNamedRelatedResource(storagePool, storagePool.getNativeGuid()));
}
}
return storagePools;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolService method getStorageTiers.
/**
* Get Storage tiers associated with given Pool
* Vmax pools, only one tier will be present always
* Vnx pools can have multiple tiers.
*
* @param id the URN of a ViPR storage pool.
*
* @brief List storage pool storage tiers
* @return A StorageTierList reference specifying the data for the
* storage tier with the passed id.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-tiers")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageTierList getStorageTiers(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StoragePool.class, "id");
StoragePool storagePool = queryRegisteredResource(id);
ArgValidator.checkEntity(storagePool, id, isIdEmbeddedInURL(id));
if (storagePool.getTiers() == null) {
throw APIException.badRequests.invalidParameterStoragePoolHasNoTiers(id);
}
StorageTierList storageTierList = new StorageTierList();
for (String tierUri : storagePool.getTiers()) {
StorageTier tier = _dbClient.queryObject(StorageTier.class, URI.create(tierUri));
if (null != tier) {
storageTierList.getStorageTiers().add(toNamedRelatedResource(tier, tier.getNativeGuid()));
}
}
return storageTierList;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolService method getStoragePool.
/**
* Gets the data for a storage pool.
*
* @param id the URN of a ViPR storage pool.
*
* @brief Show storage pool
* @return A StoragePoolRestRep reference specifying the data for the
* storage pool with the passed id.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePoolRestRep getStoragePool(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StoragePool.class, "id");
StoragePool storagePool = queryResource(id);
ArgValidator.checkEntity(storagePool, id, isIdEmbeddedInURL(id));
StoragePoolRestRep restRep = toStoragePoolRep(storagePool, _dbClient, _coordinator);
restRep.setNumResources(getNumResources(storagePool, _dbClient));
return restRep;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolService method updateStoragePool.
/**
* This API call only allows user to update virtual array & virtual pool
* assignments for the registered storage pool.
* <p>
* A pool can be associated with a virtual array either implicitly or explicitly. A pool is implicitly associated with a virtual array
* when the pool's storage system has one or more ports in the virtual array (see {@link StoragePool#getConnectedVirtualArrays()}). the
* pool's implicit virtual arrays are the union of all the tagged virtual arrays of the storage array ports. This implicit association
* cannot be changed or removed, it can only be overridden by an explicit assignment (see {@link StoragePool#getAssignedVirtualArrays()}
* ). A pool's effective virtual array association is {@link StoragePool#getTaggedVirtualArrays()})
* <p>
* Managing pools associated virtual arrays requires planning. In general, pools should be assigned to virtual arrays only when it is
* desired to limit the virtual arrays where they can be used.
*
* @param id the URN of a ViPR storage pool.
* @param storagePoolUpdates Specifies the updates to be made to the storage
* pool.
*
* @brief Update storage pool
* @return A StoragePoolRestRep specifying the updated storage pool info.
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StoragePoolRestRep updateStoragePool(@PathParam("id") URI id, StoragePoolUpdate storagePoolUpdates) {
// Get the storage pool with the passed id.
ArgValidator.checkFieldUriType(id, StoragePool.class, "id");
StoragePool storagePool = queryRegisteredResource(id);
ArgValidator.checkEntity(storagePool, id, isIdEmbeddedInURL(id));
boolean neighborhoodChange = false;
// the storage pool.
if (storagePoolUpdates.getVarrayChanges() != null) {
VirtualArrayAssignments addedNH = storagePoolUpdates.getVarrayChanges().getAdd();
if ((addedNH != null) && (!addedNH.getVarrays().isEmpty())) {
VirtualArrayService.checkVirtualArrayURIs(addedNH.getVarrays(), _dbClient);
storagePool.addAssignedVirtualArrays(addedNH.getVarrays());
}
// Validate that the neighborhoods to be unassigned from the storage
// pool reference existing neighborhoods in the database and remove
// them from the storage pool.
VirtualArrayAssignments removedNH = storagePoolUpdates.getVarrayChanges().getRemove();
if ((removedNH != null) && (!removedNH.getVarrays().isEmpty())) {
VirtualArrayService.checkVirtualArrayURIs(removedNH.getVarrays(), _dbClient);
storagePool.removeAssignedVirtualArrays(removedNH.getVarrays());
}
verifyPoolNoInUseInVarrays(storagePool);
neighborhoodChange = true;
}
// for all VirtualPool.
if (neighborhoodChange) {
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(Arrays.asList(storagePool), _dbClient, _coordinator, errorMessage);
}
Integer currentMaxSubscriptionPercentFromArray = storagePool.getMaxThinPoolSubscriptionPercentageFromArray();
_logger.info(String.format("Current maximum subscription percent in storage pool from array : %s ", currentMaxSubscriptionPercentFromArray));
if (null != storagePoolUpdates.getMaxPoolUtilizationPercentage()) {
if (storagePoolUpdates.getMaxPoolUtilizationPercentage() < 0 || storagePoolUpdates.getMaxPoolUtilizationPercentage() > 100) {
throw APIException.badRequests.invalidParameterPercentageExpected("max_pool_utilization_percentage", storagePoolUpdates.getMaxPoolUtilizationPercentage());
}
// check that a new value does not exceed array limit
if (currentMaxSubscriptionPercentFromArray != null && storagePoolUpdates.getMaxPoolUtilizationPercentage() > currentMaxSubscriptionPercentFromArray) {
throw APIException.badRequests.invalidParameterValueExceedsArrayLimit("max_pool_utilization_percentage", storagePoolUpdates.getMaxPoolUtilizationPercentage(), currentMaxSubscriptionPercentFromArray);
}
storagePool.setMaxPoolUtilizationPercentage(storagePoolUpdates.getMaxPoolUtilizationPercentage());
}
if (null != storagePoolUpdates.getMaxThinPoolSubscriptionPercentage()) {
ArgValidator.checkFieldMinimum(storagePoolUpdates.getMaxThinPoolSubscriptionPercentage(), 0, "max_thin_pool_subscription_percentage");
if (!validateMaxThinPoolSubscriptionInput(storagePool, storagePoolUpdates.getMaxThinPoolSubscriptionPercentage())) {
throw APIException.badRequests.parameterIsOnlyApplicableTo("max_thin_pool_subscription_percentage", "Thin Pool");
}
// check that a new value does not exceed array limit
if (currentMaxSubscriptionPercentFromArray != null && storagePoolUpdates.getMaxThinPoolSubscriptionPercentage() > currentMaxSubscriptionPercentFromArray) {
throw APIException.badRequests.invalidParameterValueExceedsArrayLimit("max_thin_pool_subscription_percentage", storagePoolUpdates.getMaxThinPoolSubscriptionPercentage(), currentMaxSubscriptionPercentFromArray);
}
storagePool.setMaxThinPoolSubscriptionPercentage(storagePoolUpdates.getMaxThinPoolSubscriptionPercentage());
}
// If unlimited resources is set to false, then max resources should also be specified. If not specified, throw error
if (null != storagePoolUpdates.getIsUnlimitedResourcesSet()) {
if (storagePoolUpdates.getIsUnlimitedResourcesSet()) {
storagePool.setIsResourceLimitSet(false);
} else {
if (null != storagePoolUpdates.getMaxResources()) {
storagePool.setIsResourceLimitSet(true);
storagePool.setMaxResources(storagePoolUpdates.getMaxResources());
} else {
throw APIException.badRequests.parameterMaxResourcesMissing();
}
}
} else if (null != storagePoolUpdates.getMaxResources()) {
storagePool.setMaxResources(storagePoolUpdates.getMaxResources());
storagePool.setIsResourceLimitSet(true);
}
// Persist the changes and return a successful response.
_dbClient.updateAndReindexObject(storagePool);
// Record the storage pool update event.
recordStoragePoolEvent(OperationTypeEnum.STORAGE_POOL_UPDATE, STORAGEPOOL_UPDATED_DESCRIPTION, storagePool.getId());
auditOp(OperationTypeEnum.UPDATE_STORAGE_POOL, true, null, id.toString());
return toStoragePoolRep(storagePool, _dbClient, _coordinator);
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class FileService method prepareFileSystem.
/**
* Allocate, initialize and persist state of the fileSystem being created.
*
* @param param
* @param project
* @param tenantOrg
* @param neighborhood
* @param vpool
* @param flags
* @param placement
* @param token
* @return
*/
private FileShare prepareFileSystem(FileSystemParam param, Project project, TenantOrg tenantOrg, VirtualArray neighborhood, VirtualPool vpool, DataObject.Flag[] flags, FileRecommendation placement, String token) {
_log.info("prepareFile System");
StoragePool pool = null;
FileShare fs = new FileShare();
fs.setId(URIUtil.createId(FileShare.class));
fs.setLabel(param.getLabel());
// No need to generate any name -- Since the requirement is to use the customizing label we should use the same.
// Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
String convertedName = param.getLabel().replaceAll("[^\\dA-Za-z\\_]", "");
_log.info("Original name {} and converted name {}", param.getLabel(), convertedName);
fs.setName(convertedName);
Long fsSize = SizeUtil.translateSize(param.getSize());
fs.setCapacity(fsSize);
fs.setVirtualPool(param.getVpool());
if (project != null) {
fs.setProject(new NamedURI(project.getId(), fs.getLabel()));
}
fs.setTenant(new NamedURI(tenantOrg.getId(), param.getLabel()));
fs.setVirtualArray(neighborhood.getId());
if (null != placement.getSourceStoragePool()) {
pool = _dbClient.queryObject(StoragePool.class, placement.getSourceStoragePool());
if (null != pool) {
fs.setProtocol(new StringSet());
fs.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
}
}
fs.setStorageDevice(placement.getSourceStorageSystem());
fs.setPool(placement.getSourceStoragePool());
if (param.getSoftLimit() != 0) {
fs.setSoftLimit(new Long(param.getSoftLimit()));
}
if (param.getNotificationLimit() != 0) {
fs.setNotificationLimit(new Long(param.getNotificationLimit()));
}
if (param.getSoftGrace() > 0) {
fs.setSoftGracePeriod(new Integer(param.getSoftGrace()));
}
if (placement.getStoragePorts() != null && !placement.getStoragePorts().isEmpty()) {
fs.setStoragePort(placement.getStoragePorts().get(0));
}
// When a VPool supports "thin" provisioning
if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
fs.setThinlyProvisioned(Boolean.TRUE);
}
if (placement.getvNAS() != null) {
fs.setVirtualNAS(placement.getvNAS());
}
fs.setOpStatus(new OpStatusMap());
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.CREATE_FILE_SYSTEM);
fs.getOpStatus().createTaskStatus(token, op);
if (flags != null) {
fs.addInternalFlags(flags);
}
_dbClient.createObject(fs);
return fs;
}
Aggregations