org.jclouds.compute.stub.extensions
Class StubSecurityGroupExtension

java.lang.Object
  extended by org.jclouds.compute.stub.extensions.StubSecurityGroupExtension
All Implemented Interfaces:
SecurityGroupExtension

public class StubSecurityGroupExtension
extends Object
implements SecurityGroupExtension

An extension to compute service to allow for the manipulation of SecurityGroups. Implementation is optional by providers.


Constructor Summary
StubSecurityGroupExtension(ConcurrentMap<String,SecurityGroup> groups, com.google.common.util.concurrent.ListeningExecutorService ioExecutor, com.google.common.base.Supplier<org.jclouds.domain.Location> location, javax.inject.Provider<Integer> groupIdProvider, org.jclouds.location.suppliers.all.JustProvider locationSupplier, com.google.common.collect.Multimap<String,SecurityGroup> groupsForNodes)
           
 
Method Summary
 SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group)
          Add a @{link IpPermission} to an existing @{link SecurityGroup}.
 SecurityGroup addIpPermission(IpProtocol protocol, int startPort, int endPort, com.google.common.collect.Multimap<String,String> tenantIdGroupNamePairs, Iterable<String> ipRanges, Iterable<String> groupIds, SecurityGroup group)
          Add a @{link IpPermission} to an existing @{link SecurityGroup}, based on the parameters given.
 SecurityGroup createSecurityGroup(String name, org.jclouds.domain.Location location)
          Create a new @{link SecurityGroup} from the parameters given.
 SecurityGroup getSecurityGroupById(String id)
          Get a security group by id.
 Set<SecurityGroup> listSecurityGroups()
          List security groups.
 Set<SecurityGroup> listSecurityGroupsForNode(String nodeId)
          List security groups for a given instance given the instance's ID.
 Set<SecurityGroup> listSecurityGroupsInLocation(org.jclouds.domain.Location location)
          List security groups in a given @{link Location}.
 SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group)
          Remove a @{link IpPermission} from an existing @{link SecurityGroup}.
 SecurityGroup removeIpPermission(IpProtocol protocol, int startPort, int endPort, com.google.common.collect.Multimap<String,String> tenantIdGroupNamePairs, Iterable<String> ipRanges, Iterable<String> groupIds, SecurityGroup group)
          Remove a @{link IpPermission} from an existing @{link SecurityGroup}, based on the parameters given.
 boolean removeSecurityGroup(String id)
          Remove an existing @{link SecurityGroup}, and its permissions.
 boolean supportsGroupIds()
          Returns true if this SecurityGroupExtension supports group IDs.
 boolean supportsPortRangesForGroups()
          Returns true if this SecurityGroupExtension supports port ranges for group authorization.
 boolean supportsTenantIdGroupIdPairs()
          Returns true if this SecurityGroupExtension supports tenant ID + group ID pairs.
 boolean supportsTenantIdGroupNamePairs()
          Returns true if this SecurityGroupExtension supports tenant ID + group name pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StubSecurityGroupExtension

@Inject
public StubSecurityGroupExtension(ConcurrentMap<String,SecurityGroup> groups,
                                         @Named(value="jclouds.io-worker-threads")
                                         com.google.common.util.concurrent.ListeningExecutorService ioExecutor,
                                         com.google.common.base.Supplier<org.jclouds.domain.Location> location,
                                         @Named(value="GROUP_ID")
                                         javax.inject.Provider<Integer> groupIdProvider,
                                         org.jclouds.location.suppliers.all.JustProvider locationSupplier,
                                         com.google.common.collect.Multimap<String,SecurityGroup> groupsForNodes)
Method Detail

listSecurityGroups

public Set<SecurityGroup> listSecurityGroups()
Description copied from interface: SecurityGroupExtension
List security groups.

Specified by:
listSecurityGroups in interface SecurityGroupExtension
Returns:
The set of @{link SecurityGroup}s we have access to.

listSecurityGroupsInLocation

public Set<SecurityGroup> listSecurityGroupsInLocation(org.jclouds.domain.Location location)
Description copied from interface: SecurityGroupExtension
List security groups in a given @{link Location}.

Specified by:
listSecurityGroupsInLocation in interface SecurityGroupExtension
Returns:
The set of @{link SecurityGroup}s we have access to in the given location.

listSecurityGroupsForNode

public Set<SecurityGroup> listSecurityGroupsForNode(String nodeId)
Description copied from interface: SecurityGroupExtension
List security groups for a given instance given the instance's ID.

Specified by:
listSecurityGroupsForNode in interface SecurityGroupExtension
Returns:
The set of @{link SecurityGroup}s for the given instance..

getSecurityGroupById

public SecurityGroup getSecurityGroupById(String id)
Description copied from interface: SecurityGroupExtension
Get a security group by id.

Specified by:
getSecurityGroupById in interface SecurityGroupExtension
Returns:
The @{link SecurityGroup}, if it exists.

createSecurityGroup

public SecurityGroup createSecurityGroup(String name,
                                         org.jclouds.domain.Location location)
Description copied from interface: SecurityGroupExtension
Create a new @{link SecurityGroup} from the parameters given.

