Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cumulus NCLU configuration parsing skeleton #3453

Merged
merged 4 commits into from
Mar 26, 2019

Conversation

arifogel
Copy link
Member

No description provided.

@batfish-bot
Copy link

This change is Reviewable

@codecov
Copy link

codecov bot commented Mar 22, 2019

Codecov Report

Merging #3453 into master will decrease coverage by 0.02%.
The diff coverage is 81.48%.

@@             Coverage Diff              @@
##             master    #3453      +/-   ##
============================================
- Coverage     73.13%   73.11%   -0.03%     
- Complexity    23787    23864      +77     
============================================
  Files          2062     2077      +15     
  Lines         99540    99905     +365     
  Branches      11935    11959      +24     
============================================
+ Hits          72800    73042     +242     
- Misses        21416    21503      +87     
- Partials       5324     5360      +36
Impacted Files Coverage Δ Complexity Δ
...ava/org/batfish/datamodel/ConfigurationFormat.java 100% <100%> (ø) 3 <0> (ø) ⬇️
...a/org/batfish/job/ParseVendorConfigurationJob.java 76.61% <100%> (+0.47%) 34 <0> (+1) ⬆️
...cumulus_nclu/CumulusNcluControlPlaneExtractor.java 100% <100%> (ø) 3 <3> (?)
...presentation/cumulus/CumulusNcluConfiguration.java 100% <100%> (ø) 6 <6> (?)
...rammar/cumulus_nclu/CumulusNcluCombinedParser.java 100% <100%> (ø) 2 <2> (?)
...ish/grammar/VendorConfigurationFormatDetector.java 77.86% <100%> (+0.62%) 82 <2> (+3) ⬆️
.../cumulus_nclu/CumulusNcluConfigurationBuilder.java 44.44% <44.44%> (ø) 3 <3> (?)
...c/main/java/org/batfish/dataplane/rib/RibTree.java 78.72% <0%> (-10.64%) 23% <0%> (-1%)
...g/batfish/datamodel/acl/IpAccessListLineIndex.java 33.33% <0%> (-5.56%) 4% <0%> (-1%)
.../org/batfish/datamodel/ForwardingAnalysisImpl.java 92.57% <0%> (-2.02%) 167% <0%> (+8%)
... and 51 more

@progwriter progwriter removed their request for review March 25, 2019 19:05
Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 16 of 16 files at r1.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @arifogel, @corinaminer, and @sfraint)

a discussion (no related file):
Javadoc everything not overridden.



projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 16 at r1 (raw file):

import org.batfish.vendor.StructureType;

@ParametersAreNonnullByDefault

put this at the package-info.java module level rather than individual files?


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 20 at r1 (raw file):

length() == 0

