public class HardcodeLocalhostAsNodeMetadataSupplier
extends com.google.inject.AbstractModule
Supplier<NodeMetadata>
so that it can be used in ssh commands.
Ssh is necessary for operations that cannot be performed in the virtual box api, such as clearing
sessions.
ex. once this is loaded, use Guice to inject Supplier<NodeMetadata>
as host
and
RunScriptOnNode#Factory
as factory, to start making commands like the following:
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot; import static org.jclouds.scriptbuilder.domain.Statements.*; ... // direct execute a script as opposed to using sudo, or an init wrapper ListenableFuturefooInTheFuture = factory.submit(host.get(), exec("echo foo"), runAsRoot(false).wrapInInitScript(false)); ExecResponse foo = Futures.getUnchecked(fooInTheFuture); // call a set of commands that are defined in classpath/functions/function_name.sh ListenableFuture kill = factory.submit(host.get(), call("killsession"), runAsRoot(false).wrapInInitScript(false)); ...
Future.get()
when using RunScriptOnNode.Factory#submit
.
Don't forget!Modifier and Type | Field and Description |
---|---|
static String |
HOST_ID |
static String |
HOSTNAME |
Constructor and Description |
---|
HardcodeLocalhostAsNodeMetadataSupplier() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure() |
protected com.google.common.base.Supplier<NodeMetadata> |
lazySupplyHostAsNodeMetadata()
Lazy so that we don't hang up the injector reading a file
|
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
public static final String HOST_ID
public static final String HOSTNAME
public HardcodeLocalhostAsNodeMetadataSupplier()
@Provides @Singleton protected com.google.common.base.Supplier<NodeMetadata> lazySupplyHostAsNodeMetadata()
protected void configure()
configure
in class com.google.inject.AbstractModule
Copyright © 2009-2013 jclouds. All Rights Reserved.