Search in sources :

Example 61 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getExportVolumeForHostPortGroups.

@Asset("exportVolumeForHostPortGroups")
@AssetDependencies({ "virtualArray", "blockVirtualPool", "host", "project" })
public List<AssetOption> getExportVolumeForHostPortGroups(AssetOptionsContext ctx, URI vArrayId, URI vpoolId, URI hostOrClusterId, URI projectId) {
    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 export = findExportGroup(hostOrClusterId, projectId, vArrayId, client);
        StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(vArrayId, (export != null ? export.getId() : null), null, vpoolId, null, true);
        return createPortGroupOptions(portGroups.getStoragePortGroups());
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 62 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getTargetVirtualPoolsForVpool.

@Asset("targetVirtualPool")
@AssetDependencies({ "project", "blockVirtualPool", "virtualPoolChangeOperation", "virtualPoolChangeVolumeWithSourceFilter", "displayJournals" })
public List<AssetOption> getTargetVirtualPoolsForVpool(AssetOptionsContext ctx, URI projectId, URI virtualPoolId, String vpoolChangeOperation, String filteredVolumes, String displayJournals) {
    List<URI> volumeIds = Lists.newArrayList();
    if (filteredVolumes != null && !filteredVolumes.isEmpty()) {
        // Best case we are passed in the volumes selected by the user
        // as comma delimited string so we do not have to load them from
        // the API.
        info("Filtered volumes selected by user: %s", filteredVolumes);
        List<String> parsedVolumeIds = TextUtils.parseCSV(filteredVolumes);
        for (String id : parsedVolumeIds) {
            volumeIds.add(uri(id));
        }
    } else {
        // Worst case we need to get the volumes from the API.
        info("Loading all volumes for vpool: %s", virtualPoolId.toString());
        List<VolumeRestRep> volumes = null;
        if (YES_VALUE.equals(displayJournals)) {
            volumes = listJournalVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
        } else {
            volumes = listSourceVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
        }
        for (VolumeRestRep volume : volumes) {
            volumeIds.add(volume.getId());
        }
    }
    if (CollectionUtils.isNotEmpty(volumeIds)) {
        BulkIdParam input = new BulkIdParam();
        input.setIds(volumeIds);
        List<VirtualPoolChangeRep> vpoolChanges = api(ctx).blockVpools().listVirtualPoolChangeCandidates(virtualPoolId, input);
        return createVpoolChangeOptions(vpoolChangeOperation, vpoolChanges);
    }
    return Collections.emptyList();
}
Also used : BulkIdParam(com.emc.storageos.model.BulkIdParam) VplexVolumeVirtualPoolFilter(com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 63 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getFailoverTarget.

@Asset("failoverTarget")
@AssetDependencies("protectedBlockVolume")
public List<AssetOption> getFailoverTarget(AssetOptionsContext ctx, URI protectedBlockVolume) {
    if (protectedBlockVolume != null) {
        ViPRCoreClient client = api(ctx);
        if (BlockProviderUtils.isType(protectedBlockVolume, VOLUME_TYPE)) {
            debug("getting failoverTargets (protectedBlockVolume=%s)", protectedBlockVolume);
            VolumeRestRep volume = client.blockVolumes().get(protectedBlockVolume);
            ProtectionRestRep protection = volume.getProtection();
            if (protection != null) {
                // RecoverPoint protection
                if (protection.getRpRep() != null && protection.getRpRep().getProtectionSet() != null) {
                    return getRpFailoverTargets(client, volume);
                }
                // VMAX SRDF protection
                if (protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
                    return getSrdfFailoverTargets(client, volume);
                }
            }
        } else if (BlockProviderUtils.isType(protectedBlockVolume, BLOCK_CONSISTENCY_GROUP_TYPE)) {
            debug("getting failoverTargets for consistency group %s", protectedBlockVolume);
            BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(protectedBlockVolume);
            List<VolumeRestRep> srcVolumes = null;
            // Get RP source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
                srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), RecoverPointPersonalityFilter.SOURCE);
            }
            // Get SRDF source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
            }
            if (srcVolumes != null && !srcVolumes.isEmpty()) {
                // Get the first source volume and obtain its target references
                VolumeRestRep srcVolume = srcVolumes.get(0);
                if (cg.getTypes() != null) {
                    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
                    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
                    List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
                    // Process the RP targets
                    if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
                        targets = srcVolume.getProtection().getRpRep().getRpTargets();
                    }
                    // Process the SRDF targets
                    if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                        targets = srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes();
                    }
                    for (VolumeRestRep targetVolume : client.blockVolumes().getByRefs(targets)) {
                        VirtualArrayRestRep virtualArray = virtualArrays.get(targetVolume.getVirtualArray());
                        String label = getMessage(name(virtualArray));
                        targetVolumes.put(stringId(virtualArray), label);
                    }
                    List<AssetOption> options = Lists.newArrayList();
                    for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
                        options.add(new AssetOption(entry.getKey(), entry.getValue()));
                    }
                    AssetOptionsUtils.sortOptionsByLabel(options);
                    return options;
                }
            }
        }
    }
    return Lists.newArrayList();
}
Also used : SRDFSourceFilter(com.emc.vipr.client.core.filters.SRDFSourceFilter) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) Entry(java.util.Map.Entry) CachedResources(com.emc.vipr.client.core.util.CachedResources) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) Map(java.util.Map) HashMap(java.util.HashMap) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 64 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getExportContinousCopyForHostPortGroups.

