Search in sources :

Example 1 with DataSource

use of com.emc.storageos.customconfigcontroller.DataSource in project coprhd-controller by CoprHD.

the class CustomConfigHandler method getCustomConfigPreviewValue.

/**
 * Uses the samples provided in the configuration item to generate a resolved
 * name for a given mask, configuration and scope. This can be used to preview
 * and validate a name mask prior to setting it.
 *
 * @param name the configuration type name
 * @param value the name mask to be resolved.
 * @param scope the scope to be used to for deciding which constraints to apply.
 * @param variables a map of variable-name-to-variable-value. This map can contain
 *            a value for all or only some of the name mask variables, or it can be
 *            empty. Any missing variable will be replaced with the variable default.
 * @return the resolved name.
 * @throws CustomConfigControllerException for invalid input.
 */
public String getCustomConfigPreviewValue(String name, String value, StringMap scope, Map<String, String> variables) {
    CustomConfigType item = getCustomConfigType(name);
    Map<DataSourceVariable, Boolean> dsVariables = item.getDataSourceVariables();
    DataSource sampleDatasource = null;
    if (dsVariables != null && !dsVariables.isEmpty()) {
        sampleDatasource = datasourceFactory.getSampleDataSource(name);
    }
    CustomConfigResolver resolver = configResolvers.get(item.getConfigType());
    if (variables != null && !variables.isEmpty()) {
        for (Map.Entry<String, String> entry : variables.entrySet()) {
            sampleDatasource.addProperty(entry.getKey(), entry.getValue());
        }
    }
    // validate the computed value
    resolver.validate(item, scope, value);
    // Resolve the config value
    String computedName = resolver.resolve(item, scope, value, sampleDatasource);
    // validate against the constraints
    List<CustomConfigConstraint> constraints = item.getConstraints();
    String systemType = CustomConfigConstants.DEFAULT_KEY;
    if (scope != null) {
        systemType = scope.get(CustomConfigConstants.SYSTEM_TYPE_SCOPE);
        // host type scope is only available for Hitachi Host Mode Option
        if (systemType == null) {
            systemType = scope.get(CustomConfigConstants.HOST_TYPE_SCOPE);
        }
    }
    for (CustomConfigConstraint constraint : constraints) {
        constraint.validate(computedName, systemType);
    }
    return computedName;
}
Also used : CustomConfigType(com.emc.storageos.customconfigcontroller.CustomConfigType) CustomConfigResolver(com.emc.storageos.customconfigcontroller.CustomConfigResolver) HashMap(java.util.HashMap) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap) DataSourceVariable(com.emc.storageos.customconfigcontroller.DataSourceVariable) DataSource(com.emc.storageos.customconfigcontroller.DataSource) CustomConfigConstraint(com.emc.storageos.customconfigcontroller.CustomConfigConstraint)

Example 2 with DataSource

use of com.emc.storageos.customconfigcontroller.DataSource in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method getSystemAccessZoneNamespace.

/**
 * Get the File System default system access zone from
 * controller configuration.
 *
 * @return access zone folder name
 */
private String getSystemAccessZoneNamespace() {
    String namespace = "";
    DataSource dataSource = new DataSource();
    dataSource.addProperty(CustomConfigConstants.ISILON_NO_DIR, "");
    dataSource.addProperty(CustomConfigConstants.ISILON_DIR_NAME, "");
    namespace = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_SYSTEM_ACCESS_ZONE_NAMESPACE, "isilon", dataSource);
    // framework does't allow empty variable to be set. To work around if = is added to variable via conf and then
    // remove it here
    namespace = namespace.replaceAll("=", "");
    return namespace;
}
Also used : DataSource(com.emc.storageos.customconfigcontroller.DataSource)

Example 3 with DataSource

use of com.emc.storageos.customconfigcontroller.DataSource in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method getCustomPath.

/**
 * Gets the file system custom path value from controller configuration
 *
 * @param storage
 *            Isilon storage system
 * @param args
 *            FileDeviceInputOutput object
 * @return evaluated custom path
 */
