org.jclouds.compute.domain.internal
Class TemplateBuilderImpl

java.lang.Object
  extended by org.jclouds.compute.domain.internal.TemplateBuilderImpl
All Implemented Interfaces:
TemplateBuilder
Direct Known Subclasses:
CloudSigmaTemplateBuilderImpl, EC2TemplateBuilderImpl, VCloudTemplateBuilderImpl

public class TemplateBuilderImpl
extends Object
implements TemplateBuilder

Author:
Adrian Cole

Field Summary
protected  boolean biggest
           
protected  com.google.common.base.Supplier<Location> defaultLocation
           
protected  javax.inject.Provider<TemplateBuilder> defaultTemplateProvider
           
protected  boolean fastest
           
protected  String hardwareId
           
protected  com.google.common.base.Supplier<Set<? extends Hardware>> hardwares
           
protected  String hypervisor
           
protected  String imageDescription
           
protected  String imageId
           
protected  String imageName
           
protected  com.google.common.base.Predicate<Image> imagePredicate
           
protected  com.google.common.base.Supplier<Set<? extends Image>> images
           
protected  String imageVersion
           
protected  Location location
           
protected  com.google.common.base.Supplier<Set<? extends Location>> locations
           
protected  Logger logger
           
protected  double minCores
           
protected  int minRam
           
protected  TemplateOptions options
           
protected  javax.inject.Provider<TemplateOptions> optionsProvider
           
protected  Boolean os64Bit
           
protected  String osArch
           
protected  String osDescription
           
protected  OsFamily osFamily
           
protected  String osName
           
protected  String osVersion
           
 
Constructor Summary
protected TemplateBuilderImpl(com.google.common.base.Supplier<Set<? extends Location>> locations, com.google.common.base.Supplier<Set<? extends Image>> images, com.google.common.base.Supplier<Set<? extends Hardware>> hardwares, com.google.common.base.Supplier<Location> defaultLocation2, javax.inject.Provider<TemplateOptions> optionsProvider, javax.inject.Provider<TemplateBuilder> defaultTemplateProvider)
           
 
Method Summary
 TemplateBuilder any()
          prime this builder with parameters known to work on the current compute provider.
 TemplateBuilder biggest()
          configure this template to the largest hardware, based on cores, ram, then disk
 Template build()
          Generate an immutable template from the current builder.
 TemplateBuilder fastest()
          configure this template to the fastest hardware, based on cpu
 TemplateBuilder fromHardware(Hardware hardware)
          Configure this template to require the minimum hardware of the parameter.
 TemplateBuilder fromImage(Image image)
          Configure this template to fuzzy-match on the image parameter
 TemplateBuilder fromTemplate(Template template)
          Configure this template to match the resources of the template parameter.
protected  Set<? extends Image> getImages()
           
 TemplateBuilder hardwareId(String hardwareId)
          Configure this template to require a specific hardwareId.
protected  com.google.common.collect.Ordering<Hardware> hardwareSorter()
           
 TemplateBuilder hypervisorMatches(String hypervisor)
          Configure this template to have an hypervisor that matches the regular expression
 TemplateBuilder imageDescriptionMatches(String descriptionRegex)
          Configure this template to have an image description that matches the regular expression
 TemplateBuilder imageId(String imageId)
          Configure this template to require a specific imageId.
 TemplateBuilder imageMatches(com.google.common.base.Predicate<Image> condition)
          Configure this template to have an image description that matches the supplied condition
 TemplateBuilder imageNameMatches(String nameRegex)
          Configure this template to have an image name that matches the regular expression
 TemplateBuilder imageVersionMatches(String imageVersionRegex)
          Configure this template to have an image version that matches the regular expression
 TemplateBuilder locationId(String locationId)
          Configure this template to start in a specific location
 TemplateBuilder minCores(double minCores)
          Configure this template to require the minimum cores below
 TemplateBuilder minRam(int megabytes)
          Configure this template to require the minimum ram in megabytes below
 TemplateBuilder options(TemplateOptions options)
          options such as inbound ports and run scripts.
 TemplateBuilder os64Bit(boolean is64Bit)
          Configure this template to require a 64 bit operating system.
 TemplateBuilder osArchMatches(String osArchitectureRegex)
          Configure this template to require a specific architecture.
 TemplateBuilder osDescriptionMatches(String osDescriptionRegex)
          Configure this template to have an operating system description that matches the regular expression
 TemplateBuilder osFamily(OsFamily os)
          Configure this template to use a specific operating system image.
 TemplateBuilder osNameMatches(String osNameRegex)
          Configure this template to have an operating system name that matches the regular expression
 TemplateBuilder osVersionMatches(String osVersionRegex)
          Configure this template to have an os version that matches the regular expression
