use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportedVolumes.
/**
* Gets the set of volume IDs for volumes in the given project that are exported to the given host/cluster
*
* @param client An instance of the ViPRCoreClient
* @param projectId The ViPR ID of the project
* @param hostOrClusterId The ViPR ID of the host/cluster
*
* @return The set of Volume IDs
*/
protected static Set<URI> getExportedVolumes(ViPRCoreClient client, URI projectId, URI hostOrClusterId, URI virtualArrayId) {
// determine host and cluster id
URI hostId = BlockStorageUtils.isHost(hostOrClusterId) ? hostOrClusterId : null;
URI clusterId = BlockStorageUtils.isCluster(hostOrClusterId) ? hostOrClusterId : null;
// get a list of all the exports in this project that expose resources to this host/cluster
ResourceFilter<ExportGroupRestRep> filter;
if (virtualArrayId == null) {
filter = new ExportHostOrClusterFilter(hostId, clusterId);
} else {
filter = new ExportHostOrClusterFilter(hostId, clusterId).and(new ExportVirtualArrayFilter(virtualArrayId));
}
List<ExportGroupRestRep> exports = client.blockExports().findByProject(projectId, filter);
return getBlockVolumeIdsForExports(exports);
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportedBlockContinuousCopyByVolume.
@Asset("exportedBlockContinuousCopy")
@AssetDependencies({ "project", "volumeWithContinuousCopies" })
public List<AssetOption> getExportedBlockContinuousCopyByVolume(AssetOptionsContext ctx, URI project, URI volume) {
debug("getting exported blockContinuousCopy (project=%s) (parent=%s)", project, volume);
final ViPRCoreClient client = api(ctx);
Set<URI> exportedMirrors = new HashSet<URI>();
for (ExportGroupRestRep export : client.blockExports().findByProject(project)) {
for (ExportBlockParam resource : export.getVolumes()) {
if (ResourceType.isType(ResourceType.BLOCK_CONTINUOUS_COPY, resource.getId())) {
exportedMirrors.add(resource.getId());
}
}
}
ExportedBlockResourceFilter<BlockMirrorRestRep> exportedMirrorFilter = new ExportedBlockResourceFilter<BlockMirrorRestRep>(exportedMirrors);
List<BlockMirrorRestRep> mirrors = client.blockVolumes().getContinuousCopies(volume, exportedMirrorFilter);
return createVolumeOptions(client, mirrors);
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getCurrentExportPortGroups.
@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI varrayId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
ExportGroupRestRep exportGroup = client.blockExports().get(exportId);
List<StoragePortGroupRestRep> storagePortGroups = new ArrayList<StoragePortGroupRestRep>();
List<ExportBlockParam> blockParams = exportGroup.getVolumes();
Set<URI> storageSystemURISet = new HashSet<URI>();
if (!CollectionUtils.isEmpty(blockParams)) {
for (ExportBlockParam blockParam : blockParams) {
// Get each volume in the export group to get the storage system ID
if (blockParam != null) {
URI resourceId = blockParam.getId();
URI storageDeviceURI = null;
if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
VolumeRestRep volume = client.blockVolumes().get(resourceId);
storageDeviceURI = volume.getStorageController();
} else if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resourceId)) {
BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
storageDeviceURI = snapshot.getStorageController();
}
if (storageDeviceURI != null) {
storageSystemURISet.add(storageDeviceURI);
}
} else {
log.error("Block param not found in export group: {}", exportId);
}
}
}
if (!CollectionUtils.isEmpty(storageSystemURISet)) {
Set<URI> portGroupSet = new HashSet<URI>();
for (URI storageSystemURI : storageSystemURISet) {
// Now use the storage system ID as well to query the storage port groups
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemURI, null, null, false);
List<StoragePortGroupRestRep> portGroupList = portGroups.getStoragePortGroups();
if (!CollectionUtils.isEmpty(portGroupList)) {
for (StoragePortGroupRestRep portGroup : portGroupList) {
if (portGroupSet.add(portGroup.getId())) {
storagePortGroups.add(portGroup);
}
}
}
}
}
return createPortGroupOptions(storagePortGroups);
}
return options;
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPathExports.
@Asset("exportPathExport")
@AssetDependencies({ "project", "host" })
public List<AssetOption> getExportPathExports(AssetOptionsContext ctx, URI projectId, URI hostOrClusterId) {
ViPRCoreClient client = api(ctx);
List<ExportGroupRestRep> exports = findExportGroups(hostOrClusterId, projectId, null, client);
return createExportWithVarrayOptions(client, exports);
}
use of com.emc.storageos.model.block.export.ExportGroupRestRep in project coprhd-controller by CoprHD.
the class BlockStorageUtils method removeExportIfEmpty.
public static void removeExportIfEmpty(URI exportId) {
boolean retryNeeded = false;
int retryCount = 0;
do {
retryNeeded = false;
ExportGroupRestRep export = getExport(exportId);
if (ResourceUtils.isActive(export) && export.getVolumes().isEmpty()) {
try {
log.info(String.format("Attampting deletion of ExportGroup %s (%s)", export.getGeneratedName(), export.getId()));
Task<ExportGroupRestRep> response = execute(new DeactivateBlockExport(exportId));
addAffectedResource(response);
} catch (ExecutionException e) {
if (e.getCause() instanceof ServiceErrorException) {
ServiceErrorException svcexp = (ServiceErrorException) e.getCause();
if (retryCount++ < MAX_RETRY_COUNT && ServiceCode.toServiceCode(svcexp.getCode()) == ServiceCode.API_TASK_EXECUTION_IN_PROGRESS) {
log.info(String.format("ExportGroup %s deletion waiting on pending task execution", export.getId()));
retryNeeded = true;
try {
Thread.sleep(RETRY_DELAY_MSEC);
} catch (InterruptedException ex) {
log.debug("Sleep interrupted");
}
} else {
throw e;
}
}
}
}
} while (retryNeeded);
}
Aggregations