private String getCustomPath(StorageSystem storage, FileDeviceInputOutput args) {
    String path = "";
    IsilonApi isi = getIsilonDevice(storage);
    String clusterName = isi.getClusterConfig().getName();
    FileShare fs = args.getFs();
    // source cluster name should be included in target path instead of target cluster name.
    if (fs != null && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
        FileShare sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
        if (sourceFS != null && sourceFS.getStorageDevice() != null) {
            StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
            if (sourceSystem != null) {
                IsilonApi sourceCluster = getIsilonDevice(sourceSystem);
                clusterName = sourceCluster.getClusterConfig().getName();
                // if the replication happens from user defined access zone to system access zone!!
                if (sourceFS.getVirtualNAS() != null) {
                    VirtualNAS sourcevNAS = _dbClient.queryObject(VirtualNAS.class, sourceFS.getVirtualNAS());
                    if (sourcevNAS != null) {
                        String vNASName = sourcevNAS.getNasName();
                        vNASName = getNameWithNoSpecialCharacters(vNASName, args);
                        clusterName = clusterName + vNASName;
                        _log.info("Source file system is on virtual NAS {}", vNASName);
                    }
                }
                _log.debug("Generating path for target and the source cluster is is  {}", clusterName);
            }
        }
    } else if (args.isTarget()) {
        if (args.getSourceSystem() != null) {
            IsilonApi sourceCluster = getIsilonDevice(args.getSourceSystem());
            clusterName = sourceCluster.getClusterConfig().getName();
        }
        // if the replication happens from user defined access zone to system access zone!!
        if (args.getSourceVNAS() != null && args.getvNAS() == null) {
            VirtualNAS sourcevNAS = args.getSourceVNAS();
            String vNASName = sourcevNAS.getNasName();
            vNASName = getNameWithNoSpecialCharacters(vNASName, args);
            clusterName = clusterName + vNASName;
        }
        _log.debug("Generating path for target and the source cluster is is  {}", clusterName);
    }
    DataSource dataSource = dataSourceFactory.createIsilonFileSystemPathDataSource(args.getProject(), args.getVPool(), args.getTenantOrg(), storage);
    dataSource.addProperty(CustomConfigConstants.ISILON_CLUSTER_NAME, clusterName);
    String configPath = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_PATH_CUSTOMIZATION, "isilon", dataSource);
    _log.debug("The isilon user defined custom path is  {}", configPath);
    if (configPath != null && !configPath.isEmpty()) {
        path = args.getPathWithoutSpecialCharacters(configPath);
    }
    return path;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) DataSource(com.emc.storageos.customconfigcontroller.DataSource)

Example 4 with DataSource

use of com.emc.storageos.customconfigcontroller.DataSource in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method updateDiscoveryPathForUnManagedFS.

/**
 * Add custom discovery directory paths from controller configuration
 */
private void updateDiscoveryPathForUnManagedFS(Map<String, NASServer> nasServer, StorageSystem storage) throws IsilonCollectionException {
    String paths = "";
    String systemAccessZone = "";
    String userAccessZone = "";
    String namespace = "";
    String customLocations = ",";
    // get the system access zones
    DataSource ds = new DataSource();
    ds.addProperty(CustomConfigConstants.ISILON_NO_DIR, "");
    ds.addProperty(CustomConfigConstants.ISILON_DIR_NAME, "");
    namespace = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_SYSTEM_ACCESS_ZONE_NAMESPACE, "isilon", ds);
    namespace = namespace.replaceAll("=", "");
    if (namespace.isEmpty()) {
        systemAccessZone = IFS_ROOT + "/";
    } else {
        systemAccessZone = IFS_ROOT + "/" + namespace + "/";
    }
    // get the user access zone
    userAccessZone = getUserAccessZonePath(nasServer);
    // create a dataSouce and place the value for system and user access zone
    DataSource dataSource = dataSourceFactory.createIsilonUnmanagedFileSystemLocationsDataSource(storage);
    dataSource.addProperty(CustomConfigConstants.ISILON_SYSTEM_ACCESS_ZONE, systemAccessZone);
    dataSource.addProperty(CustomConfigConstants.ISILON_USER_ACCESS_ZONE, userAccessZone);
    dataSource.addProperty(CustomConfigConstants.ISILON_CUSTOM_DIR_PATH, customLocations);
    paths = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_UNMANAGED_FILE_SYSTEM_LOCATIONS, "isilon", dataSource);
    // trim leading or trailing or multiple comma.
    paths = paths.replaceAll("^,+", "").replaceAll(",+$", "").replaceAll(",+", ",");
    if (paths.equals(",") || paths.isEmpty()) {
        IsilonCollectionException ice = new IsilonCollectionException("computed unmanaged file system location is empty. Please verify Isilon controller config settings");
        throw ice;
    }
    _log.info("Unmanaged file system locations are {}", paths);
    List<String> pathList = Arrays.asList(paths.split(","));
    Set<String> pathSet = new HashSet<>();
    pathSet.addAll(pathList);
    setDiscPathsForUnManaged(pathSet);
    _discCustomPath = getCustomConfigPath();
}
Also used : IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) DataSource(com.emc.storageos.customconfigcontroller.DataSource) HashSet(java.util.HashSet)

