Search in sources :

Example 96 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class VMWareProvider method getUnassignedDatastores.

@Asset("unassignedBlockDatastore")
@AssetDependencies({ "esxHost", "project" })
public List<AssetOption> getUnassignedDatastores(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId) {
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(api(ctx), projectId, hostOrClusterId, null);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
    return createBlockVolumeDatastoreOptions(volumes, hostOrClusterId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) UnexportedBlockResourceFilter(com.emc.sa.asset.providers.BlockProvider.UnexportedBlockResourceFilter) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 97 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient 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 98 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class VirtualArrayProvider method getFileVirtualArrays.

@Asset("fileVirtualArray")
public List<AssetOption> getFileVirtualArrays(AssetOptionsContext context) {
    ViPRCoreClient client = api(context);
    // Get the set of virtual arrays that are associated with file vpools
    Set<URI> varrayIds = new HashSet<>();
    for (FileVirtualPoolRestRep vpool : client.fileVpools().getByTenant(context.getTenant())) {
        varrayIds.addAll(ResourceUtils.refIds(vpool.getVirtualArrays()));
    }
    filterByContextTenant(varrayIds, client.varrays().getByTenant(context.getTenant()));
    return createBaseResourceOptions(client.varrays().getByIds(varrayIds));
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) URI(java.net.URI) HashSet(java.util.HashSet) Asset(com.emc.sa.asset.annotation.Asset)

Example 99 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient 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 100 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class VirtualDataCenterProvider method getUnexportedIngestionMethod.

@Asset("unexportedIngestionMethod")
@AssetDependencies({ "unmanagedBlockStorageSystem" })
public List<AssetOption> getUnexportedIngestionMethod(AssetOptionsContext ctx, URI storageSystemId) {
    ViPRCoreClient client = api(ctx);
    StorageSystemRestRep storageSystemRestRep = client.storageSystems().get(storageSystemId);
    List<AssetOption> options = Lists.newArrayList();
    options.add(newAssetOption(IngestionMethodEnum.FULL.toString(), "unmanagedVolume.ingestMethod.full"));
    if (BlockProviderUtils.isVplex(storageSystemRestRep)) {
        options.add(newAssetOption(IngestionMethodEnum.VIRTUAL_VOLUMES_ONLY.toString(), "unmanagedVolume.ingestMethod.virtualVolumesOnly"));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)225 Asset (com.emc.sa.asset.annotation.Asset)72 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)66 URI (java.net.URI)66 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)49 FlashException (controllers.util.FlashException)48 AssetOption (com.emc.vipr.model.catalog.AssetOption)41 ArrayList (java.util.ArrayList)34 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)29 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)27 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)24 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)20 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)15 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)15 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)13 HashSet (java.util.HashSet)13 Task (com.emc.vipr.client.Task)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8