org.jclouds.virtualbox.config
Class HardcodeLocalhostAsNodeMetadataSupplier

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by org.jclouds.virtualbox.config.HardcodeLocalhostAsNodeMetadataSupplier
All Implemented Interfaces:
com.google.inject.Module

public class HardcodeLocalhostAsNodeMetadataSupplier
extends com.google.inject.AbstractModule

In particular, this binds 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
  ListenableFuture fooInTheFuture = 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));
 
 ...
 
 

Note

People often forget to call Future.get() when using RunScriptOnNode.Factory#submit. Don't forget!

Author:
Adrian Cole

Field Summary
static String HOST_ID
           
static String HOSTNAME
           
 
Constructor Summary
HardcodeLocalhostAsNodeMetadataSupplier()
           
 
Method Summary
protected  void configure()
           
protected  com.google.common.base.Supplier<NodeMetadata> lazySupplyHostAsNodeMetadata()
          Lazy so that we don't hang up the injector reading a file
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HOST_ID

public static final String HOST_ID
See Also:
Constant Field Values

HOSTNAME

public static final String HOSTNAME
Constructor Detail

HardcodeLocalhostAsNodeMetadataSupplier

public HardcodeLocalhostAsNodeMetadataSupplier()
Method Detail

lazySupplyHostAsNodeMetadata

@Provides
@Singleton
protected com.google.common.base.Supplier<NodeMetadata> lazySupplyHostAsNodeMetadata()
Lazy so that we don't hang up the injector reading a file


configure

protected void configure()
Specified by:
configure in class com.google.inject.AbstractModule


Copyright © 2009-2012 jclouds. All Rights Reserved.