Example 5 with DataSource

use of com.emc.storageos.customconfigcontroller.DataSource in project coprhd-controller by CoprHD.

the class VmaxExportOperations method generateStorageGroupName.

/**
 * Leverage custom name generator module, this method generates storage group name via the following configuration
 * {host_name.FIRST(20)}_{array_serial_number.LAST(3)}_SG_{auto_tiering_policy_name.FIRST(32)} + {_count(3)}
 * NOTE: the generated name should be no more than 64 characters
 *
 * @param storage
 * @param mask
 * @param initiators
 * @param storageGroupPolicyLimitsParam
 * @return
 */
private String generateStorageGroupName(StorageSystem storage, ExportMask mask, Collection<Initiator> initiators, StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam) {
    String storageGroupCustomTemplateName = CustomConfigConstants.VMAX_HOST_STORAGE_GROUP_MASK_NAME;
    String exportType = ExportMaskUtils.getExportType(_dbClient, mask);
    if (ExportGroupType.Cluster.name().equals(exportType)) {
        storageGroupCustomTemplateName = CustomConfigConstants.VMAX_CLUSTER_STORAGE_GROUP_MASK_NAME;
    }
    // grab custom name generator data source to generate storage group name
    DataSource sgDataSource = ExportMaskUtils.getExportDatasource(storage, new ArrayList<Initiator>(initiators), dataSourceFactory, storageGroupCustomTemplateName);
    String policyName = storageGroupPolicyLimitsParam.getAutoTierPolicyName();
    if (storage.checkIfVmax3()) {
        policyName = policyName.replaceAll(Constants.SMIS_PLUS_REGEX, Constants.UNDERSCORE_DELIMITER);
    }
    policyName = _helper.isFastPolicy(policyName) ? policyName : StorageGroupPolicyLimitsParam.NON_FAST_POLICY;
    String hostIOLimitBandwidth = "";
    String hostIOLimitIops = "";
    if (storageGroupPolicyLimitsParam.isHostIOLimitBandwidthSet()) {
        hostIOLimitBandwidth = StorageGroupPolicyLimitsParam.BANDWIDTH + storageGroupPolicyLimitsParam.getHostIOLimitBandwidth();
    }
    if (storageGroupPolicyLimitsParam.isHostIOLimitIOPsSet()) {
        hostIOLimitIops = StorageGroupPolicyLimitsParam.IOPS + storageGroupPolicyLimitsParam.getHostIOLimitIOPs();
    }
    sgDataSource.addProperty(CustomConfigConstants.AUTO_TIERING_POLICY_NAME, policyName);
    sgDataSource.addProperty(CustomConfigConstants.HOST_IO_LIMIT_BANDWIDTH, hostIOLimitBandwidth);
    sgDataSource.addProperty(CustomConfigConstants.HOST_IO_LIMIT_IOPS, hostIOLimitIops);
    String baseStorageGroupName = customConfigHandler.getComputedCustomConfigValue(storageGroupCustomTemplateName, storage.getSystemType(), sgDataSource);
    // if generated name is duplicated in storage, append number to the end of the name
    return _helper.generateGroupName(_helper.getExistingStorageGroupsFromArray(storage), baseStorageGroupName);
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) DataSource(com.emc.storageos.customconfigcontroller.DataSource)

Aggregations

DataSource (com.emc.storageos.customconfigcontroller.DataSource)21 Initiator (com.emc.storageos.db.client.model.Initiator)7 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 Project (com.emc.storageos.db.client.model.Project)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 StringSet (com.emc.storageos.db.client.model.StringSet)5 HashSet (java.util.HashSet)5 ExportMask (com.emc.storageos.db.client.model.ExportMask)4 HashMap (java.util.HashMap)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)3 Volume (com.emc.storageos.db.client.model.Volume)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)3 ControllerException (com.emc.storageos.volumecontroller.ControllerException)3