Specified by:
createSecurityGroup in interface SecurityGroupExtension
Parameters:
name - The name of the security group
location - The @{link Location} of the security group
Returns:
The SecurityGroup that has been created.

removeSecurityGroup

public boolean removeSecurityGroup(String id)
Description copied from interface: SecurityGroupExtension
Remove an existing @{link SecurityGroup}, and its permissions.

Specified by:
removeSecurityGroup in interface SecurityGroupExtension
Parameters:
id - The id of the SecurityGroup to delete.
Returns:
true if we were able to remove the group, false otherwise.

addIpPermission

public SecurityGroup addIpPermission(IpPermission ipPermission,
                                     SecurityGroup group)
Description copied from interface: SecurityGroupExtension
Add a @{link IpPermission} to an existing @{link SecurityGroup}. Applies the permission to the security group on the provider.

Specified by:
addIpPermission in interface SecurityGroupExtension
group - The SecurityGroup to add the permission to.
Returns:
The SecurityGroup with the new permission added, after the permission has been applied on the provider.

addIpPermission

public SecurityGroup addIpPermission(IpProtocol protocol,
                                     int startPort,
                                     int endPort,
                                     com.google.common.collect.Multimap<String,String> tenantIdGroupNamePairs,
                                     Iterable<String> ipRanges,
                                     Iterable<String> groupIds,
                                     SecurityGroup group)
Description copied from interface: SecurityGroupExtension
Add a @{link IpPermission} to an existing @{link SecurityGroup}, based on the parameters given. Applies the permission to the security group on the provider.

Specified by:
addIpPermission in interface SecurityGroupExtension
Parameters:
protocol - The @{link IpProtocol} for the permission.
startPort - The first port in the range to be opened, or -1 for ICMP.
endPort - The last port in the range to be opened, or -1 for ICMP.
tenantIdGroupNamePairs - source of traffic allowed is on basis of another group in a tenant, as opposed to by cidr
ipRanges - An Iterable of Strings representing the IP range(s) the permission should allow.
groupIds - An Iterable of @{link SecurityGroup} IDs this permission should allow.
group - The SecurityGroup to add the permission to.
Returns:
The SecurityGroup with the new permission added, after the permission has been applied on the provider.

removeIpPermission

public SecurityGroup removeIpPermission(IpPermission ipPermission,
                                        SecurityGroup group)
Description copied from interface: SecurityGroupExtension
Remove a @{link IpPermission} from an existing @{link SecurityGroup}. Removes the permission from the security group on the provider.

Specified by:
removeIpPermission in interface SecurityGroupExtension
group - The SecurityGroup to remove the permission from.
Returns:
The SecurityGroup with the permission removed, after the permission has been removed on the provider.

removeIpPermission

public SecurityGroup removeIpPermission(IpProtocol protocol,
                                        int startPort,
                                        int endPort,
                                        com.google.common.collect.Multimap<String,String> tenantIdGroupNamePairs,
                                        Iterable<String> ipRanges,
                                        Iterable<String> groupIds,
                                        SecurityGroup group)
Description copied from interface: SecurityGroupExtension
Remove a @{link IpPermission} from an existing @{link SecurityGroup}, based on the parameters given. Removes the permission from the security group on the provider.

Specified by:
removeIpPermission in interface SecurityGroupExtension
Parameters:
protocol - The @{link IpProtocol} for the permission.
startPort - The first port in the range to be opened, or -1 for ICMP.
endPort - The last port in the range to be opened, or -1 for ICMP.
tenantIdGroupNamePairs - source of traffic allowed is on basis of another group in a tenant, as opposed to by cidr
ipRanges - An Iterable of Strings representing the IP range(s) the permission should allow.
groupIds - An Iterable of @{link SecurityGroup} IDs this permission should allow.
group - The SecurityGroup to remove the permission from.
Returns:
The SecurityGroup with the permission removed, after the permission has been removed from the provider.

supportsTenantIdGroupNamePairs

public boolean supportsTenantIdGroupNamePairs()
Description copied from interface: SecurityGroupExtension
Returns true if this SecurityGroupExtension supports tenant ID + group name pairs.

Specified by:
supportsTenantIdGroupNamePairs in interface SecurityGroupExtension

supportsTenantIdGroupIdPairs

public boolean supportsTenantIdGroupIdPairs()
Description copied from interface: SecurityGroupExtension
Returns true if this SecurityGroupExtension supports tenant ID + group ID pairs.

Specified by:
supportsTenantIdGroupIdPairs in interface SecurityGroupExtension

supportsGroupIds

public boolean supportsGroupIds()
Description copied from interface: SecurityGroupExtension
Returns true if this SecurityGroupExtension supports group IDs.

Specified by:
supportsGroupIds in interface SecurityGroupExtension

supportsPortRangesForGroups

public boolean supportsPortRangesForGroups()
Description copied from interface: SecurityGroupExtension
Returns true if this SecurityGroupExtension supports port ranges for group authorization.

Specified by:
supportsPortRangesForGroups in interface SecurityGroupExtension


Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.