Skip to content

Commit

Permalink
explorer: Update YANG parser to 1.2.2 & remove YANG blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
sbyx committed Apr 10, 2018
1 parent b0c34dd commit cccc6fc
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
2 changes: 1 addition & 1 deletion explorer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
<version>1.1.3-Carbon</version>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.server.Responsive;
import com.vaadin.server.ThemeResource;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.themes.ValoTheme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class YangParser implements SchemaSourceProvider<YangTextSchemaSource> {
private SchemaContext schemaContext;
private InMemorySchemaSourceCache<ASTSchemaSource> cache;
private List<String> warnings;
private Map<String,String> blacklist;

YangParser() {
//System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
Expand All @@ -56,16 +55,6 @@ public class YangParser implements SchemaSourceProvider<YangTextSchemaSource> {
repository.registerSchemaSourceListener(TextToASTTransformer.create(repository, repository));
cache = InMemorySchemaSourceCache.createSoftCache(repository, ASTSchemaSource.class);
warnings = new LinkedList<>();
blacklist = new HashMap<>();

// Some Openconfig YANG models use YANG 1.1 feature, but claim to be YANG 1.0
// exclude those, since they mess up the parser
blacklist.put("openconfig-telemetry", "2017-02-20");
blacklist.put("openconfig-bgp", "2016-06-06");
blacklist.put("openconfig-bgp-policy", "2016-06-06");
blacklist.put("openconfig-mpls-rsvp", "2016-12-15");
blacklist.put("openconfig-mpls-te", "2016-12-15");
blacklist.put("openconfig-if-ip", "2016-12-22");
}

public Collection<YangTextSchemaSource> getSources() {
Expand All @@ -89,16 +78,6 @@ public void registerSource(String identifier, String version, ByteSource byteSou
ASTSchemaSource ast = TextToASTTransformer.transformText(source);
SourceIdentifier actualIdentifier = ast.getIdentifier();


// Apply blacklist
String blacklistVersion = blacklist.get(identifier);
if (blacklistVersion != null && version.compareTo(blacklistVersion) < 0) {
warnings.add(String.format("%s@%s blacklisted: not YANG compliant", identifier, version));
System.err.printf("%TF %TT: %s\n", System.currentTimeMillis(), System.currentTimeMillis(),
warnings.get(warnings.size() - 1));
return;
}

// Fixup YANG source identifier if the provided YANG model has a different actual identifier
if (!source.getIdentifier().equals(actualIdentifier))
source = YangTextSchemaSource.delegateForByteSource(actualIdentifier, byteSource);
Expand Down

0 comments on commit cccc6fc

Please sign in to comment.