Search in sources :

Example 1 with PropertyMetadata

use of com.emc.storageos.model.property.PropertyMetadata in project coprhd-controller by CoprHD.

the class ConfigProperties method loadProperties.

private static Map<String, Property> loadProperties() {
    Map<String, String> values = ConfigPropertyUtils.getProperties();
    Map<String, Property> properties = Maps.newLinkedHashMap();
    for (Map.Entry<String, PropertyMetadata> entry : ConfigPropertyUtils.getPropertiesMetadata().getMetadata().entrySet()) {
        /*
             * image server configuration has been moved to Physical assets but, image server properties meta data
             * needs to remain for migration
             */
        if (entry.getKey().startsWith("image_server")) {
            continue;
        }
        PropertyMetadata metadata = entry.getValue();
        if ((metadata.getUserMutable() != null && metadata.getUserMutable()) && (metadata.getHidden() == null || !metadata.getHidden())) {
            String name = entry.getKey();
            String value = values.get(name);
            PropertyMetadata meta = entry.getValue();
            if (value != null) {
                if (meta.getType().equals(TEXT) || meta.getType().equals(ENCRYPTEDTEXT)) {
                    value = value.replace("\\\\n", "\r\n");
                }
            }
            Set<String> allSupportPageProperties = SupportPropertyPage.getAllProperties();
            if (!(allSupportPageProperties.contains(name) && SetupUtils.isOssBuild())) {
                Property property = new Property(name, value, meta);
                properties.put(name, property);
            }
        }
    }
    return properties;
}
Also used : PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Property(models.properties.Property) Map(java.util.Map)

Example 2 with PropertyMetadata

use of com.emc.storageos.model.property.PropertyMetadata in project coprhd-controller by CoprHD.

the class PropertyInfoExt method getNotifierTags.

public List<String> getNotifierTags(boolean forReconfig) {
    Map<String, PropertyMetadata> metadata = PropertiesMetadata.getGlobalMetadata();
    List<String> ret = new ArrayList<>();
    if (getProperties() == null || metadata == null) {
        return ret;
    }
    for (Map.Entry<String, String> entry : getProperties().entrySet()) {
        final String key = entry.getKey();
        final PropertyMetadata propertyMetadata = metadata.get(key);
        if (propertyMetadata != null && propertyMetadata.getNotifiers() != null) {
            // skip those properties that have notifiters but don't require reconfig
            if (forReconfig && (propertyMetadata.getReconfigRequired() == null || !propertyMetadata.getReconfigRequired())) {
                continue;
            }
            String[] notifierTags = propertyMetadata.getNotifiers();
            // TODO: Note that the ordering is not deterministic across properties now
            for (String notifierTag : notifierTags) {
                if (!ret.contains(notifierTag)) {
                    ret.add(notifierTag);
                }
            }
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Map(java.util.Map)

Example 3 with PropertyMetadata

use of com.emc.storageos.model.property.PropertyMetadata in project coprhd-controller by CoprHD.

the class PropertyInfoExt method hasReconfigProperty.

public boolean hasReconfigProperty() {
    Map<String, PropertyMetadata> metadata = PropertiesMetadata.getGlobalMetadata();
    if (getProperties() == null || metadata == null) {
        return false;
    }
    for (Map.Entry<String, String> entry : getProperties().entrySet()) {
        final String key = entry.getKey();
        final PropertyMetadata propertyMetadata = metadata.get(key);
        if (propertyMetadata != null && propertyMetadata.getReconfigRequired() != null && propertyMetadata.getReconfigRequired().booleanValue()) {
            return true;
        }
    }
    return false;
}
Also used : PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Map(java.util.Map)

Example 4 with PropertyMetadata

use of com.emc.storageos.model.property.PropertyMetadata in project coprhd-controller by CoprHD.

the class PasswordService method setUserPassword.

/**
 * Called by update password methods to set user's password
 *
 * @param username
 * @param passwd
 * @param encpasswd
 */
private void setUserPassword(String username, String passwd, String encpasswd, boolean bReset) {
    PropertyMetadata metaData = null;
    try {
        final String key = "system_" + username + "_encpassword";
        Map<String, PropertyMetadata> metadataMap = getMetaData();
        metaData = metadataMap.get(key);
    } catch (Exception e) {
        _logger.error("resetPassword", e);
        throw APIException.internalServerErrors.updateObjectError("password", e);
    }
    if (metaData == null) {
        throw APIException.badRequests.parameterIsNotValid("username");
    }
    if (ENCRYPTEDSTRING.equalsIgnoreCase(metaData.getType())) {
        _passwordHandler.setUserEncryptedPassword(username, passwd, bReset);
    } else if (passwd != null && !passwd.isEmpty()) {
        _passwordHandler.setUserPassword(username, passwd, bReset);
    } else {
        _passwordHandler.setUserHashedPassword(username, encpasswd, bReset);
    }
}
Also used : PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) ParseException(java.text.ParseException)

Example 5 with PropertyMetadata

use of com.emc.storageos.model.property.PropertyMetadata in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setTargetProperties.

/**
 * Update system properties to zookeeper
 *
 * @param currentProps
 * @throws CoordinatorClientException
 */
public void setTargetProperties(Map<String, String> currentProps) throws CoordinatorClientException {
    Map<String, PropertyMetadata> propsMetadata = PropertiesMetadata.getGlobalMetadata();
    // split properties as global, or site specific
    HashMap<String, String> globalProps = new HashMap<String, String>();
    HashMap<String, String> siteProps = new HashMap<String, String>();
    for (Map.Entry<String, String> prop : currentProps.entrySet()) {
        String key = prop.getKey();
        PropertyMetadata metadata = propsMetadata.get(key);
        if (metadata.getSiteSpecific()) {
            siteProps.put(key, prop.getValue());
        } else {
            globalProps.put(key, prop.getValue());
        }
    }
    // update properties to zk
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state if checkState = true specified
            if (!isClusterUpgradable()) {
                throw APIException.serviceUnavailable.clusterStateNotStable();
            }
            ConfigurationImpl globalCfg = new ConfigurationImpl();
            globalCfg.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
            globalCfg.setKind(PropertyInfoExt.TARGET_PROPERTY);
            PropertyInfoExt globalPropInfo = new PropertyInfoExt(globalProps);
            globalCfg.setConfig(TARGET_INFO, globalPropInfo.encodeAsString());
            _coordinator.persistServiceConfiguration(globalCfg);
            _log.info("target properties changed successfully. target properties {}", globalPropInfo.toString());
            if (siteProps.size() > 0) {
                setSiteSpecificProperties(siteProps, _coordinator.getSiteId());
                _log.info("site scope target properties changed successfully. target properties {}", siteProps.toString());
            }
        } catch (Exception e) {
            throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target info. " + e.getMessage());
        } finally {
            releaseTargetVersionLock();
        }
    } else {
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. Unable to obtain target lock");
    }
}
Also used : HashMap(java.util.HashMap) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Aggregations

PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)19 Map (java.util.Map)7 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)1 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)1 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)1 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 Property (models.properties.Property)1