public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements JcloudsLocationPublic
JcloudsLocationConfig
.Modifier and Type | Class and Description |
---|---|
static interface |
JcloudsLocation.CustomizeTemplateOptions
Deprecated.
since 0.11.0 use
TemplateOptionCustomizer instead |
AbstractLocation.BasicSubscriptionSupport
BrooklynObject.RelationSupport<T extends BrooklynObject>, BrooklynObject.SubscriptionSupport, BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal, BrooklynObjectInternal.RelationSupportInternal<T extends BrooklynObject>, BrooklynObjectInternal.SubscriptionSupportInternal
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
static java.util.Map<ConfigKey<?>,? extends TemplateBuilderCustomizer> |
SUPPORTED_TEMPLATE_BUILDER_PROPERTIES
properties which cause customization of the TemplateBuilder
|
static java.util.Map<ConfigKey<?>,? extends TemplateOptionCustomizer> |
SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES
properties which cause customization of the TemplateOptions
|
PARENT_LOCATION, TEMPORARY_LOCATION
COMMON_USER_NAMES_TO_TRY, ROOT_ALIASES, ROOT_USERNAME
COMPUTE_SERVICE_MODULES, COMPUTE_SERVICE_REGISTRY, CONNECTIVITY_RESOLVER, CUSTOM_CREDENTIALS, IMAGE_CHOOSER, JCLOUDS_LOCATION_CUSTOMIZER, JCLOUDS_LOCATION_CUSTOMIZER_TYPE, JCLOUDS_LOCATION_CUSTOMIZERS, JCLOUDS_LOCATION_CUSTOMIZERS_SUPPLIER_TYPE, LINK_CONTEXT, OS_FAMILY, OS_FAMILY_OVERRIDE, OS_VERSION_REGEX, PORT_FORWARDER, TEMPLATE_BUILDER
AUTO_ASSIGN_FLOATING_IP, AUTO_GENERATE_KEYPAIRS, CLOUD_PROVIDER, CUSTOM_MACHINE_SETUP_SCRIPT_URL, CUSTOM_MACHINE_SETUP_SCRIPT_URL_LIST, CUSTOM_MACHINE_SETUP_SCRIPT_VARS, CUSTOM_TEMPLATE_OPTIONS_SCRIPT_CONTENTS, DEFAULT_IMAGE_ID, DISABLE_ROOT_AND_PASSWORD_SSH, DONT_CREATE_USER, DONT_REQUIRE_TTY_FOR_SUDO, EXTRA_PUBLIC_KEY_DATA_TO_AUTH, EXTRA_PUBLIC_KEY_URLS_TO_AUTH, GENERATE_HOSTNAME, GRANT_USER_SUDO, GROUP_ID, HARDWARE_ID, IMAGE_DESCRIPTION_REGEX, IMAGE_ID, IMAGE_NAME_REGEX, INCLUDE_BROOKLYN_USER_METADATA, JCLOUDS_KEY_ENDPOINT, JCLOUDS_KEY_USERNAME, KEY_PAIR, LOCAL_TEMP_DIR, LOGIN_USER, LOGIN_USER_PASSWORD, LOGIN_USER_PRIVATE_KEY_DATA, LOGIN_USER_PRIVATE_KEY_FILE, LOOKUP_AWS_HOSTNAME, MACHINE_CREATE_ATTEMPTS, MACHINE_CREATION_SEMAPHORE, MACHINE_DELETION_SEMAPHORE, MAP_DEV_RANDOM_TO_DEV_URANDOM, MAX_CONCURRENT_MACHINE_CREATIONS, MAX_CONCURRENT_MACHINE_DELETIONS, NETWORK_NAME, OPEN_IPTABLES, OVERRIDE_RAM, PORT_FORWARDING_MANAGER, RUN_AS_ROOT, SECURITY_GROUPS, STOP_IPTABLES, STRING_TAGS, TEMPLATE_OPTIONS, TEMPLATE_SPEC, USE_JCLOUDS_SSH_INIT, USE_MACHINE_PUBLIC_ADDRESS_AS_PRIVATE_ADDRESS, USE_PORT_FORWARDING, USER_METADATA_MAP, USER_METADATA_STRING
ACCESS_CREDENTIAL, ACCESS_IDENTITY, ADDITIONAL_INBOUND_PORTS, CALLER_CONTEXT, CLOUD_AVAILABILITY_ZONE_ID, CLOUD_ENDPOINT, CLOUD_REGION_ID, DESTROY_ON_FAILURE, DOMAIN_NAME, EXTENSION, INBOUND_PORTS, LEGACY_PRIVATE_KEY_DATA, LEGACY_PRIVATE_KEY_FILE, LEGACY_PRIVATE_KEY_PASSPHRASE, LEGACY_PUBLIC_KEY_DATA, LEGACY_PUBLIC_KEY_FILE, LOG_CREDENTIALS, MACHINE_LOCATION_CUSTOMIZERS, MIN_CORES, MIN_DISK, MIN_RAM, OAUTH_ENDPOINT, OS_64_BIT, PASSWORD, POLL_FOR_FIRST_REACHABLE_ADDRESS, POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE, POLL_FOR_FIRST_REACHABLE_ADDRESS_PREDICATE_TYPE, PRIVATE_KEY_DATA, PRIVATE_KEY_FILE, PRIVATE_KEY_PASSPHRASE, PUBLIC_KEY_DATA, PUBLIC_KEY_FILE, USER, VM_NAME_ALLOWED_CHARACTERS, VM_NAME_MAX_LENGTH, VM_NAME_SALT_LENGTH, WAIT_FOR_SSHABLE, WAIT_FOR_WINRM_AVAILABLE
FINAL_SPEC, NAMED_SPEC_NAME, ORIGINAL_SPEC
Constructor and Description |
---|
JcloudsLocation() |
JcloudsLocation(java.util.Map<?,?> conf)
typically wants at least ACCESS_IDENTITY and ACCESS_CREDENTIAL
|
Modifier and Type | Method and Description |
---|---|
static java.io.File |
asFile(java.lang.Object o)
Deprecated.
since 0.11.0 without replacement
|
org.jclouds.compute.domain.Template |
buildTemplate(org.jclouds.compute.ComputeService computeService,
ConfigBag config,
java.util.Collection<JcloudsLocationCustomizer> customizers)
Deprecated.
since 0.11.0. Use
buildTemplate(ComputeService, ConfigBag, JcloudsLocationCustomizer) instead. |
org.jclouds.compute.domain.Template |
buildTemplate(org.jclouds.compute.ComputeService computeService,
ConfigBag config,
JcloudsLocationCustomizer customizersDelegate)
returns the jclouds Template which describes the image to be built, for the given config and compute service
|
JcloudsLocation |
configure(java.util.Map<?,?> properties)
Deprecated.
|
static java.lang.String |
fileAsString(java.lang.Object o)
Deprecated.
since 0.11.0 without replacement
|
static java.util.Set<ConfigKey<?>> |
getAllSupportedProperties() |
org.jclouds.compute.ComputeService |
getComputeService() |
org.jclouds.compute.ComputeService |
getComputeService(ConfigBag config) |
org.jclouds.compute.ComputeService |
getComputeService(java.util.Map<?,?> flags) |
java.lang.String |
getCredential() |
java.util.Collection<JcloudsLocationCustomizer> |
getCustomizers(ConfigBag setup) |
java.lang.String |
getEndpoint() |
java.lang.String |
getIdentity() |
ConnectivityResolver |
getLocationNetworkInfoCustomizer(ConfigBag setup) |
MachineManagementMixins.MachineMetadata |
getMachineMetadata(MachineLocation l) |
java.lang.String |
getProvider() |
java.util.Map<java.lang.String,java.lang.Object> |
getProvisioningFlags(java.util.Collection<java.lang.String> tags)
Gets flags, suitable as an argument to
MachineProvisioningLocation.obtain(Map) . |
java.lang.String |
getRegion()
returns the location ID used by the provider, if set, e.g.
|
java.lang.String |
getUser(ConfigBag config) |
void |
init()
Called by framework (in new-style instances where spec was used) after configuring etc,
but before a reference to this instance is shared.
|
boolean |
isLocationFirewalldEnabled(SshMachineLocation location) |
boolean |
isWindows(org.jclouds.compute.domain.Image image,
ConfigBag config)
Whether VMs provisioned from this image will be Windows.
|
boolean |
isWindows(org.jclouds.compute.domain.NodeMetadata node,
ConfigBag config)
Whether the given VM is Windows.
|
boolean |
isWindows(org.jclouds.compute.domain.Template template,
ConfigBag config) |
void |
killMachine(MachineLocation l)
Kills the indicated machine; throws if not recognised or possible
|
void |
killMachine(java.lang.String cloudServiceId)
Kills the machine indicated by the given (server-side) machine id;
note, the ID is the _cloud-service_ ID,
that is, pass in getMetadata(machineLocation).getId() not the machineLocation.getId()
|
java.util.Map<java.lang.String,MachineManagementMixins.MachineMetadata> |
listMachines() |
PersistenceObjectStore |
newPersistenceObjectStore(java.lang.String container)
Creates a
PersistenceObjectStore pointed at the given container/directory. |
JcloudsLocation |
newSubLocation(java.lang.Class<? extends AbstractCloudMachineProvisioningLocation> type,
java.util.Map<?,?> newFlags) |
JcloudsLocation |
newSubLocation(java.util.Map<?,?> newFlags)
uses reflection to create an object of the same type, assuming a Map constructor;
subclasses can extend and downcast the result
|
MachineLocation |
obtain() |
MachineLocation |
obtain(java.util.Map<?,?> flags)
core method for obtaining a VM using jclouds;
Map should contain CLOUD_PROVIDER and CLOUD_ENDPOINT or CLOUD_REGION, depending on the cloud,
as well as ACCESS_IDENTITY and ACCESS_CREDENTIAL,
plus any further properties to specify e.g.
|
MachineLocation |
obtain(java.util.Map<?,?> flags,
org.jclouds.compute.domain.TemplateBuilder tb) |
MachineLocation |
obtain(org.jclouds.compute.domain.TemplateBuilder tb) |
void |
rebind()
Called by framework on rebind (in new-style instances):
after configuring, but
before the instance is managed, and
before adjuncts are attached to entities, and
before a reference to an object is shared.
|
JcloudsMachineLocation |
registerMachine(ConfigBag flags)
Brings an existing machine with the given details under management.
|
JcloudsMachineLocation |
registerMachine(java.util.Map<?,?> flags) |
void |
release(MachineLocation rawMachine)
Release a previously-obtained machine.
|
JcloudsMachineLocation |
resumeMachine(java.util.Map<?,?> flags)
Brings an existing machine with the given details under management.
|
void |
setDefaultImageId(java.lang.String val) |
void |
setTagMapping(java.util.Map<java.lang.String,java.util.Map<java.lang.String,? extends java.lang.Object>> val) |
void |
suspendMachine(MachineLocation rawLocation)
Suspends the given location.
|
java.lang.String |
toString()
Default String representation is simplified name of class, together with selected fields.
|
java.lang.String |
toStringNice()
return a nice string suitable for display messages
|
java.lang.String |
toVerboseString() |
addChild, addExtension, config, containsLocation, equals, getChildren, getConfig, getConfig, getDisplayName, getExtension, getHostGeoInfo, getLocationTypeInternal, getParent, getRebindSupport, hasExtension, hashCode, isManaged, onManagementStarted, onManagementStopped, relations, removeChild, setDisplayName, setHostGeoInfo, setManagementContext, setParent, setParent, subscriptions, toMetadataRecord
addSearchPath, getCatalogItemId, getCatalogItemIdSearchPath, getId, getManagementContext, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId, tags
containsLocation, getChildren, getConfig, getDisplayName, getExtension, getId, getParent, hasExtension, relations, setParent
getCatalogItemId, getCatalogItemIdSearchPath, subscriptions, tags
config, getConfig
getManagementContext
addSearchPath, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId
public static final org.slf4j.Logger LOG
public static final java.util.Map<ConfigKey<?>,? extends TemplateBuilderCustomizer> SUPPORTED_TEMPLATE_BUILDER_PROPERTIES
public static final java.util.Map<ConfigKey<?>,? extends TemplateOptionCustomizer> SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES
public JcloudsLocation()
public JcloudsLocation(java.util.Map<?,?> conf)
@Deprecated public JcloudsLocation configure(java.util.Map<?,?> properties)
AbstractBrooklynObject
ConfigBag.getUnusedConfig()
.
To be overridden by AbstractEntity, AbstractLoation, AbstractPolicy, AbstractEnricher, etc.
But should not be overridden by specific entity types. If you do, the entity may break in subsequent releases. Also note that if you require fields to be initialized you must do that in this method. You must *not* rely on field initializers because they may not run until *after* this method (this method is invoked by the constructor in this class, so initializers in subclasses will not have run when this overridden method is invoked.)
configure
in class AbstractLocation
public void init()
AbstractBrooklynObject
To preserve backwards compatibility for if the instance is constructed directly, one can call the code below, but that means it will be called after references to this policy have been shared with other entities.
if (isLegacyConstruction()) {
init();
}
init
in class AbstractLocation
public void rebind()
AbstractBrooklynObject
AbstractBrooklynObject.init()
will not be called on rebind.
If you need to intercept behaviour after adjuncts are attached,
consider AbstractEntity.onManagementStarting()
(but probably worth raising a discussion on the mailing list!)
rebind
in class AbstractLocation
public JcloudsLocation newSubLocation(java.util.Map<?,?> newFlags)
AbstractCloudMachineProvisioningLocation
newSubLocation
in interface MachineProvisioningLocation<MachineLocation>
newSubLocation
in class AbstractCloudMachineProvisioningLocation
public JcloudsLocation newSubLocation(java.lang.Class<? extends AbstractCloudMachineProvisioningLocation> type, java.util.Map<?,?> newFlags)
newSubLocation
in class AbstractCloudMachineProvisioningLocation
public java.lang.String toString()
AbstractLocation
toString
in class AbstractLocation
public java.lang.String toVerboseString()
toVerboseString
in interface Location
toVerboseString
in class AbstractLocation
public java.lang.String getProvider()
getProvider
in interface JcloudsLocationPublic
public java.lang.String getIdentity()
getIdentity
in interface JcloudsLocationPublic
public java.lang.String getCredential()
getCredential
in interface JcloudsLocationPublic
public java.lang.String getRegion()
getRegion
in interface JcloudsLocationPublic
public java.lang.String getEndpoint()
getEndpoint
in interface JcloudsLocationPublic
public java.lang.String getUser(ConfigBag config)
public boolean isWindows(org.jclouds.compute.domain.Template template, ConfigBag config)
public boolean isWindows(org.jclouds.compute.domain.Image image, ConfigBag config)
JcloudsLocationConfig.OS_FAMILY
.
Will first look at JcloudsLocationConfig.OS_FAMILY_OVERRIDE
, to check if that
is set. If so, no further checks are done: the value is compared against OsFamily.WINDOWS
.
We believe the config (e.g. from brooklyn.properties) because for some clouds there is
insufficient meta-data so the Image might not tell us. Thus a user can work around it
by explicitly supplying configuration.public boolean isWindows(org.jclouds.compute.domain.NodeMetadata node, ConfigBag config)
isWindows(Image, ConfigBag)
public boolean isLocationFirewalldEnabled(SshMachineLocation location)
public java.util.Collection<JcloudsLocationCustomizer> getCustomizers(ConfigBag setup)
public ConnectivityResolver getLocationNetworkInfoCustomizer(ConfigBag setup)
public void setDefaultImageId(java.lang.String val)
public void setTagMapping(java.util.Map<java.lang.String,java.util.Map<java.lang.String,? extends java.lang.Object>> val)
public java.util.Map<java.lang.String,java.lang.Object> getProvisioningFlags(java.util.Collection<java.lang.String> tags)
MachineProvisioningLocation
MachineProvisioningLocation.obtain(Map)
. The tags provided give
hints about the machine required. The provisioning-location could be configured to
understand those tags.
For example, an AWS-location could be configured to understand that a particular entity
type (e.g. "TomcatServer") requires a particular AMI in that region, so would return the
required image id.getProvisioningFlags
in interface MachineProvisioningLocation<MachineLocation>
getProvisioningFlags
in class AbstractCloudMachineProvisioningLocation
public static final java.util.Set<ConfigKey<?>> getAllSupportedProperties()
public org.jclouds.compute.ComputeService getComputeService()
public org.jclouds.compute.ComputeService getComputeService(java.util.Map<?,?> flags)
public org.jclouds.compute.ComputeService getComputeService(ConfigBag config)
public java.util.Map<java.lang.String,MachineManagementMixins.MachineMetadata> listMachines()
listMachines
in interface MachineManagementMixins.ListsMachines
public MachineManagementMixins.MachineMetadata getMachineMetadata(MachineLocation l)
getMachineMetadata
in interface MachineManagementMixins.GivesMachineMetadata
MachineManagementMixins.MachineMetadata
for a given (brooklyn) machine location instance,
or null if not matched.public void killMachine(java.lang.String cloudServiceId)
MachineManagementMixins.KillsMachines
killMachine
in interface MachineManagementMixins.KillsMachines
public void killMachine(MachineLocation l)
MachineManagementMixins.KillsMachines
killMachine
in interface MachineManagementMixins.KillsMachines
public MachineLocation obtain() throws NoMachinesAvailableException
NoMachinesAvailableException
public MachineLocation obtain(org.jclouds.compute.domain.TemplateBuilder tb) throws NoMachinesAvailableException
NoMachinesAvailableException
public MachineLocation obtain(java.util.Map<?,?> flags, org.jclouds.compute.domain.TemplateBuilder tb) throws NoMachinesAvailableException
NoMachinesAvailableException
public MachineLocation obtain(java.util.Map<?,?> flags) throws NoMachinesAvailableException
obtain
in interface MachineProvisioningLocation<MachineLocation>
obtain
in interface ProvisioningLocation<MachineLocation>
flags
- Details of the desired machine (e.g. image, size, open ports, etc; some flag support is limited to selected providers).
"callerContext" can be specified to have custom logging and error messages (useful if starting machines in parallel)NoMachinesAvailableException
- if there are no machines available in this location (or impls may return null, but that is discouraged)public void suspendMachine(MachineLocation rawLocation)
Note that this method does not call the lifecycle methods of any
customizers
attached to this location.
suspendMachine
in interface MachineManagementMixins.SuspendsMachines
public JcloudsMachineLocation resumeMachine(java.util.Map<?,?> flags)
customizers
attached to this location.resumeMachine
in interface MachineManagementMixins.ResumesMachines
flags
- See registerMachine(ConfigBag)
for a description of required fields.registerMachine(ConfigBag)
@Deprecated public org.jclouds.compute.domain.Template buildTemplate(org.jclouds.compute.ComputeService computeService, ConfigBag config, java.util.Collection<JcloudsLocationCustomizer> customizers)
buildTemplate(ComputeService, ConfigBag, JcloudsLocationCustomizer)
instead.public org.jclouds.compute.domain.Template buildTemplate(org.jclouds.compute.ComputeService computeService, ConfigBag config, JcloudsLocationCustomizer customizersDelegate)
public java.lang.String toStringNice()
JcloudsLocationPublic
toStringNice
in interface JcloudsLocationPublic
public JcloudsMachineLocation registerMachine(ConfigBag flags) throws NoMachinesAvailableException
The args passed in are used to match against an existing machine. The machines are listed (see @link #listMachines()}), and each is compared against the given args. There should be exactly one matching machine.
Arguments that can be used for matching are:
id
: the cloud provider's VM id, e.g. "eu-west-1/i-5504f21d" (NB this is
JcloudsMachineLocationPublic.getJcloudsId()
not #getId())
hostname
: the public hostname or IP of the machine,
e.g. "ec2-176-34-93-58.eu-west-1.compute.amazonaws.com"
user
will deterine the username subsequently used for ssh or WinRM. See the standard
config options of JcloudsLocation
, SshMachineLocation
and
WinRmMachineLocation
.java.lang.IllegalArgumentException
- if there is not exactly one matchNoMachinesAvailableException
public JcloudsMachineLocation registerMachine(java.util.Map<?,?> flags) throws NoMachinesAvailableException
NoMachinesAvailableException
public void release(MachineLocation rawMachine)
MachineProvisioningLocation
release
in interface MachineProvisioningLocation<MachineLocation>
release
in interface ProvisioningLocation<MachineLocation>
rawMachine
- a MachineLocation
previously obtained from a call to #obtain()
public PersistenceObjectStore newPersistenceObjectStore(java.lang.String container)
LocationWithObjectStore
PersistenceObjectStore
pointed at the given container/directory.newPersistenceObjectStore
in interface LocationWithObjectStore
@Deprecated public static java.io.File asFile(java.lang.Object o)
@Deprecated public static java.lang.String fileAsString(java.lang.Object o)