use of io.fabric8.api.RuntimeProperties in project fabric8 by jboss-fuse.
the class ClusterBootstrapManager method getCreateEnsembleOptions.
static CreateEnsembleOptions getCreateEnsembleOptions(RuntimeProperties sysprops, Map<String, Object> options) {
String username = (String) options.remove("username");
String password = (String) options.remove("password");
String role = (String) options.remove("role");
if (username == null || password == null || role == null) {
throw new FabricException("Must specify an administrator username, password and administrative role when creating a fabric");
}
Object profileObject = options.remove("profiles");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
CreateEnsembleOptions.Builder builder = mapper.convertValue(options, CreateEnsembleOptions.Builder.class);
if (profileObject != null) {
List profiles = mapper.convertValue(profileObject, List.class);
builder.profiles(profiles);
}
org.apache.felix.utils.properties.Properties userProps = null;
try {
userProps = new org.apache.felix.utils.properties.Properties(sysprops.getConfPath().resolve("users.properties").toFile());
} catch (IOException e) {
userProps = new org.apache.felix.utils.properties.Properties();
}
if (userProps.get(username) == null) {
userProps.put(username, password + "," + role);
}
CreateEnsembleOptions answer = builder.users(userProps).withUser(username, password, role).build();
LOG.debug("Creating ensemble with options: {}", answer);
System.setProperty(ZkDefs.GLOBAL_RESOLVER_PROPERTY, answer.getGlobalResolver());
System.setProperty(ZkDefs.LOCAL_RESOLVER_PROPERTY, answer.getResolver());
System.setProperty(ZkDefs.MANUAL_IP, answer.getManualIp());
System.setProperty(ZkDefs.BIND_ADDRESS, answer.getBindAddress());
System.setProperty(ZkDefs.MINIMUM_PORT, "" + answer.getMinimumPort());
System.setProperty(ZkDefs.MAXIMUM_PORT, "" + answer.getMaximumPort());
return answer;
}
use of io.fabric8.api.RuntimeProperties in project fabric8 by jboss-fuse.
the class ClusterBootstrapManager method createCluster.
@Override
public void createCluster() {
assertValid();
RuntimeProperties sysprops = runtimeProperties.get();
bootstrap.get().create(CreateEnsembleOptions.builder().fromRuntimeProperties(sysprops).build());
}
use of io.fabric8.api.RuntimeProperties in project fabric8 by jboss-fuse.
the class ClusterServiceManager method addToCluster.
@Override
public void addToCluster(List<String> containers, Map<String, Object> options) {
assertValid();
RuntimeProperties sysprops = runtimeProperties.get();
CreateEnsembleOptions createEnsembleOptions = ClusterBootstrapManager.getCreateEnsembleOptions(sysprops, options);
addToCluster(containers, createEnsembleOptions);
}
Aggregations