isEmpty()?


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 26 at r1 (raw file):

      return text;
    } else if (text.charAt(text.length() - 1) != '"') {
      throw new BatfishException("Improperly-quoted string");

include string in error?


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 45 at r1 (raw file):

  private String convErrorMessage(Class<?> type, ParserRuleContext ctx) {
    return String.format("Could not convert to %s: %s", type.getSimpleName(), getFullText(ctx));

inline


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 56 at r1 (raw file):

  /** Mark the specified structure as defined on each line in the supplied context */
  @SuppressWarnings("unused")
  private void defineStructure(StructureType type, String name, RuleContext ctx) {

I don't understand this one. Is this a pre-post-processing-group thing from juniper? Does it apply here?


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 73 at r1 (raw file):

  }

  public CumulusNcluConfiguration getConfiguration() {

@nullable


tests/parsing-tests/networks/unit-tests/configs/cumulus_nclu, line 76 at r1 (raw file):

# There are some configuration commands that are not yet supported by nclu.
# ========================================================================
sudo sh -c "printf 'username cumulus nopassword\n' >> /etc/frr/frr.conf"

these lines are not lexed/parsed correctly - I think it has to do with >>, plus escaped inner contents? If that's intended for now, okay.

            "        IP_PREFIX:'0.0.0.0/0'",
            "        WORD:'192.0.2.1\\n''",
            "        WORD:'>>'",
            "        WORD:'/etc/frr/frr.conf\"'",
            "        NEWLINE:'\\n\\n')))",

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @arifogel, @corinaminer, @dhalperi, and @sfraint)


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 16 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

put this at the package-info.java module level rather than individual files?

What about the generated Java files in this package? I don't intend it to apply to those.


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 20 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
length() == 0

isEmpty()?

Removing until needed.


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 26 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

include string in error?

N/A


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 45 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

inline

done


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 56 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

I don't understand this one. Is this a pre-post-processing-group thing from juniper? Does it apply here?

lazy copypaste. removed as unnecessary.


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 73 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

@nullable

done

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @arifogel, @corinaminer, and @sfraint)


projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 16 at r1 (raw file):

Previously, arifogel (Ari Fogel) wrote…

What about the generated Java files in this package? I don't intend it to apply to those.

Are you sure? The context objects in enter/exit rules are assumed to be Nonnull, for instance. But:

You can always either:

  • override and add nullable for functions you need to call with null values, if such exist.
  • use a different package (should probably do this in the long term, actually).

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 12 of 16 files reviewed, 3 unresolved discussions (waiting on @arifogel, @corinaminer, @dhalperi, and @sfraint)


tests/parsing-tests/networks/unit-tests/configs/cumulus_nclu, line 76 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

these lines are not lexed/parsed correctly - I think it has to do with >>, plus escaped inner contents? If that's intended for now, okay.

            "        IP_PREFIX:'0.0.0.0/0'",
            "        WORD:'192.0.2.1\\n''",
            "        WORD:'>>'",
            "        WORD:'/etc/frr/frr.conf\"'",
            "        NEWLINE:'\\n\\n')))",

I'm not sure what you mean. To be clear, that is correct for the line below your comment.
This is the whole output for the `sudo lines:

            "  (statement",
            "    (s_null",
            "      SUDO:'sudo'",
            "      (null_rest_of_line",
            "        WORD:'sh'",
            "        WORD:'-c'",
            "        WORD:'\"printf'",
            "        WORD:''username'",
            "        WORD:'cumulus'",
            "        WORD:'nopassword\\n''",
            "        WORD:'>>'",
            "        WORD:'/etc/frr/frr.conf\"'",
            "        NEWLINE:'\\n')))",
            "  (statement",
            "    (s_null",
            "      SUDO:'sudo'",                                                                                                                                                                                  
            "      (null_rest_of_line",
            "        WORD:'sh'",
            "        WORD:'-c'",
            "        WORD:'\"printf'",
            "        WORD:''vrf'",
            "        WORD:'vrf1\\n'",
            "        WORD:'ip'",
            "        WORD:'route'",
            "        IP_PREFIX:'0.0.0.0/0'",
            "        WORD:'192.0.2.1\\n''",
            "        WORD:'>>'",
            "        WORD:'/etc/frr/frr.conf\"'",
            "        NEWLINE:'\\n\\n')))",

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 12 of 16 files reviewed, 3 unresolved discussions (waiting on @arifogel, @corinaminer, @dhalperi, and @sfraint)


tests/parsing-tests/networks/unit-tests/configs/cumulus_nclu, line 76 at r1 (raw file):

Previously, arifogel (Ari Fogel) wrote…

I'm not sure what you mean. To be clear, that is correct for the line below your comment.
This is the whole output for the `sudo lines:

            "  (statement",
            "    (s_null",
            "      SUDO:'sudo'",
            "      (null_rest_of_line",
            "        WORD:'sh'",
            "        WORD:'-c'",
            "        WORD:'\"printf'",
            "        WORD:''username'",
            "        WORD:'cumulus'",
            "        WORD:'nopassword\\n''",
            "        WORD:'>>'",
            "        WORD:'/etc/frr/frr.conf\"'",
            "        NEWLINE:'\\n')))",
            "  (statement",
            "    (s_null",
            "      SUDO:'sudo'",                                                                                                                                                                                  
            "      (null_rest_of_line",
            "        WORD:'sh'",
            "        WORD:'-c'",
            "        WORD:'\"printf'",
            "        WORD:''vrf'",
            "        WORD:'vrf1\\n'",
            "        WORD:'ip'",
            "        WORD:'route'",
            "        IP_PREFIX:'0.0.0.0/0'",
            "        WORD:'192.0.2.1\\n''",
            "        WORD:'>>'",
            "        WORD:'/etc/frr/frr.conf\"'",
            "        NEWLINE:'\\n\\n')))",

Oh if you are talking about the 192.0.2.1\n not being lexed as IP_PREFIX followed by NEWLINE, then yeah that is intended for now.

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 12 of 16 files reviewed, 3 unresolved discussions (waiting on @arifogel, @corinaminer, @dhalperi, and @sfraint)


tests/parsing-tests/networks/unit-tests/configs/cumulus_nclu, line 76 at r1 (raw file):

Previously, arifogel (Ari Fogel) wrote…

Oh if you are talking about the 192.0.2.1\n not being lexed as IP_PREFIX followed by NEWLINE, then yeah that is intended for now.

I mean IP_PREFIX => IP_ADDRESS

Copy link
Member Author

@arifogel arifogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 12 of 18 files reviewed, 2 unresolved discussions (waiting on @corinaminer, @dhalperi, and @sfraint)

a discussion (no related file):

Previously, dhalperi (Dan Halperin) wrote…

Javadoc everything not overridden.

done



projects/batfish/src/main/java/org/batfish/grammar/cumulus_nclu/CumulusNcluConfigurationBuilder.java, line 16 at r1 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Are you sure? The context objects in enter/exit rules are assumed to be Nonnull, for instance. But:

You can always either:

  • override and add nullable for functions you need to call with null values, if such exist.
  • use a different package (should probably do this in the long term, actually).

k done

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 6 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @corinaminer and @sfraint)

@dhalperi dhalperi merged commit 418dfac into batfish:master Mar 26, 2019
@arifogel arifogel deleted the ari-cumulus-nclu-skeleton branch March 28, 2019 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants