public class TemplateBuilderImpl extends Object implements TemplateBuilder
Modifier and Type | Field and Description |
---|---|
protected boolean |
biggest |
protected com.google.common.base.Supplier<Location> |
defaultLocation |
protected javax.inject.Provider<TemplateBuilder> |
defaultTemplateProvider |
protected boolean |
fastest |
protected Boolean |
forceCacheReload |
protected String |
hardwareId |
protected com.google.common.base.Supplier<Set<? extends Hardware>> |
hardwares |
protected String |
hypervisor |
protected com.google.common.base.Function<Iterable<? extends Image>,Image> |
imageChooser |
protected String |
imageDescription |
protected String |
imageId |
protected String |
imageName |
protected com.google.common.base.Predicate<Image> |
imagePredicate |
protected ImageCacheSupplier |
images |
protected String |
imageVersion |
protected Location |
location |
protected com.google.common.base.Supplier<Set<? extends Location>> |
locations |
protected Logger |
logger |
protected double |
minCores |
protected double |
minDisk |
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 |
Modifier | Constructor and Description |
---|---|
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> defaultLocation,
javax.inject.Provider<TemplateOptions> optionsProvider,
javax.inject.Provider<TemplateBuilder> defaultTemplateProvider) |
Modifier and Type | Method and Description |
---|---|
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
|
protected Hardware |
findHardwareWithId(Set<? extends Hardware> hardwaresToSearch) |
TemplateBuilder |
forceCacheReload()
Forces an image lookup against the provider to reload the image cache.
|
TemplateBuilder |
from(String spec)
Configure and return this template, updating it with the populated values of the given
spec . |
TemplateBuilder |
from(TemplateBuilderSpec spec)
Configure and return this template, updating it with the populated values of the given
spec . |
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
|
protected com.google.common.base.Function<Iterable<? extends Image>,Image> |
imageChooser() |
TemplateBuilderImpl |
imageChooser(com.google.common.base.Function<Iterable<? extends Image>,Image> imageChooser)
Configure this template with a specific preference function which operates on
images which match the other criteria.
|
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 that matches the supplied condition
ex.
|
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 |
minDisk(double gigabytes)
Configure this template with required minimum disk space in gigabytes
|
TemplateBuilder |
minRam(int megabytes)
Configure this template to require the minimum ram in megabytes below
|
TemplateBuilder |
options(TemplateOptions options)
Sets options on the template (i.e.
|
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(Set<? extends Hardware> hardwarel,
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 com.google.common.base.Objects.ToStringHelper |
string() |
protected NoSuchElementException |
throwNoSuchElementExceptionAfterLoggingHardwareIds(String message,
Iterable<? extends Hardware> hardwares) |
protected NoSuchElementException |
throwNoSuchElementExceptionAfterLoggingImageIds(String message,
Iterable<? extends Image> images) |
String |
toString() |
@Named(value="jclouds.compute") protected Logger logger
protected final ImageCacheSupplier images
protected final com.google.common.base.Supplier<Location> defaultLocation
protected final javax.inject.Provider<TemplateOptions> optionsProvider
protected final javax.inject.Provider<TemplateBuilder> defaultTemplateProvider
protected Location location
protected String imageId
protected String hardwareId
protected String hypervisor
protected String imageVersion
protected OsFamily osFamily
protected String osVersion
protected Boolean os64Bit
protected String osName
protected String osDescription
protected String osArch
protected String imageName
protected String imageDescription
protected com.google.common.base.Predicate<Image> imagePredicate
protected com.google.common.base.Function<Iterable<? extends Image>,Image> imageChooser
protected double minCores
protected int minRam
protected double minDisk
protected boolean biggest
protected boolean fastest
protected TemplateOptions options
protected Boolean forceCacheReload
@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> defaultLocation, @Named(value="DEFAULT") javax.inject.Provider<TemplateOptions> optionsProvider, @Named(value="DEFAULT") javax.inject.Provider<TemplateBuilder> defaultTemplateProvider)
public TemplateBuilder fromTemplate(Template template)
fromTemplate
in interface TemplateBuilder
public TemplateBuilder fromHardware(Hardware hardware)
fromHardware
in interface TemplateBuilder
public TemplateBuilder fromImage(Image image)
fromImage
in interface TemplateBuilder
public TemplateBuilder smallest()
smallest
in interface TemplateBuilder
public TemplateBuilder biggest()
biggest
in interface TemplateBuilder
public TemplateBuilder fastest()
fastest
in interface TemplateBuilder
public TemplateBuilder locationId(String locationId)
locationId
in interface TemplateBuilder
public TemplateBuilder osFamily(OsFamily os)
osFamily
in interface TemplateBuilder
public Template build()
build
in interface TemplateBuilder
protected NoSuchElementException throwNoSuchElementExceptionAfterLoggingImageIds(String message, Iterable<? extends Image> images)
protected NoSuchElementException throwNoSuchElementExceptionAfterLoggingHardwareIds(String message, Iterable<? extends Hardware> hardwares)
protected Hardware resolveHardware(Set<? extends Hardware> hardwarel, Iterable<? extends Image> images)
protected com.google.common.base.Function<Iterable<? extends Image>,Image> imageChooser()
protected com.google.common.collect.Ordering<Hardware> hardwareSorter()
protected Image resolveImage(Hardware hardware, Iterable<? extends Image> supportedImages)
hardware
- supportedImages
- NoSuchElementException
- if there's no image that matches the predicatepublic TemplateBuilder imageId(String imageId)
location
imageId
in interface TemplateBuilder
public TemplateBuilder imageNameMatches(String nameRegex)
imageNameMatches
in interface TemplateBuilder
public TemplateBuilder imageDescriptionMatches(String descriptionRegex)
imageDescriptionMatches
in interface TemplateBuilder
public TemplateBuilder imageMatches(com.google.common.base.Predicate<Image> condition)
builder.imageMatches(ImagePredicates.userMetadataContains("author", "sue"));
imageMatches
in interface TemplateBuilder
public TemplateBuilderImpl imageChooser(com.google.common.base.Function<Iterable<? extends Image>,Image> imageChooser)
If no function is supplied, jclouds will select one according to an internal strategy. This strategy may change from version to version.
imageChooser
in interface TemplateBuilder
public TemplateBuilder imageVersionMatches(String imageVersionRegex)
imageVersionMatches
in interface TemplateBuilder
public TemplateBuilder osVersionMatches(String osVersionRegex)
osVersionMatches
in interface TemplateBuilder
public TemplateBuilder osArchMatches(String osArchitectureRegex)
osArchMatches
in interface TemplateBuilder
public TemplateBuilder minCores(double minCores)
minCores
in interface TemplateBuilder
public TemplateBuilder minRam(int megabytes)
minRam
in interface TemplateBuilder
public TemplateBuilder minDisk(double gigabytes)
minDisk
in interface TemplateBuilder
public TemplateBuilder osNameMatches(String osNameRegex)
osNameMatches
in interface TemplateBuilder
public TemplateBuilder osDescriptionMatches(String osDescriptionRegex)
osDescriptionMatches
in interface TemplateBuilder
public TemplateBuilder hardwareId(String hardwareId)
hardwareId
in interface TemplateBuilder
public TemplateBuilder hypervisorMatches(String hypervisor)
hypervisorMatches
in interface TemplateBuilder
public TemplateBuilder options(TemplateOptions options)
options
in interface TemplateBuilder
public TemplateBuilder any()
any
in interface TemplateBuilder
protected com.google.common.base.Objects.ToStringHelper string()
public TemplateBuilder os64Bit(boolean is64Bit)
TemplateBuilder
os64Bit
in interface TemplateBuilder
public TemplateBuilder from(TemplateBuilderSpec spec)
TemplateBuilder
spec
.from
in interface TemplateBuilder
public TemplateBuilder from(String spec)
TemplateBuilder
spec
.
This is especially useful for command-line configuration of a TemplateBuilder
.from
in interface TemplateBuilder
spec
- a String in the format specified by TemplateBuilderSpec
public TemplateBuilder forceCacheReload()
TemplateBuilder
Use with caution. In some providers getting the list of images is an
expensive operation, and the use of the image cache is recommended. If
there is a need to minimize the amount of time the images are cached,
consider configuring the cache expiration time by setting the
Constants.PROPERTY_SESSION_INTERVAL
property.
forceCacheReload
in interface TemplateBuilder
Copyright © 2009-2016 The Apache Software Foundation. All Rights Reserved.