Search in sources :

Example 1 with SimpleValueRep

use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.

the class CustomConfigService method getCustomConfigTypeValue.

/**
 * Get the custom config value set in ViPR. This is valid for simple value config type only
 *
 * @brief Show config type details
 * @return The config type data.
 */
@GET
@Path("/types/{config_name}/value")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public SimpleValueRep getCustomConfigTypeValue(@PathParam("config_name") String configName, @QueryParam("scope") String scope) {
    ArgValidator.checkFieldNotEmpty(configName, "configName");
    CustomConfigType item = customConfigHandler.getCustomConfigType(configName);
    if (item != null && !SIMPLE_VALUE_TYPE.equals(item.getConfigType())) {
        throw APIException.badRequests.invalidConfigValueType(configName);
    }
    SimpleValueRep result = new SimpleValueRep();
    if (item != null) {
        String value = customConfigHandler.getComputedCustomConfigValue(configName, scope, null);
        result.setValue(value);
    } else {
        log.info(String.format("Invalid config type for %s", configName));
        throw APIException.badRequests.invalidConfigType(configName);
    }
    return result;
}
Also used : CustomConfigType(com.emc.storageos.customconfigcontroller.CustomConfigType) SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with SimpleValueRep

use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.

the class BlockProvider method getCurrentExportPortGroups.

@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI varrayId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        ExportGroupRestRep exportGroup = client.blockExports().get(exportId);
        List<StoragePortGroupRestRep> storagePortGroups = new ArrayList<StoragePortGroupRestRep>();
        List<ExportBlockParam> blockParams = exportGroup.getVolumes();
        Set<URI> storageSystemURISet = new HashSet<URI>();
        if (!CollectionUtils.isEmpty(blockParams)) {
            for (ExportBlockParam blockParam : blockParams) {
                // Get each volume in the export group to get the storage system ID
                if (blockParam != null) {
                    URI resourceId = blockParam.getId();
                    URI storageDeviceURI = null;
                    if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
                        VolumeRestRep volume = client.blockVolumes().get(resourceId);
                        storageDeviceURI = volume.getStorageController();
                    } else if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resourceId)) {
                        BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
                        storageDeviceURI = snapshot.getStorageController();
                    }
                    if (storageDeviceURI != null) {
                        storageSystemURISet.add(storageDeviceURI);
                    }
                } else {
                    log.error("Block param not found in export group: {}", exportId);
                }
            }
        }
        if (!CollectionUtils.isEmpty(storageSystemURISet)) {
            Set<URI> portGroupSet = new HashSet<URI>();
            for (URI storageSystemURI : storageSystemURISet) {
                // Now use the storage system ID as well to query the storage port groups
                StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemURI, null, null, false);
                List<StoragePortGroupRestRep> portGroupList = portGroups.getStoragePortGroups();
                if (!CollectionUtils.isEmpty(portGroupList)) {
                    for (StoragePortGroupRestRep portGroup : portGroupList) {
                        if (portGroupSet.add(portGroup.getId())) {
                            storagePortGroups.add(portGroup);
                        }
                    }
                }
            }
        }
        return createPortGroupOptions(storagePortGroups);
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) 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 3 with SimpleValueRep

use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.

the class BlockProvider method getExportVolumeForComputePortGroups.

