}
// creation of the node and installing fabric8 can take a long time...set timeout accordingly
long scriptTimeout = TimeUnit.MILLISECONDS.convert(30, TimeUnit.MINUTES);
props.setProperty(ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
ContextBuilder builder = null;
if (selectedProvider != null && selectedProvider != JClouds.EMPTY_PROVIDER) {
builder = ContextBuilder.newBuilder(selectedProvider);
} else if (selectedApi != null && selectedApi != JClouds.EMPTY_API) {
builder = ContextBuilder.newBuilder(selectedApi);
}
if (endpoint != null && !endpoint.isEmpty()) {
builder = builder.endpoint(endpoint);
}
builder = builder.credentials(identity, credential);
builder = builder.overrides(props);
builder = builder.modules(ImmutableSet.<Module>of(new ManagementLifecycle(BaseManagementContext.INSTANCE)));
builder = builder.name(providerId).modules(ImmutableSet.<Module>of(new Log4JLoggingModule(), new SshjSshClientModule()));
ComputeServiceContext context = builder.build(ComputeServiceContext.class);
return context.getComputeService();
}
return null;
}