if (clusterSpec.getProvider().equals("ec2")) {
// This code (or something like it) may be added to jclouds (see
// http://code.google.com/p/jclouds/issues/detail?id=336).
// Until then we need this temporary workaround.
String region = EC2Utils.parseHandle(Iterables.get(instances, 0).getId())[0];
EC2Client ec2Client = EC2Client.class.cast(
computeServiceContext.getProviderSpecificContext().getApi());
String groupName = "jclouds#" + clusterSpec.getClusterName() + "#" + region;
for (String cidr : cidrs) {
for (int port : ports) {
ec2Client.getSecurityGroupServices()
.authorizeSecurityGroupIngressInRegion(region, groupName,
IpProtocol.TCP, port, port, cidr);
}
}
}