for (EC2SecurityGroup group : groups) {
CloudStackKeyValue pair = new CloudStackKeyValue();
pair.setKeyValue(group.getAccount(), group.getName());
secGroupList.add(pair);
}
CloudStackSecurityGroup resp = null;
if (ipPerm.getProtocol().equalsIgnoreCase("icmp")) {
resp = getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null, null,
ipPerm.getIcmpCode(), ipPerm.getIcmpType(), ipPerm.getProtocol(), null,
request.getName(), null, secGroupList);
} else {
resp = getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null,
ipPerm.getToPort().longValue(), null, null, ipPerm.getProtocol(), null, request.getName(),
ipPerm.getFromPort().longValue(), secGroupList);
}
if (resp != null ){
List<CloudStackIngressRule> ingressRules = resp.getIngressRules();
for (CloudStackIngressRule ingressRule : ingressRules)
if (ingressRule.getRuleId() == null) return false;
} else {
return false;
}