use of com.emc.storageos.model.block.UnManagedVolumeList in project coprhd-controller by CoprHD.
the class HostService method getUnmanagedVolumes.
/**
* Gets the UnManagedVolumes exposed to a Host.
*
* @param id
* the URI of a ViPR Host
* @brief List unmanaged volumes exposed to a host
* @return a list of UnManagedVolumes exposed to this host
* @throws DatabaseException
* when a database error occurs
*/
@GET
@Path("/{id}/unmanaged-volumes")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UnManagedVolumeList getUnmanagedVolumes(@PathParam("id") URI id) throws DatabaseException {
Host host = queryObject(Host.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(host.getTenant(), getUserFromContext());
// get the unmanaged volumes
List<UnManagedVolume> unmanagedVolumes = VolumeIngestionUtil.findUnManagedVolumesForHost(id, _dbClient, _coordinator);
UnManagedVolumeList list = new UnManagedVolumeList();
for (UnManagedVolume volume : unmanagedVolumes) {
list.getUnManagedVolumes().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, volume.getId()));
}
return list;
}
use of com.emc.storageos.model.block.UnManagedVolumeList in project coprhd-controller by CoprHD.
the class ClusterService method getUnmanagedVolumes.
/**
* Gets the UnManagedVolumes exposed to a Cluster.
*
* @param id the URI of a ViPR Cluster
* @brief List unmanaged volumes exposed to a cluster
* @return a list of UnManagedVolumes exposed to this host
* @throws DatabaseException when a database error occurs
*/
@GET
@Path("/{id}/unmanaged-volumes")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UnManagedVolumeList getUnmanagedVolumes(@PathParam("id") URI id) throws DatabaseException {
Cluster cluster = queryObject(Cluster.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
// get the unmanaged volumes
List<UnManagedVolume> unmanagedVolumes = VolumeIngestionUtil.findUnManagedVolumesForCluster(id, _dbClient);
UnManagedVolumeList list = new UnManagedVolumeList();
for (UnManagedVolume volume : unmanagedVolumes) {
list.getUnManagedVolumes().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, volume.getId()));
}
return list;
}
use of com.emc.storageos.model.block.UnManagedVolumeList in project coprhd-controller by CoprHD.
the class StorageSystemService method getUnManagedVPoolVolumes.
/**
* List all unmanaged volumes that are available for a storage system &
* given vpool.
*
* Unmanaged volumes refers to volumes which are available within underlying
* storage systems, but still not managed in ViPR. As these volumes are not
* managed in ViPR, there will not be any ViPR specific details associated
* such as, virtual array, virtual pool, or project.
*
* @param id
* the URN of a ViPR storage system
* @prereq none
* @param vPoolId
* the URN of the Virtual Pool
* @param exportType
* Specifies the type of UnManaged Volume.
* @brief List of all unmanaged volumes available for a storage system & vpool
* @return UnManagedVolumeList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/unmanaged/{vpoolid}/volumes")
public UnManagedVolumeList getUnManagedVPoolVolumes(@PathParam("id") URI id, @PathParam("vpoolid") URI vPoolId, @QueryParam("exportType") String exportType) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
ArgValidator.checkFieldUriType(vPoolId, VirtualPool.class, "id");
if (exportType == null || exportType.trim().length() < 1) {
exportType = ExportType.UNEXPORTED.name();
}
if (ExportType.lookup(exportType) == null) {
throw APIException.badRequests.invalidParameterForUnManagedVolumeQuery(exportType);
}
String isExportedSelected = exportType.equalsIgnoreCase(ExportType.EXPORTED.name()) ? TRUE_STR : FALSE_STR;
StorageSystem system = _dbClient.queryObject(StorageSystem.class, id);
boolean isVplexSystem = ConnectivityUtil.isAVPlex(system);
Map<String, UnManagedVolume> vplexParentVolumeCache = isVplexSystem ? new HashMap<String, UnManagedVolume>() : null;
UnManagedVolumeList unManagedVolumeList = new UnManagedVolumeList();
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedVolumeSupportedVPoolConstraint(vPoolId.toString()), result);
Iterator<UnManagedVolume> unmanagedVolumeItr = _dbClient.queryIterativeObjects(UnManagedVolume.class, result, true);
while (unmanagedVolumeItr.hasNext()) {
UnManagedVolume umv = unmanagedVolumeItr.next();
String umvExportStatus = umv.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString());
// checking the IS_VOLUME_EXPORTED flag instead.
if (umvExportStatus == null) {
umvExportStatus = umv.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString());
}
boolean exportStatusMatch = (null != umvExportStatus) && umvExportStatus.equalsIgnoreCase(isExportedSelected);
boolean systemMatch = umv.getStorageSystemUri().equals(id);
// allow backend snapshots for vplex vpool ingestion - must check parent virtual volume for system match
boolean isVplexSnapshot = false;
if (exportStatusMatch && isVplexSystem && VolumeIngestionUtil.isSnapshot(umv)) {
UnManagedVolume vplexParentVolume = VolumeIngestionUtil.findVplexParentVolume(umv, _dbClient, vplexParentVolumeCache);
if (vplexParentVolume != null && vplexParentVolume.getStorageSystemUri().equals(id)) {
isVplexSnapshot = true;
}
}
if (exportStatusMatch && (systemMatch || isVplexSnapshot)) {
String name = (null == umv.getLabel()) ? umv.getNativeGuid() : umv.getLabel();
unManagedVolumeList.getNamedUnManagedVolumes().add(toNamedRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, umv.getId(), name));
} else {
_log.debug("Ignoring unmanaged volume: {}", umv.getNativeGuid());
}
}
return unManagedVolumeList;
}
use of com.emc.storageos.model.block.UnManagedVolumeList in project coprhd-controller by CoprHD.
the class StorageSystemService method getUnManagedVolumes.
/**
* List all unmanaged volumes that are available for a storage system.Unmanaged volumes refers to volumes which are available within
* underlying storage systems , but
* still not managed in ViPR.
* As these volumes are not managed in ViPR, there will not be any ViPR specific
* details associated such as, virtual array, virtual pool, or project.
*
* @param id the URN of a ViPR storage system
* @prereq none
* @brief List of all unmanaged volumes available for a storage system
* @return UnManagedVolumeList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/unmanaged/volumes")
public UnManagedVolumeList getUnManagedVolumes(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
UnManagedVolumeList unManagedVolumeList = new UnManagedVolumeList();
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceUnManagedVolumeConstraint(id), result);
while (result.iterator().hasNext()) {
URI unManagedVolumeUri = result.iterator().next();
unManagedVolumeList.getUnManagedVolumes().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, unManagedVolumeUri));
}
return unManagedVolumeList;
}
Aggregations