JCLOUDS-661: Supporting single port firewall rules in GCE

Corresponding test added in
https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=f3778b6
This commit is contained in:
Stuart Hendren 2014-08-12 10:26:05 +01:00 committed by Andrew Phillips
parent 5ec9bdb3f3
commit bc52da8a73
1 changed files with 6 additions and 2 deletions

View File

@ -220,8 +220,12 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
}
Firewall.Rule.Builder ruleBuilder = Firewall.Rule.builder();
ruleBuilder.IpProtocol(ipPermission.getIpProtocol());
if (ipPermission.getToPort() > 0) {
ruleBuilder.addPortRange(ipPermission.getFromPort(), ipPermission.getToPort());
if (ipPermission.getFromPort() > 0) {
if (ipPermission.getFromPort() == ipPermission.getToPort()) {
ruleBuilder.addPort(ipPermission.getToPort());
} else {
ruleBuilder.addPortRange(ipPermission.getFromPort(), ipPermission.getToPort());
}
}
fwOptions.addAllowedRule(ruleBuilder.build());