use of org.apache.whirr.service.ClusterSpec.Property in project whirr by apache.
the class ClusterSpecCommand method getClusterSpec.
protected ClusterSpec getClusterSpec(OptionSet optionSet) throws ConfigurationException {
Configuration optionsConfig = new PropertiesConfiguration();
for (Map.Entry<Property, OptionSpec> entry : optionSpecs.entrySet()) {
Property property = entry.getKey();
OptionSpec option = entry.getValue();
if (property.hasMultipleArguments()) {
optionsConfig.setProperty(property.getConfigName(), optionSet.valuesOf(option));
} else {
optionsConfig.setProperty(property.getConfigName(), optionSet.valueOf(option));
}
}
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(optionsConfig);
if (optionSet.has(configOption)) {
Configuration defaults = new PropertiesConfiguration(optionSet.valueOf(configOption));
config.addConfiguration(defaults);
}
for (Property required : EnumSet.of(SERVICE_NAME, CLUSTER_NAME, IDENTITY)) {
if (config.getString(required.getConfigName()) == null) {
throw new IllegalArgumentException(String.format("Option '%s' not set.", required.getSimpleName()));
}
}
return ClusterSpec.fromConfiguration(config);
}
Aggregations