Search in sources :

Example 31 with AssetOption

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

the class VMWareProvider method createDatastoreOptions.

protected static List<AssetOption> createDatastoreOptions(List<? extends BlockObjectRestRep> mountedVolumes, URI hostId) {
    // There can be multiple volumes to a DS, so de-dupe in a hash map
    Map<String, List<String>> datastores = Maps.newHashMap();
    for (BlockObjectRestRep volume : mountedVolumes) {
        String key = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
        List<String> values = Lists.newArrayList();
        if (datastores.containsKey(key)) {
            values = datastores.get(key);
        }
        values.add(volume.getWwn());
        datastores.put(key, values);
    }
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<String, List<String>> datastore : datastores.entrySet()) {
        options.add(new AssetOption(datastore.getKey(), getMessage("datastore.label", datastore.getKey(), String.join(",", datastore.getValue()))));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) List(java.util.List) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) Map(java.util.Map)

Example 32 with AssetOption

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

the class VMWareProvider method createBlockVolumeDatastoreOptions.

protected static List<AssetOption> createBlockVolumeDatastoreOptions(List<? extends BlockObjectRestRep> mountedVolumes, URI hostId) {
    List<AssetOption> options = Lists.newArrayList();
    for (BlockObjectRestRep volume : mountedVolumes) {
        Set<String> datastoreNames = VMwareDatastoreTagger.getDatastoreNames(volume);
        String datastoresLabel = datastoreNames.isEmpty() ? "N/A" : StringUtils.join(datastoreNames, ",");
        options.add(newAssetOption(volume.getId(), "volume.hlu.datastore", volume.getName(), datastoresLabel, volume.getWwn()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 33 with AssetOption

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

the class VcenterClusterProvider method getClusterOptions.

@Asset("vcenterCluster")
public List<AssetOption> getClusterOptions(AssetOptionsContext ctx) {
    debug("getting clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    Map<URI, String> vcenterMap = getVcenters(ctx);
    Map<URI, String> dataCenterNameMap = new HashMap<URI, String>();
    Map<URI, String> dataCenterVcenterMap = new HashMap<URI, String>();
    String vcenterName;
    String datacenterName;
    for (ClusterRestRep value : clusters) {
        if (value.getVcenterDataCenter() != null) {
            RelatedResourceRep datacenterVal = value.getVcenterDataCenter();
            if (datacenterVal != null) {
                if (dataCenterVcenterMap.get(datacenterVal.getId()) == null) {
                    VcenterDataCenterRestRep restResponse = api(ctx).vcenterDataCenters().get(datacenterVal.getId());
                    datacenterName = restResponse.getName();
                    dataCenterNameMap.put(datacenterVal.getId(), datacenterName);
                    RelatedResourceRep vcenterResp = restResponse.getVcenter();
                    if (vcenterMap.get(vcenterResp.getId()) == null) {
                        VcenterRestRep vcenterRep = api(ctx).vcenters().get(vcenterResp);
                        vcenterMap.put(vcenterResp.getId(), vcenterRep.getName());
                        vcenterName = vcenterRep.getName();
                        dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
                    } else {
                        vcenterName = vcenterMap.get(vcenterResp.getId());
                        dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
                    }
                } else {
                    datacenterName = dataCenterNameMap.get(datacenterVal.getId());
                    vcenterName = dataCenterVcenterMap.get(datacenterVal.getId());
                }
                options.add(createClusterOption(ctx, value, true, vcenterName, datacenterName));
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) HashMap(java.util.HashMap) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep) URI(java.net.URI) Asset(com.emc.sa.asset.annotation.Asset)

Example 34 with AssetOption

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

the class VcenterClusterProvider method getNewClusterOptions.

@Asset("newVcenterCluster")
public List<AssetOption> getNewClusterOptions(AssetOptionsContext ctx) {
    debug("getting clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (ClusterRestRep value : clusters) {
        if (value.getVcenterDataCenter() == null) {
            options.add(createClusterOption(ctx, value, false, "", ""));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

Example 35 with AssetOption

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

the class VirtualArrayProvider method getVirtualArray.

@Asset("virtualArray")
@AssetDependencies({ "host" })
public List<AssetOption> getVirtualArray(AssetOptionsContext context, URI hostOrClusterId) {
    ViPRCoreClient client = api(context);
    List<URI> hostIds = HostProvider.getHostIds(client, hostOrClusterId);
    Map<URI, VirtualArrayRestRep> virtualArrays = null;
    Map<URI, VirtualArrayRestRep> allVirtualArrays = Maps.newHashMap();
    for (URI hostId : hostIds) {
        Map<URI, VirtualArrayRestRep> connectedVirtualArrays = ResourceUtils.mapById(client.varrays().findByConnectedHost(hostId));
        if (virtualArrays == null) {
            virtualArrays = connectedVirtualArrays;
        } else {
            virtualArrays.keySet().retainAll(connectedVirtualArrays.keySet());
        }
        allVirtualArrays.putAll(connectedVirtualArrays);
    }
    // Creates options for the virtual arrays, showing an indication whether the virtual array is only
    // partially connected to the cluster
    List<AssetOption> fullyConnectedOptions = new ArrayList<>();
    List<AssetOption> partiallyConnectedOptions = new ArrayList<>();
    List<VirtualArrayRestRep> varraysByTenant = client.varrays().getByTenant(context.getTenant());
    for (VirtualArrayRestRep varray : allVirtualArrays.values()) {
        if (!contains(varray.getId(), varraysByTenant)) {
            continue;
        }
        boolean fullyConnected = virtualArrays.containsKey(varray.getId());
        if (fullyConnected) {
            fullyConnectedOptions.add(new AssetOption(varray.getId(), varray.getName()));
        } else {
            String label = getMessage("virtualArray.partiallyConnected", varray.getName());
            partiallyConnectedOptions.add(new AssetOption(varray.getId(), label));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(fullyConnectedOptions);
    AssetOptionsUtils.sortOptionsByLabel(partiallyConnectedOptions);
    // Place the fully connected options first
    List<AssetOption> options = new ArrayList<>();
    options.addAll(fullyConnectedOptions);
    options.addAll(partiallyConnectedOptions);
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) 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