@Asset("exportContinousCopyForHostPortGroups")
@AssetDependencies({ "volumeWithContinuousCopies", "unassignedBlockContinuousCopies", "host", "project" })
public List<AssetOption> getExportContinousCopyForHostPortGroups(AssetOptionsContext ctx, URI volumeId, String selectedCopies, URI hostOrClusterId, URI projectId) {
    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")) {
        List<URI> snapshotIds = Lists.newArrayList();
        info("Continous Copies selected by user: %s", selectedCopies);
        List<String> parsedCopiesIds = TextUtils.parseCSV(selectedCopies);
        for (String id : parsedCopiesIds) {
            snapshotIds.add(uri(id));
        }
        List<BlockMirrorRestRep> copies = client.blockVolumes().getContinuousCopies(volumeId);
        Set<URI> virtualArrays = new HashSet<URI>();
        Set<URI> storageSystems = new HashSet<URI>();
        Set<URI> virtualPools = new HashSet<URI>();
        for (BlockMirrorRestRep copy : copies) {
            virtualArrays.add(copy.getVirtualArray().getId());
            storageSystems.add(copy.getStorageController());
            virtualPools.add(copy.getVirtualPool().getId());
        }
        if (virtualArrays.size() == 1 && storageSystems.size() == 1 && virtualPools.size() == 1) {
            Iterator<URI> it = virtualArrays.iterator();
            URI varrayId = it.next();
            ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
            Iterator<URI> ssIt = storageSystems.iterator();
            Iterator<URI> vpIt = virtualPools.iterator();
            StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), vpIt.next(), null, true);
            return createPortGroupOptions(portGroups.getStoragePortGroups());
        }
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) URI(java.net.URI) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 65 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getSnapshotBlockVolumes.

@Asset("snapshotBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotBlockVolumes(AssetOptionsContext context, URI project, String storageType) {
    final ViPRCoreClient client = api(context);
    if (isVolumeType(storageType)) {
        List<VolumeRestRep> volumes = listVolumes(client, project);
        List<VolumeDetail> volumeDetails = getVolumeDetails(client, volumes);
        Map<URI, VolumeRestRep> volumeNames = ResourceUtils.mapById(volumes);
        List<AssetOption> options = Lists.newArrayList();
        for (VolumeDetail detail : volumeDetails) {
            if (detail.vpool == null) {
                continue;
            }
            boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
            boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
            boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
            boolean isInConsistencyGroup = BlockProvider.isInConsistencyGroup(detail.volume);
            debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup);
            if (isRPSourceVolume || (localSnapSupported && (!isInConsistencyGroup || isRPTargetVolume))) {
                options.add(createVolumeOption(client, null, detail.volume, volumeNames));
            }
        }
        return options;
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

Asset (com.emc.sa.asset.annotation.Asset)102 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)102 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)66 AssetOption (com.emc.vipr.model.catalog.AssetOption)63 URI (java.net.URI)43 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)35 ArrayList (java.util.ArrayList)22 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)17 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)13 HashSet (java.util.HashSet)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)10 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)10 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)7 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6