use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class VirtualPoolService method recordOperation.
public void recordOperation(OperationTypeEnum opType, String evDesc, Object... extParam) {
String evType;
evType = opType.getEvType(true);
_log.info("opType: {} detail: {}", opType.toString(), evType + ':' + evDesc);
VirtualPool vpool = (VirtualPool) extParam[0];
recordVirtualPoolEvent(evType, evDesc, vpool.getId());
StringBuilder protocols = new StringBuilder();
if (vpool.getProtocols() != null) {
for (String proto : vpool.getProtocols()) {
protocols.append(" ");
protocols.append(proto);
}
}
StringBuilder neighborhoods = new StringBuilder();
if (vpool.getVirtualArrays() != null) {
for (String neighborhood : vpool.getVirtualArrays()) {
neighborhoods.append(" ");
neighborhoods.append(neighborhood);
}
}
switch(opType) {
case CREATE_VPOOL:
auditOp(opType, true, null, vpool.getId().toString(), vpool.getLabel(), vpool.getType(), protocols.toString(), neighborhoods.toString(), vpool.getSupportedProvisioningType(), vpool.getAutoTierPolicyName(), vpool.getDriveType(), vpool.getHighAvailability());
break;
case UPDATE_VPOOL:
auditOp(opType, true, null, vpool.getId().toString(), vpool.getLabel(), vpool.getType(), protocols.toString(), neighborhoods.toString(), vpool.getSupportedProvisioningType(), vpool.getAutoTierPolicyName(), vpool.getDriveType());
break;
case DELETE_VPOOL:
auditOp(opType, true, null, vpool.getId().toString(), vpool.getLabel(), vpool.getType());
break;
default:
_log.error("unrecognized vpool operation type");
}
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class VirtualPoolService method updateVirtualPoolWithAssignedStoragePools.
/**
* This method allows user to assign matching pools to VirtualPool.
*
* @param id : the URN of a ViPR VirtualPool.
* @param param : Pool Update param
* @return : update VirtualPool.
*/
protected VirtualPool updateVirtualPoolWithAssignedStoragePools(URI id, VirtualPoolPoolUpdateParam param) {
ArgValidator.checkUri(id);
VirtualPool vpool = queryResource(id);
ArgValidator.checkEntity(vpool, id, isIdEmbeddedInURL(id));
if (param.getStoragePoolAssignmentChanges() != null) {
// Validate whether all the pools with virtual pool resources are part of the assigned pools
checkPoolsWithResources(param.getStoragePoolAssignmentChanges(), vpool, _dbClient);
StoragePoolAssignments addedAssignedPools = param.getStoragePoolAssignmentChanges().getAdd();
if ((addedAssignedPools != null) && (!addedAssignedPools.getStoragePools().isEmpty())) {
validateAssignedPoolInMatchedPools(addedAssignedPools.getStoragePools(), vpool);
vpool.updateAssignedStoragePools(addedAssignedPools.getStoragePools());
}
// Validate that the storage pools to be unassigned from the storage
// pool reference existing storage pools in the database and remove
// them from the storage pool.
StoragePoolAssignments removedPool = param.getStoragePoolAssignmentChanges().getRemove();
if ((removedPool != null) && (!removedPool.getStoragePools().isEmpty())) {
checkUnassignedPoolURIs(removedPool.getStoragePools(), vpool, _dbClient);
_log.debug("Removing pools {} from the virtual pool {}", removedPool.getStoragePools(), id);
vpool.removeAssignedStoragePools(removedPool.getStoragePools());
}
// adding supported vpools to unmanaged volumes/file systems
if (vpool.getType().equals(VirtualPool.Type.file.name())) {
ImplicitUnManagedObjectsMatcher.matchVirtualPoolsWithUnManagedFileSystems(vpool, _dbClient);
} else if (vpool.getType().equals(VirtualPool.Type.block.name())) {
Set<URI> allSrdfTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
Set<URI> allRpTargetVpools = RPHelper.fetchRPTargetVirtualPools(_dbClient);
ImplicitUnManagedObjectsMatcher.matchVirtualPoolsWithUnManagedVolumes(vpool, allSrdfTargetVPools, allRpTargetVpools, _dbClient, false);
}
_dbClient.updateAndReindexObject(vpool);
}
return vpool;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class VirtualPoolService method getAclsOnVirtualPool.
protected ACLAssignments getAclsOnVirtualPool(VirtualPool.Type type, URI id) {
VirtualPool vpool = queryResource(id);
ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
if (!vpool.getType().equals(type.name())) {
throw APIException.badRequests.providedVirtualPoolNotCorrectType();
}
ACLAssignments response = new ACLAssignments();
response.setAssignments(_permissionsHelper.convertToACLEntries(vpool.getAcls()));
return response;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class VirtualPoolService method refreshMatchedPools.
/**
* Refresh the matching pools by running implicit pool matcher algorithm and
* find if there are any new matched pools exists in the environment.
* Returns the new matched pools to user.
*
* @param id the URN of a ViPR VirtualPool.
* @return : list of pools.
*/
protected StoragePoolList refreshMatchedPools(VirtualPool.Type type, URI id) {
ArgValidator.checkUri(id);
StoragePoolList poolList = new StoragePoolList();
VirtualPool vpool = queryResource(id);
ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
if (!vpool.getType().equals(type.name())) {
throw APIException.badRequests.providedVirtualPoolNotCorrectType();
}
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchVirtualPoolWithAllStoragePools(vpool, _dbClient, _coordinator, errorMessage);
_dbClient.updateAndReindexObject(vpool);
StringSet matchedPools = vpool.getMatchedStoragePools();
if (null != matchedPools && !matchedPools.isEmpty()) {
Iterator<String> vpoolItr = matchedPools.iterator();
while (vpoolItr.hasNext()) {
URI poolURI = URI.create(vpoolItr.next());
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolURI);
if (pool == null) {
continue;
}
poolList.getPools().add(toNamedRelatedResource(pool));
}
}
return poolList;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class VirtualPoolService method queryResource.
@Override
protected VirtualPool queryResource(URI id) {
VirtualPool vpool = _permissionsHelper.getObjectById(id, VirtualPool.class);
ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
return vpool;
}
Aggregations