protected  Hardware resolveHardware(com.google.common.collect.Ordering<Hardware> hardwareOrdering, Iterable<? extends Image> images)
           
protected  Image resolveImage(Hardware hardware, Iterable<? extends Image> supportedImages)
           
 TemplateBuilder smallest()
          configure this template to the smallest hardware, based on cores, ram, then disk
protected  void throwNoSuchElementExceptionAfterLoggingImageIds(String message, Iterable<? extends Image> images)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

@Named(value="jclouds.compute")
protected Logger logger

images

protected final com.google.common.base.Supplier<Set<? extends Image>> images

hardwares

protected final com.google.common.base.Supplier<Set<? extends Hardware>> hardwares

locations

protected final com.google.common.base.Supplier<Set<? extends Location>> locations

defaultLocation

protected final com.google.common.base.Supplier<Location> defaultLocation

optionsProvider

protected final javax.inject.Provider<TemplateOptions> optionsProvider

defaultTemplateProvider

protected final javax.inject.Provider<TemplateBuilder> defaultTemplateProvider

location

protected Location location

imageId

protected String imageId

hardwareId

protected String hardwareId

hypervisor

protected String hypervisor

imageVersion

protected String imageVersion

osFamily

protected OsFamily osFamily

osVersion

protected String osVersion

os64Bit

protected Boolean os64Bit

osName

protected String osName

osDescription

protected String osDescription

osArch

protected String osArch

imageName

protected String imageName

imageDescription

protected String imageDescription

imagePredicate

protected com.google.common.base.Predicate<Image> imagePredicate

minCores

protected double minCores

minRam

protected int minRam

biggest

protected boolean biggest

fastest

protected boolean fastest

options

protected TemplateOptions options
Constructor Detail

TemplateBuilderImpl

@Inject
protected TemplateBuilderImpl(com.google.common.base.Supplier<Set<? extends Location>> locations,
                                     com.google.common.base.Supplier<Set<? extends Image>> images,
                                     com.google.common.base.Supplier<Set<? extends Hardware>> hardwares,
                                     com.google.common.base.Supplier<Location> defaultLocation2,
                                     @Named(value="DEFAULT")
                                     javax.inject.Provider<TemplateOptions> optionsProvider,
                                     @Named(value="DEFAULT")
                                     javax.inject.Provider<TemplateBuilder> defaultTemplateProvider)
Method Detail

fromTemplate

public TemplateBuilder fromTemplate(Template template)
Configure this template to match the resources of the template parameter.

Specified by:
fromTemplate in interface TemplateBuilder

fromHardware

public TemplateBuilder fromHardware(Hardware hardware)
Configure this template to require the minimum hardware of the parameter.

Specified by:
fromHardware in interface TemplateBuilder

fromImage

public TemplateBuilder fromImage(Image image)
Configure this template to fuzzy-match on the image parameter

Specified by:
fromImage in interface TemplateBuilder

smallest

public TemplateBuilder smallest()
configure this template to the smallest hardware, based on cores, ram, then disk

Specified by:
smallest in interface TemplateBuilder

biggest

public TemplateBuilder biggest()
configure this template to the largest hardware, based on cores, ram, then disk

Specified by:
biggest in interface TemplateBuilder

fastest

public TemplateBuilder fastest()
configure this template to the fastest hardware, based on cpu

Specified by:
fastest in interface TemplateBuilder

locationId

public TemplateBuilder locationId(String locationId)
Configure this template to start in a specific location

Specified by:
locationId in interface TemplateBuilder

osFamily

