cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From koushik-das <...@git.apache.org>
Subject [GitHub] cloudstack pull request: SecurityGroupRulesCmd code cleanup
Date Mon, 11 Apr 2016 16:13:48 GMT
Github user koushik-das commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1287#discussion_r59233185
  
    --- Diff: core/src/com/cloud/agent/api/SecurityGroupRulesCmd.java ---
    @@ -200,52 +167,43 @@ public String getSecIpsString() {
             return sb.toString();
         }
     
    +    public String stringifyRules() {
    +        StringBuilder ruleBuilder = new StringBuilder();
    +        stringifyRulesFor(getIngressRuleSet(), INGRESS_RULE, false, ruleBuilder);
    +        stringifyRulesFor(getEgressRuleSet(), EGRESS_RULE, false, ruleBuilder);
    +        return ruleBuilder.toString();
    +    }
    +
         public String stringifyCompressedRules() {
             StringBuilder ruleBuilder = new StringBuilder();
    -        for (SecurityGroupRulesCmd.IpPortAndProto ipPandP : getIngressRuleSet()) {
    -            ruleBuilder.append("I:").append(ipPandP.getProto()).append(":").append(ipPandP.getStartPort()).append(":").append(ipPandP.getEndPort()).append(":");
    -            for (String cidr : ipPandP.getAllowedCidrs()) {
    -                //convert cidrs in the form "a.b.c.d/e" to "hexvalue of 32bit ip/e"
    -                ruleBuilder.append(compressCidr(cidr)).append(",");
    -            }
    -            ruleBuilder.append("NEXT");
    -            ruleBuilder.append(" ");
    -        }
    -        for (SecurityGroupRulesCmd.IpPortAndProto ipPandP : getEgressRuleSet()) {
    -            ruleBuilder.append("E:").append(ipPandP.getProto()).append(":").append(ipPandP.getStartPort()).append(":").append(ipPandP.getEndPort()).append(":");
    +        stringifyRulesFor(getEgressRuleSet(), INGRESS_RULE, true, ruleBuilder);
    +        stringifyRulesFor(getEgressRuleSet(), EGRESS_RULE, true, ruleBuilder);
    +        return ruleBuilder.toString();
    +    }
    +
    +    /**
    +     * @param ipPandPs
    +     * @param gression
    +     * @param compress
    +     * @param ruleBuilder
    +     */
    +    void stringifyRulesFor(SecurityGroupRulesCmd.IpPortAndProto[] ipPandPs, String gression,
boolean compress, StringBuilder ruleBuilder) {
    --- End diff --
    
    @DaanHoogland My bad, was looking at the individual commits. Saw that this is already
fixed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message