use of com.emc.storageos.model.vpool.VirtualPoolChangeList in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method getVirtualPoolForVirtualPoolChange.
/**
* Returns all potential virtual pools, which supported the given virtual pool change operation
* for a virtual pool change of the volumes specified in the request
*
* @prereq none
*
* @param param
*
* @brief Show potential virtual pools
* @return A VirtualPoolChangeList that identifies each potential virtual
* pool, whether or not a change is allowed for the virtual pool,
* and if not, the reason why.
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/vpool-change/vpool")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public VirtualPoolChangeList getVirtualPoolForVirtualPoolChange(@PathParam("id") URI id, BulkIdParam param) {
VirtualPool vpool = getVirtualPool(VirtualPool.Type.block, id);
ArgValidator.checkFieldNotEmpty(param.getIds(), "volume_id");
// We only need one volume from the current vpool to determine
// which other vpools we can move to.
Volume volume = _dbClient.queryObject(Volume.class, param.getIds().get(0));
VirtualPoolChangeList virtualPoolChangeList = new VirtualPoolChangeList();
if (volume != null) {
if (!volume.getVirtualPool().equals(id)) {
throw APIException.badRequests.volumeNotInVirtualPool(volume.getLabel(), vpool.getLabel());
}
// Get the block service implementation for this volume.
BlockServiceApi blockServiceApi = BlockService.getBlockServiceImpl(volume, _dbClient);
_log.info("Got BlockServiceApi for volume, now checking for vpool change candidates...");
// Return the list of candidate VirtualPools for a VirtualPool change for this volume.
VirtualPoolChangeList volumeVirturalPoolChangeList = blockServiceApi.getVirtualPoolForVirtualPoolChange(volume);
virtualPoolChangeList.getVirtualPools().addAll(volumeVirturalPoolChangeList.getVirtualPools());
}
return virtualPoolChangeList;
}
use of com.emc.storageos.model.vpool.VirtualPoolChangeList in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl method getVirtualPoolChangeListForVolume.
/**
* Gets all potential vpools to to which the vpool for the passed volume can be
* changed.
*
* @param volume
* A reference to the volume.
*
* @return A VirtualPoolChangeList specifying each vpool to which the volume's
* vpool could potentially be changed and whether or not the change would
* be allowed for that vpool.
*/
protected VirtualPoolChangeList getVirtualPoolChangeListForVolume(Volume volume) {
// Get all potential vpools for this volume based on system
// connectivity of the volume's storage system. For each
// vpool determine if a vpool change to that vpool would be
// allowed for the volume.
VirtualPoolChangeList vpoolChangeList = new VirtualPoolChangeList();
VirtualPool currentVpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
Collection<VirtualPool> allVpools = getVPoolsForVolumeBasedOnSystemConnectivity(volume);
Iterator<VirtualPool> vpoolIter = allVpools.iterator();
StringBuffer logMsg = new StringBuffer();
logMsg.append("Analyzing vpools for change vpool operations:\n");
while (vpoolIter.hasNext()) {
StringBuffer notAllowedReason = new StringBuffer();
VirtualPool targetVpool = vpoolIter.next();
List<VirtualPoolChangeOperationEnum> allowedOperations = getVirtualPoolChangeAllowedOperationsForVolume(volume, currentVpool, targetVpool, notAllowedReason);
logMsg.append("\tVpool [" + targetVpool.getLabel() + "]");
logMsg.append((notAllowedReason.length() > 0) ? " not allowed: " + notAllowedReason.toString() : " allowed but only for: ");
logMsg.append((allowedOperations != null && !allowedOperations.isEmpty()) ? Joiner.on("\t").join(allowedOperations) : "");
logMsg.append("\n");
vpoolChangeList.getVirtualPools().add(toVirtualPoolChangeRep(targetVpool, allowedOperations, notAllowedReason.toString()));
}
s_logger.info(logMsg.toString());
return vpoolChangeList;
}
Aggregations