public TemplateBuilder osFamily(OsFamily os)
Configure this template to use a specific operating system image.

Specified by:
osFamily in interface TemplateBuilder

build

public Template build()
Generate an immutable template from the current builder.

Specified by:
build in interface TemplateBuilder

throwNoSuchElementExceptionAfterLoggingImageIds

protected void throwNoSuchElementExceptionAfterLoggingImageIds(String message,
                                                               Iterable<? extends Image> images)

resolveHardware

protected Hardware resolveHardware(com.google.common.collect.Ordering<Hardware> hardwareOrdering,
                                   Iterable<? extends Image> images)

hardwareSorter

protected com.google.common.collect.Ordering<Hardware> hardwareSorter()

resolveImage

protected Image resolveImage(Hardware hardware,
                             Iterable<? extends Image> supportedImages)
Parameters:
hardware -
supportedImages -
Throws:
NoSuchElementException - if there's no image that matches the predicate

getImages

protected Set<? extends Image> getImages()

imageId

public TemplateBuilder imageId(String imageId)
Configure this template to require a specific imageId.

Note that image Ids are often scoped to location

Specified by:
imageId in interface TemplateBuilder

imageNameMatches

public TemplateBuilder imageNameMatches(String nameRegex)
Configure this template to have an image name that matches the regular expression

Specified by:
imageNameMatches in interface TemplateBuilder

imageDescriptionMatches

public TemplateBuilder imageDescriptionMatches(String descriptionRegex)
Configure this template to have an image description that matches the regular expression

Specified by:
imageDescriptionMatches in interface TemplateBuilder

imageMatches

public TemplateBuilder imageMatches(com.google.common.base.Predicate<Image> condition)
Configure this template to have an image description that matches the supplied condition

Specified by:
imageMatches in interface TemplateBuilder

imageVersionMatches

public TemplateBuilder imageVersionMatches(String imageVersionRegex)
Configure this template to have an image version that matches the regular expression

Specified by:
imageVersionMatches in interface TemplateBuilder

osVersionMatches

public TemplateBuilder osVersionMatches(String osVersionRegex)
Configure this template to have an os version that matches the regular expression

Specified by:
osVersionMatches in interface TemplateBuilder

osArchMatches

public TemplateBuilder osArchMatches(String osArchitectureRegex)
Configure this template to require a specific architecture. ex. virtualizationType or

Specified by:
osArchMatches in interface TemplateBuilder

minCores

public TemplateBuilder minCores(double minCores)
Configure this template to require the minimum cores below

Specified by:
minCores in interface TemplateBuilder

minRam

public TemplateBuilder minRam(int megabytes)
Configure this template to require the minimum ram in megabytes below

Specified by:
minRam in interface TemplateBuilder

osNameMatches

public TemplateBuilder osNameMatches(String osNameRegex)
Configure this template to have an operating system name that matches the regular expression

Specified by:
osNameMatches in interface TemplateBuilder

osDescriptionMatches

public TemplateBuilder osDescriptionMatches(String osDescriptionRegex)
Configure this template to have an operating system description that matches the regular expression

Specified by:
osDescriptionMatches in interface TemplateBuilder

hardwareId

public TemplateBuilder hardwareId(String hardwareId)
Configure this template to require a specific hardwareId.

Specified by:
hardwareId in interface TemplateBuilder

hypervisorMatches

public TemplateBuilder hypervisorMatches(String hypervisor)
Configure this template to have an hypervisor that matches the regular expression

Specified by:
hypervisorMatches in interface TemplateBuilder

options

public TemplateBuilder options(TemplateOptions options)
options such as inbound ports and run scripts.

Specified by:
options in interface TemplateBuilder

any

public TemplateBuilder any()
prime this builder with parameters known to work on the current compute provider.

Specified by:
any in interface TemplateBuilder

toString

public String toString()
Overrides:
toString in class Object

os64Bit

public TemplateBuilder os64Bit(boolean is64Bit)
Description copied from interface: TemplateBuilder
Configure this template to require a 64 bit operating system.

Specified by:
os64Bit in interface TemplateBuilder


Copyright © 2009-2012 jclouds. All Rights Reserved.