public class JcloudsLocationSecurityGroupCustomizer extends BasicJcloudsLocationCustomizer
is an optional extension to jclouds compute service. It allows the manipulation of
{@link SecurityGroup}s.
This customizer can be injected into {@link JcloudsLocation#obtainOnce} using
It will be executed after the provisiioning of the {@link JcloudsMachineLocation} to apply app-specific
customization related to the security groups.
Modifier and Type | Method and Description |
---|---|
JcloudsLocationSecurityGroupCustomizer |
addPermissionsToLocation(JcloudsMachineLocation location,
org.jclouds.net.domain.IpPermission... permissions) |
JcloudsLocationSecurityGroupCustomizer |
addPermissionsToLocation(JcloudsMachineLocation location,
java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions)
Applies the given security group permissions to the given location.
|
JcloudsLocationSecurityGroupCustomizer |
addPermissionsToLocation(JcloudsMachineLocation location,
SecurityGroupDefinition securityGroupDefinition) |
void |
customize(JcloudsLocation location,
org.jclouds.compute.ComputeService computeService,
org.jclouds.compute.domain.Template template)
Replaces security groups configured on the given template with one that allows
SSH access on port 22 and allows communication on all ports between machines in
the same group.
|
java.lang.String |
getBrooklynCidrBlock() |
static JcloudsLocationSecurityGroupCustomizer |
getInstance(Entity entity)
Gets a customizer for the given entity's application.
|
static JcloudsLocationSecurityGroupCustomizer |
getInstance(java.lang.String applicationId)
Gets the customizer for the given applicationId.
|
static |
newAwsExceptionRetryPredicate() |
void |
removePermissionsFromLocation(JcloudsMachineLocation location,
java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions)
Removes the given security group permissions from the given node with the given compute service.
|
JcloudsLocationSecurityGroupCustomizer |
setRetryExceptionPredicate( |
JcloudsLocationSecurityGroupCustomizer |
setSshCidrSupplier( |
customize, customize, customize, customize, postRelease, postRelease, preRelease, preRelease
public static JcloudsLocationSecurityGroupCustomizer getInstance(java.lang.String applicationId)
applicationId
- An identifier for the application the customizer is to be used forpublic static JcloudsLocationSecurityGroupCustomizer getInstance(Entity entity)
entity
- The entity the customizer is to be used forpublic JcloudsLocationSecurityGroupCustomizer setRetryExceptionPredicate(predicate)
predicate
- A predicate whose return value indicates whether a request to add a security group
or permission may be retried after its input Exception
was thrown.public JcloudsLocationSecurityGroupCustomizer setSshCidrSupplier(cidrSupplier)
cidrSupplier
- A supplier returning a CIDR for hosts that are allowed to SSH to locations.public JcloudsLocationSecurityGroupCustomizer addPermissionsToLocation(JcloudsMachineLocation location, org.jclouds.net.domain.IpPermission... permissions)
#addPermissionsToLocation(JcloudsSshMachineLocation, java.lang.Iterable)
public JcloudsLocationSecurityGroupCustomizer addPermissionsToLocation(JcloudsMachineLocation location, SecurityGroupDefinition securityGroupDefinition)
#addPermissionsToLocation(JcloudsSshMachineLocation, java.lang.Iterable)
public JcloudsLocationSecurityGroupCustomizer addPermissionsToLocation(JcloudsMachineLocation location, java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions)
Takes no action if the location's compute service does not have a security group extension.
The synchronized
block is to serialize the permission changes, preventing race
conditions in some clouds. If multiple customizations of the same group are done in parallel
the changes may not be picked up by later customizations, meaning the same rule could possibly be
added twice, which would fail. A finer grained mechanism would be preferable here, but
we have no access to the information required, so this brute force serializing is required.
location
- Location to gain permissionspermissions
- The set of permissions to be applied to the locationpublic void removePermissionsFromLocation(JcloudsMachineLocation location, java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions)
Takes no action if the compute service does not have a security group extension.
permissions
- The set of permissions to be removed from the locationlocation
- Location to remove permissions frompublic void customize(JcloudsLocation location, org.jclouds.compute.ComputeService computeService, org.jclouds.compute.domain.Template template)
locations
.
This method is called by Brooklyn when obtaining machines, as part of the
JcloudsLocationCustomizer
contract. It
should not be called from anywhere else.
customize
in interface JcloudsLocationCustomizer
customize
in class BasicJcloudsLocationCustomizer
location
- The Brooklyn location that has called this method while obtaining a machinecomputeService
- The compute service being used by the location argument to provision a machinetemplate
- The machine template created by the location argumentpublic java.lang.String getBrooklynCidrBlock()
public staticnewAwsExceptionRetryPredicate()
AWSResponseException
whose error code is either InvalidGroup.InUse
, DependencyViolation
or
RequestLimitExceeded
.