* Removes all rules.
*/
@Override
public void flush(ComputeService service, NodeMetadata node) {
String region = AWSUtils.parseHandle(node.getId())[0];
EC2Api ec2Api = service.getContext().unwrapApi(EC2Api.class);
String groupName = "jclouds#" + node.getGroup() + "#" + region;
Set<SecurityGroup> matchedSecurityGroups = ec2Api.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, groupName);
for (SecurityGroup securityGroup : matchedSecurityGroups) {
for (IpPermission ipPermission : securityGroup) {
for (String cdr : ipPermission.getCidrBlocks()) {
ec2Api.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, groupName,
IpProtocol.TCP, ipPermission.getFromPort(), ipPermission.getToPort(),
cdr
);
}
}