public final class DefaultEC2Service extends Object implements EC2Service
Constructor and Description |
---|
DefaultEC2Service(com.amazonaws.auth.AWSCredentials credentials) |
DefaultEC2Service(com.amazonaws.auth.AWSCredentials credentials,
com.amazonaws.services.ec2.model.Region region) |
DefaultEC2Service(com.amazonaws.auth.AWSCredentials credentials,
String region) |
DefaultEC2Service(EC2ServiceContext context,
org.kuali.common.util.wait.WaitService service) |
Modifier and Type | Method and Description |
---|---|
void |
allowTermination(String instanceId)
Set a flag that allows an Amazon EC2 instance to be terminated.
|
String |
attachVolume(VolumeRequest request) |
protected void |
checkSizeEquals(Collection<?> c,
int size) |
protected com.amazonaws.services.ec2.model.EbsBlockDevice |
convert(com.amazonaws.services.ec2.model.EbsInstanceBlockDevice device,
String snapshotId,
int sizeInGigabytes) |
protected com.amazonaws.services.ec2.model.BlockDeviceMapping |
convert(com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping mapping,
String snapshotId,
int sizeInGigabytes) |
String |
copyAmi(String region,
String ami) |
String |
copyAmi(String region,
String ami,
com.google.common.base.Optional<String> name) |
String |
copyAmi(String region,
String ami,
String name) |
com.amazonaws.services.ec2.model.Image |
createAmi(CreateAMIRequest request) |
protected com.amazonaws.services.ec2.model.Image |
createAmi(CreateAMIRequest create,
com.amazonaws.services.ec2.model.Instance instance,
com.amazonaws.services.ec2.model.Snapshot snapshot) |
void |
createSecurityGroup(KualiSecurityGroup group)
Create a new security group (it must not exist yet)
|
com.amazonaws.services.ec2.model.Snapshot |
createSnapshot(String volumeId,
String description,
int timeoutMillis)
Snapshot a volume.
|
String |
createVolume(CreateVolumeRequest request) |
String |
createVolume(String zone,
int size) |
void |
deleteSnapshot(String snapshotId) |
String |
deleteVolume(String volumeId) |
String |
detachVolume(VolumeRequest request) |
protected com.google.common.base.Optional<com.amazonaws.services.ec2.model.BlockDeviceMapping> |
findMatch(List<com.amazonaws.services.ec2.model.BlockDeviceMapping> mappings,
com.amazonaws.services.ec2.model.BlockDeviceMapping mapping) |
String |
getAccessKey() |
com.amazonaws.services.ec2.model.Image |
getAmi(String ami) |
EC2ServiceContext |
getContext() |
com.amazonaws.services.ec2.model.Image |
getImage(String imageId)
Return an Image object given an image id
|
List<com.amazonaws.services.ec2.model.Image> |
getImages() |
com.amazonaws.services.ec2.model.Instance |
getInstance(String instanceId)
Return an Amazon EC2 instance object given an instance id.
|
List<com.amazonaws.services.ec2.model.Instance> |
getInstances() |
protected List<com.amazonaws.services.ec2.model.Instance> |
getInstances(com.amazonaws.services.ec2.model.DescribeInstancesResult result) |
List<com.amazonaws.services.ec2.model.Instance> |
getInstances(List<String> instanceIds) |
protected com.amazonaws.services.ec2.model.IpPermission |
getIpPermission(Permission perm) |
protected List<com.amazonaws.services.ec2.model.IpPermission> |
getIpPermissions(Collection<Permission> permissions) |
protected com.google.common.base.Optional<com.amazonaws.services.ec2.model.KeyPairInfo> |
getKeyPairInfo(String name,
List<com.amazonaws.services.ec2.model.KeyPairInfo> list) |
List<com.amazonaws.services.ec2.model.Image> |
getMyImages()
Return a list of all the AMI's you own.
|
protected List<String> |
getNames(List<KualiSecurityGroup> groups) |
protected Permission |
getPermission(com.amazonaws.services.ec2.model.IpPermission perm) |
protected List<Permission> |
getPermissions(Collection<com.amazonaws.services.ec2.model.IpPermission> permissions) |
String |
getRegion() |
protected com.amazonaws.services.ec2.model.BlockDeviceMapping |
getRootBlockDeviceMapping(com.amazonaws.services.ec2.model.Image image) |
protected String |
getRootVolumeId(com.amazonaws.services.ec2.model.Instance instance) |
protected com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping |
getRootVolumeMapping(com.amazonaws.services.ec2.model.Instance instance) |
protected com.amazonaws.services.ec2.model.BlockDeviceMapping |
getRootVolumeMapping(com.amazonaws.services.ec2.model.Instance instance,
String snapshotId,
RootVolume rootVolume) |
protected com.amazonaws.services.ec2.model.RunInstancesRequest |
getRunInstanceRequest(LaunchInstanceContext context)
Return a request that spins up exactly one instance.
|
com.google.common.base.Optional<com.amazonaws.services.ec2.model.SecurityGroup> |
getSecurityGroup(String name)
Return the security group object associated with
name |
List<String> |
getSecurityGroupNames()
Return a list containing the names of all the security groups.
|
com.amazonaws.services.ec2.model.Snapshot |
getSnapshot(String snapshotId)
Return a snapshot object, given a snapshot id
|
protected String |
getStatus(List<com.amazonaws.services.ec2.model.InstanceStatus> statuses,
InstanceStatusType type,
String name) |
String |
getStatus(String instanceId,
InstanceStatusType type,
String statusName)
Each Amazon EC2 instance has a list of statuses associated with it.
|
protected com.google.common.base.Optional<String> |
getStatusDetail(com.amazonaws.services.ec2.model.InstanceStatusSummary summary,
String name) |
protected List<com.amazonaws.services.ec2.model.InstanceStatus> |
getStatusList(String instanceId) |
protected com.amazonaws.services.ec2.model.InstanceStatusSummary |
getSummary(com.amazonaws.services.ec2.model.InstanceStatus status,
InstanceStatusType type) |
protected com.google.common.base.Optional<com.amazonaws.services.ec2.model.Tag> |
getTag(List<com.amazonaws.services.ec2.model.Tag> tags,
String key) |
protected List<com.amazonaws.services.ec2.model.BlockDeviceMapping> |
getUpdatedBlockDeviceMappings(LaunchInstanceContext context) |
com.amazonaws.services.ec2.model.Volume |
getVolume(String volumeId) |
protected org.kuali.common.util.wait.WaitContext |
getWaitContext(int timeout) |
String |
importKey(String keyName,
String publicKey)
Import the public key using the given name into Amazon.
|
boolean |
isExistingKey(String keyName)
Return true if Amazon has a public key stored under this name.
|
boolean |
isExistingSecurityGroup(String name)
Return true if there is already a security group with the given name.
|
boolean |
isOnline(String instanceId)
This method returns true if the Amazon EC2 instance meets three conditions:
|
protected com.amazonaws.services.ec2.model.Instance |
issueRunInstanceRequest(LaunchInstanceContext context) |
com.amazonaws.services.ec2.model.Instance |
launchInstance(LaunchInstanceContext context)
Launch a single Amazon EC2 instance and wait until Amazon confirms that the instance is online and functioning.
|
List<com.amazonaws.services.ec2.model.Volume> |
listVolumes() |
protected void |
logPermissionChanges(KualiSecurityGroup group,
List<Permission> perms,
String changeDescription) |
void |
preventTermination(String instanceId)
Set a flag that prevent's an Amazon EC2 instance from being terminated.
|
protected void |
preventTermination(String instanceId,
boolean preventTermination) |
void |
purgeAmi(String imageId)
Deregister the AMI and delete any snapshots associated with it.
|
SetPermissionsResult |
setPermissions(String securityGroupName,
List<Permission> permissions)
Make the permissions for the indicated security group match the list provided.
|
com.amazonaws.services.ec2.model.Instance |
startInstance(String instanceId) |
void |
stopInstance(String instanceId) |
void |
tag(String resourceId,
List<com.amazonaws.services.ec2.model.Tag> tags)
Create tags on the indicated Amazon EC2 resource (instance, volume, snapshot, ami, etc).
|
void |
tag(String resourceId,
com.amazonaws.services.ec2.model.Tag tag)
Create tags on the indicated Amazon EC2 resource (instance, volume, snapshot, ami, etc).
|
void |
terminateInstance(String instanceId)
Terminate a single Amazon EC2 instance and wait until Amazon confirms that the instance has been terminated.
|
void |
terminateInstanceNoWait(String instanceId) |
void |
terminateInstancesNoWait(List<String> instanceIds) |
protected void |
updateRootBlockDeviceMapping(com.amazonaws.services.ec2.model.Image ami,
RootVolume rootVolume) |
protected void |
waitForAmiState(String imageId,
String state,
int timeoutMillis) |
protected void |
waitForOnlineConfirmation(com.amazonaws.services.ec2.model.Instance instance,
LaunchInstanceContext context) |
protected void |
waitForSnapshotState(String snapshotId,
String state,
int timeoutMillis) |
public DefaultEC2Service(com.amazonaws.auth.AWSCredentials credentials)
public DefaultEC2Service(com.amazonaws.auth.AWSCredentials credentials, String region)
public DefaultEC2Service(com.amazonaws.auth.AWSCredentials credentials, com.amazonaws.services.ec2.model.Region region)
public DefaultEC2Service(EC2ServiceContext context, org.kuali.common.util.wait.WaitService service)
public List<com.amazonaws.services.ec2.model.Volume> listVolumes()
listVolumes
in interface EC2Service
public com.amazonaws.services.ec2.model.Volume getVolume(String volumeId)
getVolume
in interface EC2Service
public String detachVolume(VolumeRequest request)
detachVolume
in interface EC2Service
public String getAccessKey()
getAccessKey
in interface EC2Service
public String getRegion()
getRegion
in interface EC2Service
public String copyAmi(String region, String ami)
copyAmi
in interface EC2Service
public String copyAmi(String region, String ami, String name)
copyAmi
in interface EC2Service
public String copyAmi(String region, String ami, com.google.common.base.Optional<String> name)
public List<com.amazonaws.services.ec2.model.Image> getImages()
getImages
in interface EC2Service
public void deleteSnapshot(String snapshotId)
deleteSnapshot
in interface EC2Service
public void purgeAmi(String imageId)
EC2Service
purgeAmi
in interface EC2Service
public com.amazonaws.services.ec2.model.Image createAmi(CreateAMIRequest request)
createAmi
in interface EC2Service
protected com.amazonaws.services.ec2.model.Image createAmi(CreateAMIRequest create, com.amazonaws.services.ec2.model.Instance instance, com.amazonaws.services.ec2.model.Snapshot snapshot)
protected com.amazonaws.services.ec2.model.BlockDeviceMapping getRootVolumeMapping(com.amazonaws.services.ec2.model.Instance instance, String snapshotId, RootVolume rootVolume)
protected com.amazonaws.services.ec2.model.BlockDeviceMapping convert(com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping mapping, String snapshotId, int sizeInGigabytes)
protected com.amazonaws.services.ec2.model.EbsBlockDevice convert(com.amazonaws.services.ec2.model.EbsInstanceBlockDevice device, String snapshotId, int sizeInGigabytes)
protected com.google.common.base.Optional<com.amazonaws.services.ec2.model.Tag> getTag(List<com.amazonaws.services.ec2.model.Tag> tags, String key)
protected String getRootVolumeId(com.amazonaws.services.ec2.model.Instance instance)
protected com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping getRootVolumeMapping(com.amazonaws.services.ec2.model.Instance instance)
public com.amazonaws.services.ec2.model.Snapshot createSnapshot(String volumeId, String description, int timeoutMillis)
EC2Service
createSnapshot
in interface EC2Service
public com.amazonaws.services.ec2.model.Snapshot getSnapshot(String snapshotId)
EC2Service
getSnapshot
in interface EC2Service
protected void waitForSnapshotState(String snapshotId, String state, int timeoutMillis)
protected void waitForAmiState(String imageId, String state, int timeoutMillis)
public List<com.amazonaws.services.ec2.model.Image> getMyImages()
EC2Service
getMyImages
in interface EC2Service
protected void checkSizeEquals(Collection<?> c, int size)
public com.amazonaws.services.ec2.model.Image getImage(String imageId)
EC2Service
getImage
in interface EC2Service
public String importKey(String keyName, String publicKey)
EC2Service
importKey
in interface EC2Service
public boolean isExistingKey(String keyName)
EC2Service
isExistingKey
in interface EC2Service
protected com.google.common.base.Optional<com.amazonaws.services.ec2.model.KeyPairInfo> getKeyPairInfo(String name, List<com.amazonaws.services.ec2.model.KeyPairInfo> list)
public List<String> getSecurityGroupNames()
EC2Service
getSecurityGroupNames
in interface EC2Service
public void createSecurityGroup(KualiSecurityGroup group)
EC2Service
createSecurityGroup
in interface EC2Service
public boolean isExistingSecurityGroup(String name)
EC2Service
isExistingSecurityGroup
in interface EC2Service
public SetPermissionsResult setPermissions(String securityGroupName, List<Permission> permissions)
EC2Service
Make the permissions for the indicated security group match the list provided.
setPermissions
in interface EC2Service
public com.google.common.base.Optional<com.amazonaws.services.ec2.model.SecurityGroup> getSecurityGroup(String name)
EC2Service
name
getSecurityGroup
in interface EC2Service
protected List<com.amazonaws.services.ec2.model.IpPermission> getIpPermissions(Collection<Permission> permissions)
protected List<Permission> getPermissions(Collection<com.amazonaws.services.ec2.model.IpPermission> permissions)
protected Permission getPermission(com.amazonaws.services.ec2.model.IpPermission perm)
protected com.amazonaws.services.ec2.model.IpPermission getIpPermission(Permission perm)
public com.amazonaws.services.ec2.model.Instance getInstance(String instanceId)
EC2Service
getInstance
in interface EC2Service
public List<com.amazonaws.services.ec2.model.Instance> getInstances(List<String> instanceIds)
getInstances
in interface EC2Service
protected List<com.amazonaws.services.ec2.model.Instance> getInstances(com.amazonaws.services.ec2.model.DescribeInstancesResult result)
public List<com.amazonaws.services.ec2.model.Instance> getInstances()
getInstances
in interface EC2Service
public com.amazonaws.services.ec2.model.Instance launchInstance(LaunchInstanceContext context)
EC2Service
launchInstance
in interface EC2Service
terminateInstance
public void allowTermination(String instanceId)
EC2Service
allowTermination
in interface EC2Service
preventTermination
public void preventTermination(String instanceId)
EC2Service
preventTermination
in interface EC2Service
allowTermination
public com.amazonaws.services.ec2.model.Instance startInstance(String instanceId)
startInstance
in interface EC2Service
public void stopInstance(String instanceId)
stopInstance
in interface EC2Service
public void terminateInstance(String instanceId)
EC2Service
terminateInstance
in interface EC2Service
launchInstance
public void terminateInstancesNoWait(List<String> instanceIds)
terminateInstancesNoWait
in interface EC2Service
public void terminateInstanceNoWait(String instanceId)
terminateInstanceNoWait
in interface EC2Service
public void tag(String resourceId, List<com.amazonaws.services.ec2.model.Tag> tags)
EC2Service
tag
in interface EC2Service
public void tag(String resourceId, com.amazonaws.services.ec2.model.Tag tag)
EC2Service
tag
in interface EC2Service
public boolean isOnline(String instanceId)
EC2Service
This method returns true if the Amazon EC2 instance meets three conditions:
running
state.If this method returns false, the instance cannot be used in any meaningful way.
isOnline
in interface EC2Service
public String getStatus(String instanceId, InstanceStatusType type, String statusName)
EC2Service
Each Amazon EC2 instance has a list of statuses associated with it.
Each status has a name and value and is associated with either the ability of Amazon's internal systems to determine that status (external to the instance itself) or with the status of something going on internally to the instance.
A SYSTEM status is analogous to saying "is powered on", or "is connected to the network", but says nothing about the state of any software running on the instance.
An INSTANCE status indicates something about the state of software running on the instance, aka "is operating system running"
getStatus
in interface EC2Service
protected void preventTermination(String instanceId, boolean preventTermination)
protected List<com.amazonaws.services.ec2.model.InstanceStatus> getStatusList(String instanceId)
protected String getStatus(List<com.amazonaws.services.ec2.model.InstanceStatus> statuses, InstanceStatusType type, String name)
protected com.amazonaws.services.ec2.model.InstanceStatusSummary getSummary(com.amazonaws.services.ec2.model.InstanceStatus status, InstanceStatusType type)
protected com.google.common.base.Optional<String> getStatusDetail(com.amazonaws.services.ec2.model.InstanceStatusSummary summary, String name)
protected com.amazonaws.services.ec2.model.Instance issueRunInstanceRequest(LaunchInstanceContext context)
protected void logPermissionChanges(KualiSecurityGroup group, List<Permission> perms, String changeDescription)
protected org.kuali.common.util.wait.WaitContext getWaitContext(int timeout)
protected void waitForOnlineConfirmation(com.amazonaws.services.ec2.model.Instance instance, LaunchInstanceContext context)
protected List<String> getNames(List<KualiSecurityGroup> groups)
protected com.amazonaws.services.ec2.model.RunInstancesRequest getRunInstanceRequest(LaunchInstanceContext context)
protected List<com.amazonaws.services.ec2.model.BlockDeviceMapping> getUpdatedBlockDeviceMappings(LaunchInstanceContext context)
protected com.google.common.base.Optional<com.amazonaws.services.ec2.model.BlockDeviceMapping> findMatch(List<com.amazonaws.services.ec2.model.BlockDeviceMapping> mappings, com.amazonaws.services.ec2.model.BlockDeviceMapping mapping)
protected void updateRootBlockDeviceMapping(com.amazonaws.services.ec2.model.Image ami, RootVolume rootVolume)
protected com.amazonaws.services.ec2.model.BlockDeviceMapping getRootBlockDeviceMapping(com.amazonaws.services.ec2.model.Image image)
public EC2ServiceContext getContext()
public String deleteVolume(String volumeId)
deleteVolume
in interface EC2Service
public String attachVolume(VolumeRequest request)
attachVolume
in interface EC2Service
public String createVolume(String zone, int size)
createVolume
in interface EC2Service
public String createVolume(CreateVolumeRequest request)
createVolume
in interface EC2Service
Copyright © 2004–2014 The Kuali Foundation. All rights reserved.