public class JcloudsLocationSecurityGroupCustomizer extends BasicJcloudsLocationCustomizer
This customizer can be injected into JcloudsLocation.obtainOnce(org.apache.brooklyn.util.core.config.ConfigBag)
using
the JcloudsLocationConfig.JCLOUDS_LOCATION_CUSTOMIZERS
configuration key.
It will be executed after the provisiioning of the JcloudsMachineLocation
to apply app-specific customization related to the security groups.
SecurityGroupExtension
is an optional extension to the jclouds compute
service. It allows the manipulation of security groups
.
BasicConfigurableObject.BasicConfigurationSupport
Configurable.ConfigurationSupport
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) |
java.util.Collection<org.jclouds.compute.domain.SecurityGroup> |
addPermissionsToLocationAndReturnSecurityGroup(JcloudsMachineLocation location,
java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions) |
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 <any> |
newAwsExceptionRetryPredicate() |
void |
removePermissionsFromLocation(JcloudsMachineLocation location,
java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions)
Removes the given security group permissions from the given node.
|
JcloudsLocationSecurityGroupCustomizer |
setRetryExceptionPredicate(<any> predicate) |
JcloudsLocationSecurityGroupCustomizer |
setSshCidrSupplier(<any> cidrSupplier) |
apply, customize, customize, customize, customize, postRelease, postReleaseOnObtainError, preRelease, preReleaseOnObtainError
config, getBrooklynManagementContext, getConfig, getId, setManagementContext
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(<any> 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(<any> 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)
public JcloudsLocationSecurityGroupCustomizer addPermissionsToLocation(JcloudsMachineLocation location, SecurityGroupDefinition securityGroupDefinition)
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.
TODO investigate whether this can be improved. Can the synchronization be moved to
the class org.apache.brooklyn.location.jclouds.networking.SecurityGroupEditor?
location
- Location to gain permissionspermissions
- The set of permissions to be applied to the locationpublic java.util.Collection<org.jclouds.compute.domain.SecurityGroup> addPermissionsToLocationAndReturnSecurityGroup(JcloudsMachineLocation location, java.lang.Iterable<org.jclouds.net.domain.IpPermission> permissions)
public 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.
location
- Location of the node to remove permissions frompermissions
- The set of permissions to be removed from the nodepublic 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 static <any> newAwsExceptionRetryPredicate()
AWSResponseException
whose error code is either InvalidGroup.InUse
, DependencyViolation
or
RequestLimitExceeded
.