Search in sources :

Example 6 with VirtualArrayRestRep

use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationVirtualArrays.

@Asset("applicationVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
    final ViPRCoreClient client = api(ctx);
    List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
    List<AssetOption> options = new ArrayList<AssetOption>();
    boolean isRP = false;
    URI sourceVarrayId = null;
    List<VolumeRestRep> allRPSourceVols = null;
    if (volList != null && !volList.isEmpty()) {
        VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
        if (BlockProviderUtils.isVolumeRP(vol)) {
            isRP = true;
            allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
            if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
                VolumeRestRep rpvol = allRPSourceVols.get(0);
                sourceVarrayId = rpvol.getVirtualArray().getId();
            }
        }
    } else {
        options.add(newAssetOption(URI.create("none"), "None"));
        return options;
    }
    // if the volumes are RP (vplex or not) add the RP targets as options
    if (isRP) {
        options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
        Set<URI> targetVarrayIds = new HashSet<URI>();
        List<AssetOption> targetOptions = new ArrayList<AssetOption>();
        List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
        for (VolumeRestRep targetVol : allRPTargetVols) {
            targetVarrayIds.add(targetVol.getVirtualArray().getId());
        }
        List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
        for (VirtualArrayRestRep targetVarray : targetVarrays) {
            targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
        }
        // sort the targets
        AssetOptionsUtils.sortOptionsByLabel(targetOptions);
        options.addAll(targetOptions);
    }
    if (options.isEmpty()) {
        options.add(newAssetOption(URI.create("none"), "None"));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with VirtualArrayRestRep

use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.

the class VirtualArrayProvider method getTargetVirtualArrays.

@Asset("fileTargetVirtualArray")
@AssetDependencies({ "fileFilePolicy", "unprotectedFilesystem" })
public List<AssetOption> getTargetVirtualArrays(AssetOptionsContext context, URI filePolicy, URI fsId) {
    ViPRCoreClient client = api(context);
    FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
    if (policyRest.getType().equals("file_snapshot")) {
        VirtualArrayRestRep vArray = null;
        List<AssetOption> options = Lists.newArrayList();
        FileShareRestRep fsObj = client.fileSystems().get(fsId);
        if (fsObj != null) {
            vArray = client.varrays().get(fsObj.getVirtualArray().getId());
            options.add(createBaseResourceOption(vArray));
        }
        return options;
    } else {
        return getFileVirtualArrays(context);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 8 with VirtualArrayRestRep

use of com.emc.storageos.model.varray.VirtualArrayRestRep 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)

Example 9 with VirtualArrayRestRep

use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method createVolumeWithVarrayOptions.

protected static List<AssetOption> createVolumeWithVarrayOptions(ViPRCoreClient client, Collection<? extends BlockObjectRestRep> blockObjects) {
    List<URI> varrayIds = getVirtualArrayIds(blockObjects);
    Map<URI, VirtualArrayRestRep> varrayNames = getVirutalArrayNames(client, varrayIds);
    List<AssetOption> options = Lists.newArrayList();
    for (BlockObjectRestRep blockObject : blockObjects) {
        options.add(createVolumeWithVarrayOption(blockObject, varrayNames));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 10 with VirtualArrayRestRep

use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.

the class FindVirtualArrayInitiators method executeTask.

@Override
public Set<Initiator> executeTask() throws Exception {
    IdFilter<VirtualArrayRestRep> filter = new IdFilter<VirtualArrayRestRep>(varray);
    Set<Initiator> results = Sets.newHashSet();
    for (Initiator initiator : initiators) {
        String initiatorPort = initiator.getInitiatorPort();
        List<VirtualArrayRestRep> virtualArrays = getClient().varrays().findByInitiatorPort(initiatorPort, filter);
        // Filter will only return the virtual array we are searching for
        if (!virtualArrays.isEmpty()) {
            results.add(initiator);
        }
    }
    return results;
}
Also used : IdFilter(com.emc.vipr.client.core.filters.IdFilter) Initiator(com.emc.storageos.db.client.model.Initiator) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep)

Aggregations

VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)56 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)15 URI (java.net.URI)15 AssetOption (com.emc.vipr.model.catalog.AssetOption)14 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 ArrayList (java.util.ArrayList)10 FlashException (controllers.util.FlashException)9 HashSet (java.util.HashSet)8 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)6 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)6 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)5 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)4 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)4 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)4 HashMap (java.util.HashMap)4 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)3