use of de.cinovo.cloudconductor.api.model.ConfigValue in project cloudconductor-agent-redhat by cinovo.
the class ServerCom method getConfig.
/**
* @return the config for this agent
* @throws CloudConductorException error if retrieval fails
*/
public static Map<String, String> getConfig() throws CloudConductorException {
Map<String, String> configMap = new HashMap<>();
try {
for (ConfigValue c : ServerCom.config.getConfig(AgentState.info().getTemplate(), AgentVars.SERVICE_NAME)) {
if ((c.getService() != null) && c.getService().equals(AgentVars.SERVICE_NAME)) {
ServerCom.LOGGER.debug("Add config: " + c.getKey() + ": " + c.getValue());
configMap.put(c.getKey(), (String) c.getValue());
}
}
} catch (RuntimeException e) {
ServerCom.LOGGER.error("Error getting config from server: ", e);
throw new CloudConductorException(e.getMessage());
}
return configMap;
}
use of de.cinovo.cloudconductor.api.model.ConfigValue in project cloudconductor-agent-redhat by cinovo.
the class ConfigValueHandler method getConfig.
/**
* @param template the template name
* @param service the serice name
* @return map containing config kv-pairs of the service
* @throws CloudConductorException Error indicating connection or data problems
*/
@SuppressWarnings("unchecked")
public List<ConfigValue> getConfig(String template, String service) throws CloudConductorException {
String path = this.pathGenerator("/config/{template}/{service}", template, service);
ConfigValueHandler.LOGGER.debug("Receive config from '" + path + "'...");
JavaType type = AbstractApiHandler.mapper.getTypeFactory().constructCollectionLikeType(ArrayList.class, ConfigValue.class);
List<ConfigValue> configList = (ArrayList<ConfigValue>) this._get(path, type);
return configList;
}
Aggregations