@Asset("exportVolumeForComputePortGroups")
@AssetDependencies({ "blockVirtualArray", "blockVirtualPool", "project" })
public List<AssetOption> getExportVolumeForComputePortGroups(AssetOptionsContext ctx, URI vArrayId, URI vpoolId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(vArrayId, null, null, vpoolId, null, true);
        return createPortGroupOptions(portGroups.getStoragePortGroups());
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with SimpleValueRep

use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method isVMAXUsePortGroupEnabled.

public static boolean isVMAXUsePortGroupEnabled(URI resourceId) {
    SimpleValueRep value = execute(new GetVMAXUsePortGroupEnabledConfig());
    if (value.getValue().equalsIgnoreCase("true")) {
        if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
            BlockObjectRestRep obj = getVolume(resourceId);
            if (obj instanceof VolumeRestRep) {
                VolumeRestRep volume = (VolumeRestRep) obj;
                boolean isVMAX = StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax3.name());
                boolean isRPOrVPlex = isVplexOrRPVolume(volume);
                if (isVMAX && !isRPOrVPlex) {
                    return true;
                }
            }
            if (obj instanceof BlockSnapshotRestRep) {
                BlockSnapshotRestRep snapshot = (BlockSnapshotRestRep) obj;
                BlockObjectRestRep parent = getVolume(snapshot.getParent().getId());
                if (parent instanceof VolumeRestRep) {
                    VolumeRestRep volume = (VolumeRestRep) obj;
                    if (StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
                        return true;
                    }
                }
                if (parent instanceof BlockMirrorRestRep) {
                    BlockMirrorRestRep mirror = (BlockMirrorRestRep) obj;
                    if (StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
                        return true;
                    }
                }
            }
            if (obj instanceof BlockMirrorRestRep) {
                BlockMirrorRestRep mirror = (BlockMirrorRestRep) obj;
                if (StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
                    return true;
                }
            }
        }
        if (ResourceType.isType(ResourceType.VIRTUAL_POOL, resourceId)) {
            BlockVirtualPoolRestRep virtualPool = execute(new GetBlockVirtualPool(resourceId));
            boolean isVMAX = StringUtils.equalsIgnoreCase(virtualPool.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(virtualPool.getSystemType(), DiscoveredDataObject.Type.vmax3.name());
            boolean isVPLEX = virtualPool.getHighAvailability() != null;
            if (isVMAX && !isVPLEX) {
                return true;
            }
        }
    }
    return false;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) GetBlockVirtualPool(com.emc.sa.service.vipr.block.tasks.GetBlockVirtualPool) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) GetVMAXUsePortGroupEnabledConfig(com.emc.sa.service.vipr.block.tasks.GetVMAXUsePortGroupEnabledConfig) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 5 with SimpleValueRep

use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.

the class BlockProvider method getExportVolumePortGroups.

@Asset("exportVolumePortGroups")
@AssetDependencies({ "unassignedBlockVolume", "host", "project" })
public List<AssetOption> getExportVolumePortGroups(AssetOptionsContext ctx, String selectedVolumes, URI hostOrClusterId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        List<URI> volumeIds = Lists.newArrayList();
        info("Volumes selected by user: %s", selectedVolumes);
        List<String> parsedVolumeIds = TextUtils.parseCSV(selectedVolumes);
        for (String id : parsedVolumeIds) {
            volumeIds.add(uri(id));
        }
        List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds);
        Set<URI> virtualArrays = new HashSet<URI>();
        Set<URI> storageSystems = new HashSet<URI>();
        Set<URI> virtualPools = new HashSet<URI>();
        for (VolumeRestRep volume : volumes) {
            virtualArrays.add(volume.getVirtualArray().getId());
            storageSystems.add(volume.getStorageController());
            virtualPools.add(volume.getVirtualPool().getId());
        }
        if (virtualArrays.size() == 1 && storageSystems.size() == 1 && virtualPools.size() == 1) {
            Iterator<URI> it = virtualArrays.iterator();
            URI varrayId = it.next();
            ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
            Iterator<URI> ssIt = storageSystems.iterator();
            Iterator<URI> vpIt = virtualPools.iterator();
            StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), vpIt.next(), null, true);
            return createPortGroupOptions(portGroups.getStoragePortGroups());
        }
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) URI(java.net.URI) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) 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)

Aggregations

SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)8 Asset (com.emc.sa.asset.annotation.Asset)6 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)6 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 URI (java.net.URI)4 HashSet (java.util.HashSet)4 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)3 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)3 BlockMirrorRestRep (com.emc.storageos.model.block.BlockMirrorRestRep)2 GetBlockVirtualPool (com.emc.sa.service.vipr.block.tasks.GetBlockVirtualPool)1 GetVMAXUsePortGroupEnabledConfig (com.emc.sa.service.vipr.block.tasks.GetVMAXUsePortGroupEnabledConfig)1 CustomConfigType (com.emc.storageos.customconfigcontroller.CustomConfigType)1 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)1 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)1 StoragePortGroupRestRep (com.emc.storageos.model.portgroup.StoragePortGroupRestRep)1 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)1 ArrayList (java.util.ArrayList)1