Search in sources :

Example 66 with Asset

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

the class BlockProvider method getExportPathVirtualArray.

@Asset("exportPathVirtualArray")
@AssetDependencies({ "exportPathExport", "exportPathStorageSystem" })
public List<AssetOption> getExportPathVirtualArray(AssetOptionsContext ctx, URI exportId, URI storageSystemId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    ExportGroupRestRep export = client.blockExports().get(exportId);
    List<URI> vArrayIds = new ArrayList<URI>();
    vArrayIds.add(export.getVirtualArray().getId());
    List<StringHashMapEntry> altArrays = export.getAltVirtualArrays() != null ? export.getAltVirtualArrays() : new ArrayList<StringHashMapEntry>();
    for (StringHashMapEntry altArray : altArrays) {
        if (altArray.getName().equalsIgnoreCase(storageSystemId.toString())) {
            vArrayIds.add(URI.create(altArray.getValue()));
        }
    }
    List<VirtualArrayRestRep> vArrays = client.varrays().getByIds(vArrayIds);
    for (VirtualArrayRestRep vArray : vArrays) {
        options.add(new AssetOption(vArray.getId(), vArray.getName()));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 67 with Asset

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

the class BlockProvider method getExportPathPorts.

@Asset("exportPathPorts")
@AssetDependencies({ "exportPathVirtualArray", "exportPathStorageSystem", "exportPathExport" })
public List<AssetOption> getExportPathPorts(AssetOptionsContext ctx, URI vArrayId, URI storageSystemId, URI exportId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    // Get all the PGs for the varray/storage system/EG combo then check to
    // see if there are any non-mutable PGs;
    // if there are the storage ports displayed to the user would be limited
    // to just those ones.
    StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(vArrayId, exportId, storageSystemId, null, null, false);
    // Keep a list of ports from the non-mutable PGs. This could remain
    // empty if there are no PGs or none that are non-mutable.
    List<URI> nonMutablePGPortURIs = new ArrayList<URI>();
    if (portGroupsRestRep != null) {
        // Drill down to get the PG and the storage ports
        List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
        if (!CollectionUtils.isEmpty(portGroups)) {
            for (StoragePortGroupRestRep pg : portGroups) {
                // Check to see if the PG is non-mutable
                if (!pg.getMutable()) {
                    // Keep track of these storage ports, they will be used
                    // to filter out
                    // other storage ports.
                    StoragePortList pgPortsList = pg.getStoragePorts();
                    List<NamedRelatedResourceRep> pgPorts = pgPortsList.getPorts();
                    for (NamedRelatedResourceRep pgPort : pgPorts) {
                        nonMutablePGPortURIs.add(pgPort.getId());
                    }
                }
            }
        }
    }
    List<StoragePortRestRep> ports = client.storagePorts().getByVirtualArray(vArrayId);
    for (StoragePortRestRep port : ports) {
        // Check to see if this port needs to be filtered out.
        boolean filterOutPortBasedOnPG = (!nonMutablePGPortURIs.isEmpty()) ? !nonMutablePGPortURIs.contains(port.getId()) : false;
        if (!filterOutPortBasedOnPG) {
            if (port.getPortType().equals(StoragePort.PortType.frontend.toString()) && port.getStorageDevice().getId().equals(storageSystemId) && port.getOperationalStatus().equals(StoragePort.OperationalStatus.OK.toString())) {
                if (port.getNetwork() != null) {
                    String portPercentBusy = (port.getPortPercentBusy() != null) ? String.valueOf(Math.round(port.getPortPercentBusy() * 100 / 100)) + "%" : "N/A";
                    String networkName = client.networks().get(port.getNetwork().getId()).getName();
                    String label = getMessage("exportPathAdjustment.ports", port.getPortName(), networkName, port.getPortNetworkId(), portPercentBusy);
                    options.add(new AssetOption(port.getId(), label));
                }
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) StoragePortList(com.emc.storageos.model.ports.StoragePortList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 68 with Asset

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

the class BlockProvider method getVolumes.

@Asset("blockVolume")
@AssetDependencies("project")
public List<AssetOption> getVolumes(AssetOptionsContext ctx, URI project) {
    debug("getting volumes (project=%s)", project);
    ViPRCoreClient client = api(ctx);
    return createVolumeOptions(client, listVolumes(client, project));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 69 with Asset

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

the class BlockProvider method getCopyNameByConsistencyGroup.

@Asset("journalCopyName")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getCopyNameByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
    ViPRCoreClient client = api(ctx);
    List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
    Set<String> copyNames = Sets.newHashSet();
    if (volumes != null && !volumes.isEmpty()) {
        RelatedResourceRep volume = volumes.get(0);
        VolumeRestRep volumeRep = client.blockVolumes().get(volume);
        if (volumeRep.getProtection() != null && volumeRep.getProtection().getRpRep() != null) {
            if (volumeRep.getProtection().getRpRep().getCopyName() != null) {
                String copyName = volumeRep.getProtection().getRpRep().getCopyName();
                copyNames.add(copyName);
            }
            if (volumeRep.getHaVolumes() != null) {
                List<RelatedResourceRep> haVolumes = volumeRep.getHaVolumes();
                List<URI> haVolumeIds = new ArrayList<URI>();
                for (RelatedResourceRep haVolume : haVolumes) {
                    haVolumeIds.add(haVolume.getId());
                }
                List<VolumeRestRep> haVolumeReps = client.blockVolumes().getByIds(haVolumeIds, null);
                for (VolumeRestRep haVolumeRep : haVolumeReps) {
                    if (haVolumeRep.getProtection() != null && haVolumeRep.getProtection().getRpRep() != null && haVolumeRep.getProtection().getRpRep().getCopyName() != null) {
                        String copyName = haVolumeRep.getProtection().getRpRep().getCopyName();
                        copyNames.add(copyName);
                    }
                }
            }
            if (volumeRep.getProtection().getRpRep().getRpTargets() != null) {
                List<VirtualArrayRelatedResourceRep> targetVolumes = volumeRep.getProtection().getRpRep().getRpTargets();
                List<URI> targetVolumeIds = new ArrayList<URI>();
                for (VirtualArrayRelatedResourceRep targetVolume : targetVolumes) {
                    targetVolumeIds.add(targetVolume.getId());
                }
                List<VolumeRestRep> targetVolumeReps = client.blockVolumes().getByIds(targetVolumeIds, null);
                for (VolumeRestRep targetVolumeRep : targetVolumeReps) {
                    String copyName = targetVolumeRep.getProtection().getRpRep().getCopyName();
                    copyNames.add(copyName);
                }
            }
        }
    }
    List<AssetOption> copyNameAssets = Lists.newArrayList();
    for (String copyName : copyNames) {
        copyNameAssets.add(newAssetOption(copyName, copyName));
    }
    AssetOptionsUtils.sortOptionsByLabel(copyNameAssets);
    return copyNameAssets;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 70 with Asset

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

the class BlockProvider method getAffectedExports.

@Asset("exportPathAffectedExports")
@AssetDependencies({ "host", "exportPathVirtualArray", "exportPathExport", "exportPathMinPathsOptions", "exportPathMaxPathsOptions", "exportPathPathsPerInitiatorOptions", "exportPathExistingPath", "exportPathStorageSystem", "exportPathPorts" })
public List<AssetOption> getAffectedExports(AssetOptionsContext ctx, URI hostOrClusterId, URI vArrayId, URI exportId, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, String useExisting, URI storageSystemId, String ports) {
    ViPRCoreClient client = api(ctx);
    // the asset option list
    List<AssetOption> options = Lists.newArrayList();
    List<URI> exportPathPorts = parseExportPathPorts(ports);
    ExportPathsAdjustmentPreviewRestRep portPreview = generateExportPathPreview(ctx, hostOrClusterId, vArrayId, exportId, minPaths, maxPaths, pathsPerInitiator, useExisting, storageSystemId, exportPathPorts);
    List<NamedRelatedResourceRep> affectedList = portPreview.getAffectedExportGroups();
    List<URI> exportIds = new ArrayList<URI>();
    for (NamedRelatedResourceRep affected : affectedList) {
        exportIds.add(affected.getId());
    }
    List<ExportGroupRestRep> exports = client.blockExports().getByIds(exportIds);
    for (ExportGroupRestRep export : exports) {
        // TODO: need to optimize the way that we retrieve the project name.
        String projectName = client.projects().get(export.getProject().getId()).getName();
        String label = getMessage("exportPathAdjustment.affectedExports", projectName, export.getName());
        options.add(new AssetOption(export.getName(), label));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ExportPathsAdjustmentPreviewRestRep(com.emc.storageos.model.block.export.ExportPathsAdjustmentPreviewRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) 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)119 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)102 AssetOption (com.emc.vipr.model.catalog.AssetOption)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)72 URI (java.net.URI)47 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)35 ArrayList (java.util.ArrayList)23 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)17 HashSet (java.util.HashSet)15 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)13 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)8 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)8 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6