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;
}
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;
}
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;
}
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);
}
}
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");
}
}
Aggregations