use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method getVirtualPool.
/**
* Get info for block store virtual pool
*
* @prereq none
* @param id the URN of a ViPR VirtualPool
* @brief Show block store virtual pool
* @return VirtualPool details
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public BlockVirtualPoolRestRep getVirtualPool(@PathParam("id") URI id) {
VirtualPool vpool = getVirtualPool(VirtualPool.Type.block, id);
BlockVirtualPoolRestRep restRep = getBlockVirtualPoolWithProtection(vpool);
restRep.setNumResources(getNumResources(vpool, _dbClient));
return restRep;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method verifyNewHAVpoolForHAVpoolUpdate.
/**
* When updating a virtual pool, this function verifies that if there is
* and update to the HA virtual pool, that the specified pool is valid
* for the virtual pool being updated.
*
* @param vPoolBeingUpdated The vpool being updated.
* @param newHAVpoolId The non-null id of the new HA vpool.
*/
private void verifyNewHAVpoolForHAVpoolUpdate(VirtualPool vPoolBeingUpdated, String newHAVpoolId) {
URI newHAVpoolURI = URI.create(newHAVpoolId);
VirtualPool newHAVpool = _dbClient.queryObject(VirtualPool.class, newHAVpoolURI);
if (newHAVpool == null) {
throw APIException.badRequests.haVpoolForVpoolUpdateDoesNotExist(newHAVpoolId);
}
if (newHAVpool.getInactive()) {
throw APIException.badRequests.haVpoolForVpoolUpdateIsInactive(newHAVpool.getLabel());
}
StringMap newHAVpoolHAMap = newHAVpool.getHaVarrayVpoolMap();
if ((newHAVpoolHAMap == null) || (newHAVpoolHAMap.isEmpty())) {
// New HA vpool does not specify VPLEX HA.
return;
}
String newHAVpoolHAVpoolId = newHAVpoolHAMap.get(newHAVpoolHAMap.keySet().iterator().next());
if (!NullColumnValueGetter.isNotNullValue(newHAVpoolHAVpoolId)) {
// No HA Vpool specified.
return;
}
VirtualPool newHAVpoolHAVpool = _dbClient.queryObject(VirtualPool.class, URI.create(newHAVpoolHAVpoolId));
if (newHAVpoolHAVpool == null) {
// Invalid HA vpool for the new HA vpool does not exist.
throw APIException.badRequests.haVpoolForNewHAVpoolForVpoolUpdateDoesNotExist(newHAVpoolHAVpoolId, newHAVpool.getLabel());
}
// HA vpool is not this vpool being updated. See Jira 6797.
if (newHAVpoolHAVpool.getId().equals(vPoolBeingUpdated.getId())) {
throw APIException.badRequests.haVpoolForVpoolUpdateHasInvalidHAVpool(newHAVpool.getLabel());
}
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method queryFilteredBulkResourceReps.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected BlockVirtualPoolBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
if (isSystemOrRestrictedSystemAdmin()) {
return queryBulkResourceReps(ids);
}
if (!ids.iterator().hasNext()) {
return new BlockVirtualPoolBulkRep();
}
// get vdc id from the first id; assume all id's are from the same vdc
String shortVdcId = VdcUtil.getVdcId(getResourceClass(), ids.iterator().next()).toString();
Iterator<VirtualPool> dbIterator;
if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
} else {
GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
try {
dbIterator = geoClient.queryObjects(getResourceClass(), ids);
} catch (Exception ex) {
// TODO: revisit this exception
_log.error("error retrieving bulk virtual pools from vdc " + shortVdcId, ex);
throw APIException.internalServerErrors.genericApisvcError("error retrieving remote virtual pool", ex);
}
}
BulkList.ResourceFilter filter = new BulkList.VirtualPoolFilter(Type.block, getUserFromContext(), _permissionsHelper);
return new BlockVirtualPoolBulkRep(BulkList.wrapping(dbIterator, BLOCK_VPOOL_MAPPER, filter));
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method createBlockVirtualPool.
/**
* Creates a block store virtual pool
*
* @prereq none
* @param param VirtualPool parameters
* @brief Create block store virtual pool
* @return VirtualPool details
* @throws Exception
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public BlockVirtualPoolRestRep createBlockVirtualPool(BlockVirtualPoolParam param) throws DatabaseException {
ArgValidator.checkFieldNotEmpty(param.getName(), VPOOL_NAME);
checkForDuplicateName(param.getName(), VirtualPool.class);
ArgValidator.checkFieldNotEmpty(param.getDescription(), VPOOL_DESCRIPTION);
VirtualPoolUtil.validateBlockVirtualPoolCreateParams(param, _dbClient);
Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettingsMap = new HashMap<URI, VpoolRemoteCopyProtectionSettings>();
List<VpoolProtectionVarraySettings> protectionSettings = new ArrayList<VpoolProtectionVarraySettings>();
Map<URI, VpoolProtectionVarraySettings> protectionSettingsMap = new HashMap<URI, VpoolProtectionVarraySettings>();
VirtualPool vpool = prepareVirtualPool(param, remoteSettingsMap, protectionSettingsMap, protectionSettings);
// Set the underlying protection setting objects
if (!protectionSettings.isEmpty()) {
_dbClient.createObject(protectionSettings);
}
if (!remoteSettingsMap.isEmpty()) {
_dbClient.createObject(new ArrayList(remoteSettingsMap.values()));
}
StringBuffer errorMessage = new StringBuffer();
// update the implicit pools matching with this VirtualPool.
ImplicitPoolMatcher.matchVirtualPoolWithAllStoragePools(vpool, _dbClient, _coordinator, errorMessage);
Set<URI> allSrdfTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
Set<URI> allRpTargetVPools = RPHelper.fetchRPTargetVirtualPools(_dbClient);
if (null != vpool.getMatchedStoragePools() || null != vpool.getInvalidMatchedPools()) {
ImplicitUnManagedObjectsMatcher.matchVirtualPoolsWithUnManagedVolumes(vpool, allSrdfTargetVPools, allRpTargetVPools, _dbClient, true);
}
_dbClient.createObject(vpool);
// Creates a new QoS object in DB based on data from given Virtual Pool
QosService.createQosSpecification(vpool, _dbClient);
recordOperation(OperationTypeEnum.CREATE_VPOOL, VPOOL_CREATED_DESCRIPTION, vpool);
return toBlockVirtualPool(_dbClient, vpool, VirtualPool.getProtectionSettings(vpool, _dbClient), VirtualPool.getRemoteProtectionSettings(vpool, _dbClient));
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BucketService method updateBucket.
/**
* Updates Bucket values like Quota and Retention.
*
* @param id Bucket ID
* @param param Bucket update parameter
* @brief Change bucket properties
* @return Task resource representation
* @throws InternalException if update fails
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateBucket(@PathParam("id") URI id, BucketUpdateParam param) throws InternalException {
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
Integer retention = null != param.getRetention() ? Integer.valueOf(param.getRetention()) : 0;
// if no softquota is provided, use the old value
if (softQuota == 0) {
softQuota = bucket.getSoftQuota();
}
// if no hardquota is provided, use the old value
if (hardQuota == 0) {
hardQuota = bucket.getHardQuota();
}
// Hard Quota should be more than SoftQuota
verifyQuotaValues(softQuota, hardQuota, bucket.getLabel());
// if no retention is provided, use the old value
if (retention == 0) {
retention = bucket.getRetention();
}
VirtualPool cos = _dbClient.queryObject(VirtualPool.class, bucket.getVirtualPool());
// verify retention. Its validated only if Retention is configured.
if (retention != 0 && cos.getMaxRetention() != 0 && retention > cos.getMaxRetention()) {
throw APIException.badRequests.insufficientRetentionForVirtualPool(cos.getLabel(), "bucket");
}
String task = UUID.randomUUID().toString();
_log.info(String.format("BucketUpdate --- Bucket id: %1$s, Task: %2$s", id, task));
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.UPDATE_BUCKET);
op.setDescription("Bucket update");
ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
controller.updateBucket(bucket.getStorageDevice(), id, softQuota, hardQuota, retention, task);
auditOp(OperationTypeEnum.UPDATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
return toTask(bucket, task, op);
}
Aggregations