Search in sources :

Example 56 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BaseHostProvider method createHostOptions.

protected List<AssetOption> createHostOptions(AssetOptionsContext ctx, Collection<HostRestRep> hosts, Map<URI, String> clusters) {
    List<AssetOption> options = Lists.newArrayList();
    for (HostRestRep value : hosts) {
        options.add(createHostOption(ctx, value, clusters));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption)

Example 57 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BlockProvider method getBlockSnapshotType.

@Asset("blockSnapshotType")
@AssetDependencies({ "blockVolumeOrConsistencyType", "snapshotBlockVolume" })
public List<AssetOption> getBlockSnapshotType(AssetOptionsContext ctx, String storageType, URI blockVolumeOrCG) {
    // These are hard coded values for now. In the future, this may be available through an API
    List<AssetOption> options = Lists.newArrayList();
    if (isConsistencyGroupType(blockVolumeOrCG)) {
        options.add(CG_SNAPSHOT_TYPE_OPTION);
        // Only add cg session option if the CG selected supports it
        ViPRCoreClient client = api(ctx);
        BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(blockVolumeOrCG);
        if (isSnapshotSessionSupportedForCG(cg)) {
            options.add(CG_SNAPSHOT_SESSION_TYPE_OPTION);
        }
    } else {
        debug("getting blockSnapshotTypes (blockVolume=%s)", blockVolumeOrCG);
        ViPRCoreClient client = api(ctx);
        VolumeRestRep volume = client.blockVolumes().get(blockVolumeOrCG);
        BlockVirtualPoolRestRep virtualPool = client.blockVpools().get(volume.getVirtualPool());
        if (isLocalSnapshotSupported(virtualPool)) {
            options.add(LOCAL_ARRAY_SNAPSHOT_TYPE_OPTION);
        }
        if (isRPSourceVolume(volume)) {
            options.add(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_OPTION);
        }
        if (isSnapshotSessionSupportedForVolume(volume)) {
            options.add(SNAPSHOT_SESSION_TYPE_OPTION);
        }
    }
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 58 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BlockProvider method getSnapshotSessionBlockVolumes.

@Asset("snapshotSessionBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotSessionBlockVolumes(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) {
            boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
            boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
            boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
            boolean isInConsistencyGroup = !StringUtils.isEmpty(detail.volume.getReplicationGroupInstance());
            boolean isSnapshotSessionSupported = isSnapshotSessionSupportedForVolume(detail.volume);
            debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s, isXio3XVolume=%s ]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup, isSnapshotSessionSupported);
            if (isSnapshotSessionSupported && localSnapSupported && !isInConsistencyGroup) {
                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)

Example 59 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption 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 60 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption 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)

Aggregations

AssetOption (com.emc.vipr.model.catalog.AssetOption)107 Asset (com.emc.sa.asset.annotation.Asset)74 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)63 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)41 URI (java.net.URI)36 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)20 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)14 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)14 ArrayList (java.util.ArrayList)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)10 Map (java.util.Map)9 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)8 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)8 HashMap (java.util.HashMap)8 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)6 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)6 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5