ppe.ec2
Class SecurityGroupFactory

java.lang.Object
  extended by ppe.ec2.SecurityGroupFactory

public class SecurityGroupFactory
extends java.lang.Object


Constructor Summary
SecurityGroupFactory(ParamsEc2 params, com.amazonaws.services.ec2.AmazonEC2Client ec2Client)
           
 
Method Summary
 java.lang.String createOneTimeSecurityGroup()
          Creates an ec2 security group that works for mpi.
 java.lang.String createStandardSecurityGroup(java.lang.String groupName, java.lang.String description)
          Creates a group with ssh (tcp port 22) open to the world and everything else open to group members only.
 void deleteOneTimeSecurityGroup(java.lang.String securityGroupName)
          If the specified group is not a 'one time' group, this method does nothing.
 int deleteOneTimeSecurityGroups()
          This method deletes all security groups owned by the user that have names starting with "<User name>_mpi_ec2_", where <User name> is the value of the system property user.name.
 java.util.List<com.amazonaws.services.ec2.model.SecurityGroup> getExtantSecurityGroups()
           
 java.lang.String getOneTimeSecurityGroupName()
          Gets the name of a security group that has prefix "<User name>_mpi_ec2_", (where <User name> is the value of the system property user.name), if one exists.
 java.util.List<java.lang.String> getOneTimeSecurityGroups(NetworkInfo ni)
           
 java.util.List<java.lang.String> getSecurityGroups(NetworkInfo ni)
          Gets a unique list of all security groups to which instances with the networkID belong.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityGroupFactory

public SecurityGroupFactory(ParamsEc2 params,
                            com.amazonaws.services.ec2.AmazonEC2Client ec2Client)
Method Detail

createOneTimeSecurityGroup

public java.lang.String createOneTimeSecurityGroup()
                                            throws ParamMissingException
Creates an ec2 security group that works for mpi. This group is created with a unique name based on user.name (unless a securityGroupNameBase has been specified as a parameter). All ec2 instances are assigned to this security group. The security group is deleted by #terminateInstances() . If you terminate you ec2 instances any other way (e.g. using the AWS Management Console), you should delete this security group.

Returns:
the new security group name.
Throws:
ParamMissingException

createStandardSecurityGroup

public java.lang.String createStandardSecurityGroup(java.lang.String groupName,
                                                    java.lang.String description)
                                             throws ParamMissingException
Creates a group with ssh (tcp port 22) open to the world and everything else open to group members only.

Parameters:
groupName -
Returns:
Throws:
ParamMissingException

getOneTimeSecurityGroupName

public java.lang.String getOneTimeSecurityGroupName()
                                             throws ParamMissingException
Gets the name of a security group that has prefix "<User name>_mpi_ec2_", (where <User name> is the value of the system property user.name), if one exists.

If more than one security group meets the criteria, the first one encountered is return.

Returns:
A security group name or null.
Throws:
ParamMissingException

deleteOneTimeSecurityGroups

public int deleteOneTimeSecurityGroups()
                                throws ParamMissingException
This method deletes all security groups owned by the user that have names starting with "<User name>_mpi_ec2_", where <User name> is the value of the system property user.name.

Throws:
ParamMissingException

getExtantSecurityGroups

public java.util.List<com.amazonaws.services.ec2.model.SecurityGroup> getExtantSecurityGroups()

deleteOneTimeSecurityGroup

public void deleteOneTimeSecurityGroup(java.lang.String securityGroupName)
If the specified group is not a 'one time' group, this method does nothing. A 'one time' group has a name that starts with prefix created by buildSecurityGroupNamePrefix().

Parameters:
securityGroupName -

getSecurityGroups

public java.util.List<java.lang.String> getSecurityGroups(NetworkInfo ni)
Gets a unique list of all security groups to which instances with the networkID belong.

Parameters:
networkID -
Returns:

getOneTimeSecurityGroups

public java.util.List<java.lang.String> getOneTimeSecurityGroups(NetworkInfo ni)