yangtools.git
6 years agoRefactor InferenceAction 01/58701/2
Robert Varga [Tue, 6 Jun 2017 21:50:24 +0000 (23:50 +0200)]
Refactor InferenceAction

An inference action's prerequisite may only be accessed once the
action fires. Hence require a key context to give out the value
of a particular Prerequisite.

Also audit methods interfacing to StatementContextBase and lower
their expectations where possible.

Change-Id: I71cec8647d7e013598dcdf2faf9d0a46c5105938
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7e0c23776039758abe103858c3f9afe490e3035c)

6 years agoMove DeviateKind parsing 00/58700/2
Robert Varga [Mon, 5 Jun 2017 17:19:06 +0000 (19:19 +0200)]
Move DeviateKind parsing

This parser is only used in DeviateStatementImpl, so move it there
and do not clutter Utils.

Change-Id: Ie878f22e5fdd28fc2e3747a1af61a25b92a44d05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4523f8f18be0dfbe81e7a9bfc648d319bb366e7e)

6 years agoModifierImpl has no use for phase 99/58699/2
Robert Varga [Tue, 6 Jun 2017 20:55:00 +0000 (22:55 +0200)]
ModifierImpl has no use for phase

Since the field is unused, reduce confusion by not propagating it.

Change-Id: Id541143dffc536b4487628c301950d5f4d98385e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7429be41b925370957e59eec2825a6adff713875)

6 years agoCleanup effectiveStatements() access 98/58698/2
Robert Varga [Tue, 6 Jun 2017 00:41:29 +0000 (02:41 +0200)]
Cleanup effectiveStatements() access

No need to cache the field, as we are typically only iterating over
it.

Change-Id: Ia5d189deca1dbc560c77c17423814db1f7700c0d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit aa3a77e73cc51fe1286902caab094295b3a4ee91)

6 years agoDo not duplicate findModuleByNamespaceAndRevision() 03/58603/2
Robert Varga [Fri, 9 Jun 2017 09:34:38 +0000 (11:34 +0200)]
Do not duplicate findModuleByNamespaceAndRevision()

This method is already defined as a default method in SchemaContext,
hence there is no need to re-define it.

Change-Id: I419d502bffea6e5f25c60aefb31bf3f14dd3f58e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoOptimize ModuleDependencySort 05/58605/3
Robert Varga [Fri, 9 Jun 2017 10:00:58 +0000 (12:00 +0200)]
Optimize ModuleDependencySort

This class can use some love to improve its performance:
- eliminate unneeded String.format() calls
- perform revision formatting only when needed
- streamline getModuleByNameAndRevision() to eliminate duplicate
  lookups and checks

Change-Id: Iac88e223bb108110a9081ce0e6edcdd748d5b52a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit add54f1ae94f38ec842ab6810d5da2369d05422d)

6 years agoDo not create temporary array for module sorting 04/58604/2
Robert Varga [Fri, 9 Jun 2017 09:17:47 +0000 (11:17 +0200)]
Do not create temporary array for module sorting

ModuleDependencySort uses an internal iterable anyway, so expose
that method and pass our temporary set, skipping an unnecessary
copy operation.

Change-Id: I2253ed4edc3837ebb9182bcb1b0069d94e2f83e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c0f132ca8118358f1e41feb196da4f068f130430)

6 years agoIntern low-cardinality statement arguments 15/58415/2
Robert Varga [Mon, 5 Jun 2017 16:46:02 +0000 (18:46 +0200)]
Intern low-cardinality statement arguments

config, mandatory, ordered-by, require-instance, status and
yin-element statements have a fixed number of strings they take as
an argument, hence we can lower the memory overhead by sharing
strings instances.

Change-Id: I9b3f470466db8d3463956e4fb010c77671ac3900
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not throw IllegalArgumentException 14/58414/1
Robert Varga [Tue, 6 Jun 2017 08:13:19 +0000 (10:13 +0200)]
Do not throw IllegalArgumentException

We have enough information to throw a SourceException, so do that
to propagate relevant diagnostics.

Change-Id: I5d7b5db1cba00fc3bea6f63025091086c6d2ed34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5b20a9f51f915e53180f1ff5612be8c999cd554c)

6 years agoBug 8523: Add support for parsing restconf:yang-data extension 58/58358/1
Igor Foltin [Fri, 2 Jun 2017 12:41:49 +0000 (14:41 +0200)]
Bug 8523: Add support for parsing restconf:yang-data extension

Add support for yang-data extension to the YANG statement parser.
This extension is defined in RFC8040:
https://tools.ietf.org/html/rfc8040#section-8

Config and if-feature statements are ignored
when placed within a yang-data extension body.

Change-Id: Iccc1ffc76cf1ba1032552e68a4591d44f586c889
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
(cherry picked from commit d2d8522c64bede5324547689345e4c0188b5bb87)

6 years agoBug 8597 - Empty description and reference of ModuleImport in some cases 50/58350/1
Peter Kajsa [Mon, 5 Jun 2017 14:37:42 +0000 (16:37 +0200)]
Bug 8597 - Empty description and reference of ModuleImport in some cases

If a module import is specified without 'revision-date' or with
'revision-date' equal to '1970-01-01', ModuleImport does not have
filled description and reference, even though they are declared
in yang source.

Change-Id: I217d09f5f3718aee6557bec309f53c278895ebe7
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit f1df7385a93b7cc83278a992f0bbed74e04b96f2)

6 years agoBug 4640: Change semantic-version to openconfig-version 63/58263/1
Igor Foltin [Mon, 5 Jun 2017 13:18:31 +0000 (15:18 +0200)]
Bug 4640: Change semantic-version to openconfig-version

The concept of semantic version already exists in the
openconfig-extensions YANG module in the form of
openconfig-version extension.

Rename the internal representation of semantic-version
statement to openconfig-version in the yang-parser-impl module.

Also adjust existing unit tests accordingly.

Change-Id: Ie647bfce5c1a462e6d269103e55a13e08f163dc6
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
(cherry picked from commit 9ba2970f55594e4c2704b0c590bd92112e0441fb)

6 years agoBug 7037 - Improve mapping of YANG extensions 29/58229/1
Peter Kajsa [Thu, 20 Apr 2017 09:49:14 +0000 (11:49 +0200)]
Bug 7037 - Improve mapping of YANG extensions

Each extension definition is able to create an unknown statement
form of a regular yang statement. Created definitions of regular yang
statements are created only once per each yang statement and extension
definition. So we do not create a new ModelDefinedStatementDefinition
and a corresponding UnknownStatementImpl.Definition for each instance
of a regular yang statement when it is placed in an unknown statement's
body.

Change-Id: I5613eb36273e6b512637fb14456c64b023df3f1f
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit 4fe39dd37465c2bb87f920317849ca5eb044fc3d)

6 years agoBUG 8566 Introduce a fallback for ChoiceSchemaNode lookup 04/58104/2
Tomas Cere [Wed, 31 May 2017 11:28:17 +0000 (13:28 +0200)]
BUG 8566 Introduce a fallback for ChoiceSchemaNode lookup

With the way parsing callbacks are handled between netconf and yangtools
theres no hook for case nodes, which we are missing in the path when doing
SchemaNode lookup. This introduces a callback that checks Choice children
for a possible match once the normal lookup fails.

Change-Id: Ieefc6771ec3c6892e00103cbab77f6340f197d62
Signed-off-by: Tomas Cere <tcere@cisco.com>
6 years agoAdd hook for interning raw argument 67/58067/2
Robert Varga [Wed, 31 May 2017 16:42:25 +0000 (18:42 +0200)]
Add hook for interning raw argument

Type statement typically has a low cardinality of arguments, hence
we can reuse the same object for things like 'type uint32'.

Change-Id: I34c11e1d1f18f8ecaf260d55eb20ffd09d8ae4b0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 8307: Add the option for activating deviation statements 33/57333/2
Igor Foltin [Tue, 16 May 2017 12:04:38 +0000 (14:04 +0200)]
Bug 8307: Add the option for activating deviation statements

YANG statement parser currently resolves all deviation statements.
Add the option to specify which of the processed YANG modules
can be deviated by the specified YANG modules. This information is
passed down to the statement parser in the form of
Map<QNameModule, Set<QNameModule>>. If no deviations should be
activated, use an empty Map. In default mode, that is when
the Map is not provided at all, all deviations are activated.

This patch handles only the statement reactor part.
SchemaContextFactory should be fixed in a separate patch.

Moreover, change the rules for allowed deviation target path.
A deviation statement cannot target nodes in the same module
as the one it is defined in. Adjust existing unit tests accordingly.

Change-Id: Ica0f8c09218e50fd4c3efeb4dc08acb4fa418798
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
(cherry picked from commit 5079ec96bfeeb7a6ff66e71a114033c7d6c5c7a3)

6 years agoDo not use FileInputStream 13/57213/2
Robert Varga [Fri, 12 May 2017 13:49:47 +0000 (15:49 +0200)]
Do not use FileInputStream

https://www.cloudbees.com/blog/fileinputstream-fileoutputstream-considered-harmful

Change-Id: Ic3c9fab4ba21ac9da05d96e9a83597426f67331a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5190fa2a29692f8200eb971b6819c38cdeae5d38)

6 years agoBug 7844 - Unable to create LeafRefContext for leafref 25/57225/2
Peter Kajsa [Fri, 12 May 2017 12:10:50 +0000 (14:10 +0200)]
Bug 7844 - Unable to create LeafRefContext for leafref

In order to get correct namespace for a prefix used in a leafref
path we need to find the module which contains definition
of leafref path and then a prefix need to be resolved based on
imports of this module.

Change-Id: Icfb599783e90e44935d5e18eea23b0ac0d86cbf0
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
6 years agoBump versions by x.y.(z+1) 79/57879/1
jenkins-releng [Thu, 25 May 2017 18:18:08 +0000 (18:18 +0000)]
Bump versions by x.y.(z+1)

Change-Id: I8dfd91ad4af6664fa75b32f73cc33daced2e9cd1
Signed-off-by: jenkins-releng <jenkins-releng@opendaylight.org>
7 years agoMake repo depend on single features only 82/56082/2
Vratko Polak [Wed, 26 Apr 2017 14:13:31 +0000 (16:13 +0200)]
Make repo depend on single features only

Change-Id: I33b67267ebcbab193acbfe72611f02a0d0e32b4b
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
7 years agoSilence all info messages about all features being used 96/56096/3
Robert Varga [Wed, 26 Apr 2017 16:13:26 +0000 (18:13 +0200)]
Silence all info messages about all features being used

This message:

2017-04-26 17:55:00,136 | INFO  | l for user karaf | CrossSourceStatementReactor      | 85 - org.opendaylight.yangtools.yang-parser-impl - 1.1.0.SNAPSHOT | Set of supported features has not been provided, so all features are supported by default.

is featured prominently during startup operations. As it turns out,
we do not have a proper API to express 'use everything', hence the
callers, which really mean that, are passing down nulls.

Expose proper Optional-based methods which are as expressive, thus
allowing us to side-step this pesky flood.

Change-Id: I11c95c58be01deac8bbb587883d152fc6e647a6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 8291 - Unit test 90/56090/2
Peter Kajsa [Wed, 26 Apr 2017 09:08:56 +0000 (11:08 +0200)]
Bug 8291 - Unit test

Added unit test for Bug 8291.

Change-Id: Iaf41b01924f3d644b94620d2b72968725b2b2177
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
(cherry picked from commit e95ee66d2753375516ad07fc11ab24844da0a471)

7 years agoBUG-8291: expose additional DataTreeFactory methods 89/56089/1
Robert Varga [Tue, 25 Apr 2017 20:32:06 +0000 (22:32 +0200)]
BUG-8291: expose additional DataTreeFactory methods

There are use cases when we want to instantiate a DataTree rooted
at a list itself, which is something we cannot discover from
YangInstanceIdentifier because lists and containers share the same
identifier.

Therefore we need to expose a factory method which takes an initial
SchemaContext, from which we can derive the appropriate root node.

While we are at it, we also expose another factory method, which
takes additionally the initial tree state. Since the state is not
empty, we can run full validation on it before we give out the
DataTree -- allowing us to perform full enforcement of mandatory
nodes.

Change-Id: Id362234b9ef42d93ae01577809fb004864d05d1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cbb18c74acab8a9b77ddf1dc19d988e3d0fe37fc)

7 years agoBUG-8123: fix URL naming mixup 13/56013/1
Robert Varga [Tue, 25 Apr 2017 17:17:33 +0000 (19:17 +0200)]
BUG-8123: fix URL naming mixup

As it turns out URL.getFile() does the wrong thing, leading to us
taking the whole path as the module name, resulting in wrong comparison.

Change the code to analyze URL.getPath(), stripping it down to the
last component.

Change-Id: Ica3e387caf2924712151f4da5939487872f8e98c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c2ca0aa4ddb933bbb4b1f8701c92c4f0d22c08a7)

7 years agoYANG XPath functions - unit tests and bugfix 42/55842/1
Igor Foltin [Fri, 21 Apr 2017 15:06:37 +0000 (17:06 +0200)]
YANG XPath functions - unit tests and bugfix

Add more unit tests for YANG XPath functions
in yang-data-jaxen.

Fix deref function for leafrefs that reference
a leaf-list node.

Change-Id: I7bfe90a3a1a101b95a3b8ea3b1dd42963e5ea264
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
(cherry picked from commit 8539503c13746b5b765c9aa9d249a85462f69d7f)

7 years agoBUG-8123: simplify file name support 88/54988/3
Robert Varga [Thu, 13 Apr 2017 14:18:06 +0000 (16:18 +0200)]
BUG-8123: simplify file name support

As it turns out, we already have the utility classes needed
to parse the file name. Reuse them rather than duplicating their
functionality.

Change-Id: I1ecfeb6ac40ae9ae928b6457807a3fd4c421dc41
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 7050 - Document parser-impl package structure 70/54870/3
Peter Kajsa [Wed, 12 Apr 2017 08:27:57 +0000 (10:27 +0200)]
Bug 7050 - Document parser-impl package structure

Added initial javadoc to yang statement parser packages.

Change-Id: I2f18eb4ad01fee297f52953f2ef2aae24a69d253
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7038 - Rework 'type decimal64' lookup 67/54767/2
Peter Kajsa [Thu, 23 Mar 2017 16:12:33 +0000 (17:12 +0100)]
Bug 7038 - Rework 'type decimal64' lookup

Fix of hack in SourceSpecificContext, which attempts to lookup specific
complex types by considering only a QName's localName and routes
it via BUILTIN_TYPE_SUPPORTS to specific statement support.

This solution introduces argument specific statement sub-definitions.
If a StatementSupport has some argument specific sub-supports, processing
of a statement is routed to appropriate sub-support based on given
statement argument.

Change-Id: I602c0a919107a633f594a4393299f3f6623bd1c5
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoUpdate the developer docs 46/54946/2
Igor Foltin [Thu, 13 Apr 2017 07:59:35 +0000 (09:59 +0200)]
Update the developer docs

Update the docs related to the usage of
if-feature resolution mode of the YANG statement parser.

Change-Id: Id2201d7082b2b744f98c09801530bc8ad2205d65
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-8123: be better at guessing identifiers 67/54867/3
Robert Varga [Wed, 12 Apr 2017 13:54:23 +0000 (15:54 +0200)]
BUG-8123: be better at guessing identifiers

Given an URI we need to attempt to interpret it to improve our
guess of the module name and revision.

Change-Id: I4d74b06fb9f949c538911d215b6d90a383560f1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoImplement DocumentedNode interface to RevisionEffectiveStatementImpl 56/54856/1
Jakub Toth [Tue, 11 Apr 2017 21:49:18 +0000 (23:49 +0200)]
Implement DocumentedNode interface to RevisionEffectiveStatementImpl
for overriding getDescription() and getReference() methods for
exposing it to others.

Change-Id: Ida77679f952f795d06a044c0fdc8f5c40d9455a7
Signed-off-by: Jakub Toth <jatoth@cisco.com>
7 years agoUpdate .gitreview to stable/carbon 81/54681/1
Anil Belur [Tue, 11 Apr 2017 01:26:31 +0000 (11:26 +1000)]
Update .gitreview to stable/carbon

Change-Id: Ie757e1c01c9268e97b7503c4787427ae9a976a13
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
7 years agoBug 7847: Implement YANG 1.1 XPath functions in YangFunctionContext 25/54525/3
Igor Foltin [Fri, 7 Apr 2017 15:17:23 +0000 (17:17 +0200)]
Bug 7847: Implement YANG 1.1 XPath functions in YangFunctionContext

Introduce implementation of functions re-match, deref, derived-from,
derived-from-or-self, enum-value and bit-is-set in the yang-data-jaxen's
YangFunctionContext.

The functionality introduced in this patch is beta-quality and will
need more thorough testing in the future

Change-Id: Ia89f8b50dd7537cfafc2297ada8720648050bdbd
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 8126 - Some augments are not being processed 65/54365/5
Peter Kajsa [Wed, 5 Apr 2017 13:55:08 +0000 (15:55 +0200)]
Bug 8126 - Some augments are not being processed

If a node is marked as mandatory (e.g. "leaf" with "mandatory true;"),
yang statement parser does not perform augmentation of such node into
a target node in different module even though one of ancestors of the
target node is a non-mandatory choice or a non-mandatory list from the
same namespace as the mandatory node and so in fact it should not
be considered as augmenatation of mandatory node into different module
anymore and augmentation should be performed.

We also increase severity of the augment error log from debug to error.

Change-Id: Icb8554ba61ce0aa0fa25541dd5675f3aa8ba3d1b
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-7833: Fix identityref codecs 70/53870/7
Robert Varga [Sun, 26 Mar 2017 19:38:00 +0000 (21:38 +0200)]
BUG-7833: Fix identityref codecs

Introduce QNameCodecUtil to help JSON and XML codecs correctly implement
their identityref codecs. As it turns out, both only need to provide
proper mapping functions without having to deal with multiple codec
hierarchies.

The patch is also more strict about parsing the string, as it rejects
malformed identityrefs, i.e. those which contain invalid characters.

This fixes BUG-7833, which is triggered by invalid PUT, where we parse
an empty string as a null identityref.

Change-Id: I1f3086a0f9e930f7782dff8d6c39329d4b28ed14
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: unify JSONCodec and XmlCodec methods 69/53869/5
Robert Varga [Sun, 26 Mar 2017 18:06:21 +0000 (20:06 +0200)]
BUG-7983: unify JSONCodec and XmlCodec methods

This patch introduces TypeAwareCodec to define the common interface
which both these codecs implement. We adjust methods to conform
to this interface.

Change-Id: I25ccaf56c2e6013dee01016efe5fd7c960790f70
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: make XmlCodecFactory a subclass of AbstractCodecFactory 65/53865/4
Robert Varga [Sun, 26 Mar 2017 15:49:03 +0000 (17:49 +0200)]
BUG-7983: make XmlCodecFactory a subclass of AbstractCodecFactory

AbstractCodecFactory contains everything we need for efficient caching,
the only problem we need to solve is binding to NamespaceContext. This
patch does exactly that, decoupling XmlCodec from the generic Codec
interface, so that serialization and deserialization paths are explicit.

This flushes out the fact that the codecs are not used in the egress
path at all and rely on TypeDefinitionAwareCodec instead. That deficiency
will be fixed in a subsequent patch.

Change-Id: I0bdf8af673893f2dc4fcc8842b64f9bed1bc5236
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoSpeed up XpathStringParsingPathArgumentBuilder 71/53871/7
Robert Varga [Sun, 26 Mar 2017 20:30:13 +0000 (22:30 +0200)]
Speed up XpathStringParsingPathArgumentBuilder

Use an internal ArrayList to lower the amount of pointer-chasing
we do. Also make sure we format the error string only when it is
necessary.

Change-Id: Ic2ce96b45dd44b1d1da24ceb9452a2548f883446
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: factor out AbstractCodecFactory 64/53864/2
Robert Varga [Sun, 26 Mar 2017 14:57:37 +0000 (16:57 +0200)]
BUG-7983: factor out AbstractCodecFactory

Since the type decomposition logic can be shared between XML and
JSON codecs, factor it out into yang.data.util.codec, where it
can be efficiently shared.

JSONCodecFactory becomes a pure type binding provider, with all
of the logic abstracted out. We also reduce CodecCache method
visibility, as they are a package-private implementation detail.

Change-Id: I58e50dd966915e4e1a691add517c9a6d0b647c80
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: extract codec caching from JSONCodecFactory 63/53863/2
Robert Varga [Sun, 26 Mar 2017 14:09:40 +0000 (16:09 +0200)]
BUG-7983: extract codec caching from JSONCodecFactory

Caching aspect of CodecFactory is independent of the actual codec,
factor it out for reuse with XML codecs.

Change-Id: Ib6678a038482a2f50a8a55a0065158e3bc840cd8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7996: expose different implementations of JSONCodecFactory 01/53801/2
Robert Varga [Fri, 24 Mar 2017 16:37:42 +0000 (17:37 +0100)]
BUG-7996: expose different implementations of JSONCodecFactory

We have four different implementations of JSONCodecFactory, each useful
in different circumstances. Rather than having a singleton create()
method, expose multiple methods so users can pick and choose the
implementation which is best suited to their use case.

Change-Id: I1c2e48ed2bc2734447e08e043d8505b741f1e401
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7996: reshuffle caching logic 20/53620/10
Robert Varga [Tue, 21 Mar 2017 16:29:33 +0000 (17:29 +0100)]
BUG-7996: reshuffle caching logic

This patch reworks JSONCodecFactory internals to split the codecs
by their type, allowing simple codecs to be reused across multiple
leaves.

Efficient implementation of this split requires exposing individual
StringCodec classes -- as we need to avoid the broken union codec.
This also has the added benefit of not performing instanceof checks
multiple types.

JSONCodec interface is updated to not be directly bound to the Codec
interface, but rather provide the GSON-specific methods and to expose
the expected data type class. This change allows us to optimize
the serialization side of union codecs, as they can check the input
data without incurring a ClassCastException.

Union codec is decoupled from AbstractStringUnionCodec and contains
pre-computed codecs. This is needed to eliminate the dependency
on the JSONCodecFactory itself and allow for efficient caching
of the codec without incurring further overhead of having to deal
with mutable codec.

Change-Id: I05f18fbaa4b3160d2a7017ec2428d1577f54af7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 6183 - Shorthand case should create case node in schema tree 39/53139/11
Peter Kajsa [Fri, 10 Mar 2017 13:10:56 +0000 (14:10 +0100)]
Bug 6183 - Shorthand case should create case node in schema tree

According to Rfc7950, if a case statement is omitted and implicit case
node is created, schema node identifiers MUST always explicitly include
the implicit case node identifiers.

This patch deals with both Yang 1.1 and Yang 1 in the same way.

Change-Id: I64fef2aee85855cb6300318f7c97e694b3105a0a
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoTrim down TypeDefinitionAwareCodec 53/53653/2
Robert Varga [Wed, 22 Mar 2017 07:29:37 +0000 (08:29 +0100)]
Trim down TypeDefinitionAwareCodec

Storing an Optional runs contrary to its usual role and wastes
memory. We can simply calculate the optional and have a nullable
internal field, saving ~16 bytes per codec instance.

Change-Id: I184fbd8f390bf5703b3342a6dd09de599c236554
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoCleanup codecs a bit 69/53469/5
Robert Varga [Fri, 17 Mar 2017 09:49:43 +0000 (10:49 +0100)]
Cleanup codecs a bit

- prevent unnecessary boxing
- add type arguments
- static methods
- do not use deprecated methods

Change-Id: Ic129d327804d3b28066c84d6101cbe262e2101b1
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7996: Use weak keys in SharedJSONCodecFactory 88/53388/7
Robert Varga [Thu, 16 Mar 2017 08:34:42 +0000 (09:34 +0100)]
BUG-7996: Use weak keys in SharedJSONCodecFactory

This speeds up hashing, as weak keys are forcing identity-based
hashCode/equals().

Change-Id: If6b0323ac8e80fc8833a13ff5b4406e908e7f558
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7996: Split JSONCodec into multiple implementations 73/53373/8
Robert Varga [Wed, 15 Mar 2017 18:10:18 +0000 (19:10 +0100)]
BUG-7996: Split JSONCodec into multiple implementations

Make JSONCodecFactory an abstract base class with four different
trade-offs in cpu/memory usage. The only implementation available
to clients is SharedJSONCodecFactory, which behaves exactly like
the previous implementation used to.

One user-visible change is that thread-safe implementations,
including SharedJSONCodedFactory, now keep a shared weak cache
for reuse when the same kind of factory is requested multiple times
for the same context.

Change-Id: I15342e6b4ed68ccbac9c099f63654d7456913934
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-8039: Enforce binary/string type length 53/53553/3
Robert Varga [Mon, 20 Mar 2017 11:30:23 +0000 (12:30 +0100)]
BUG-8039: Enforce binary/string type length

Binary type does not enforce input data length based on the supplied
constraints. Introduce two separate classes to deal with restricted
and unrestricted binary types.

String type fails to do the same, retrofit StringStringCodec with
the appropriate check.

Change-Id: I82516b39d66cbf846ed3eed39ee9e266b882f45d
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoUse TypedSchemaNode 21/53321/4
Robert Varga [Wed, 15 Mar 2017 09:44:02 +0000 (10:44 +0100)]
Use TypedSchemaNode

Eliminate special cases for leafs and leaf-lists, as they now
share a common interface.

Change-Id: I0c2e6a3875e6934e94af6552a14546e19ac822dd
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoMove hard-coded prefix 06/53306/5
Robert Varga [Tue, 14 Mar 2017 22:24:06 +0000 (23:24 +0100)]
Move hard-coded prefix

Prefix constant is used only in one branch, colocate it where it is
needed.

Change-Id: I2f0e954538877af602cc68c710cc491a39bebd7c
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoRename XmlStreamUtils 03/53303/5
Robert Varga [Tue, 14 Mar 2017 20:35:42 +0000 (21:35 +0100)]
Rename XmlStreamUtils

The utilities come in two flavors, schema-aware and schema-less,
so split them out into two separate classes. This flushes out the fact
the schema-less version cannot serialize instance identifiers, so mark
that explicitly.

Change-Id: I59b0f63ba80b6cb44570df19bef2e20675755d01
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoAdd XmlParserStream documentation 02/53302/5
Robert Varga [Tue, 14 Mar 2017 20:05:00 +0000 (21:05 +0100)]
Add XmlParserStream documentation

This is a slight refactor allowing XmlCodecFactory to be reused across
multiple invocations. It also clarifies the factory methods.

Change-Id: I6fe46424402f3ee87f0ddde554c661591a87efb1
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 7954: Throw an exception when parsing duplicate (sub)modules 83/53283/6
Igor Foltin [Tue, 14 Mar 2017 16:11:33 +0000 (17:11 +0100)]
Bug 7954: Throw an exception when parsing duplicate (sub)modules

In case we add the same YANG (sub)module to the YANG parsing
cycle twice, throw a SourceException which reports the problem
with colliding namespaces/names.

Change-Id: If0a0aff23ace2cdcbb3d87b639c9ef74f2302432
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoReduce visibility of codec methods 93/53293/4
Robert Varga [Tue, 14 Mar 2017 18:38:44 +0000 (19:38 +0100)]
Reduce visibility of codec methods

These are needlessly protected/public, lower them to package-private.

Change-Id: I06ef86402051be3a010d88470ed2c0569853dbb0
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7759: return deserialized type 97/53297/2
Robert Varga [Tue, 14 Mar 2017 19:45:19 +0000 (20:45 +0100)]
BUG-7759: return deserialized type

Union codec should not be returning the string representation,
but rather the proper deserialized type.

Change-Id: I4c452ecd59ee72b9b69ead39c3c36868bcd74444
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoUse specific versions for odlparent imports 72/53272/3
Stephen Kitt [Tue, 14 Mar 2017 12:21:24 +0000 (13:21 +0100)]
Use specific versions for odlparent imports

Felix (or something related) doesn't look for snapshots in version
ranges, which breaks integration/distribution, so we can't use version
ranges for feature dependencies (even though they don't currently end
up in the generated features) until we switch to release artifacts.

See
https://jenkins.opendaylight.org/releng/job/netconf-distribution-check-carbon/1468/
for an example of a broken build.

Change-Id: I1c50ba1d05ef1eb8fd06820f5e84c02e3ae43fad
Signed-off-by: Stephen Kitt <skitt@redhat.com>
7 years agoBUG-7954: identify source of the offending statement 84/53184/1
Robert Varga [Sat, 11 Mar 2017 20:15:55 +0000 (21:15 +0100)]
BUG-7954: identify source of the offending statement

When we have a conflicting key we should also identify where it was
populated, as that may not be immediately obvious by looking at the
module source.

Change-Id: If48cb1af73b86bd7cbf6926dfc8fe696f796a20e
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoUse UntrustedXML in tests 79/53179/3
Robert Varga [Sat, 11 Mar 2017 17:24:29 +0000 (18:24 +0100)]
Use UntrustedXML in tests

In order not to preliferate DocumentBuilderFactory instantiation,
use UntrustedXML everywhere in tests.

Change-Id: I412711035978679a69cc41118c006bf8d7cf5864
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoRemove remants of yang-data-operations 78/53178/3
Robert Varga [Sat, 11 Mar 2017 16:50:51 +0000 (17:50 +0100)]
Remove remants of yang-data-operations

This component is no longer built, remove its remnants.

Change-Id: Ibe1850ea8449cabc323c41df9025844346968af8
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDo not trust documents in anyxml 76/53176/2
Robert Varga [Sat, 11 Mar 2017 16:48:36 +0000 (17:48 +0100)]
Do not trust documents in anyxml

Parsing XMLs in anyxml is an untrusted operation, as they can
include various references to outside world. Fix this by using
a DocumentBuilder from UntrustedXML.

Change-Id: If212d5cc9629d415c7d22aba7d691215644a8669
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoMake XmlDocumentUtils use UntrustedXML 75/53175/2
Robert Varga [Sat, 11 Mar 2017 16:44:31 +0000 (17:44 +0100)]
Make XmlDocumentUtils use UntrustedXML

When dealing with incoming XML, we should not be trusting it. Instead
of open-coded DocumentBuilderFactory, use the one encapsulated in
UntrustedXML.

Change-Id: I3bcee704de8dc73428950ac59579b33aabe15bc0
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6392: Fix lenient parsing of unkeyed list entries 49/53149/3
Igor Foltin [Fri, 10 Mar 2017 16:05:07 +0000 (17:05 +0100)]
Bug 6392: Fix lenient parsing of unkeyed list entries

The old xml parser can be set to ignore nodes
which do not exist in the corresponding YANG model
using a boolean flag. However, this flag is
ignored when parsing unkeyed list entries.

This patch fixes the issue

Change-Id: I798be8151d575f838e97a8fe44d04f47363491ba
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 5410 - XSD regular expressions are interpreted as Java regexes (2/2) 00/53000/5
Peter Kajsa [Wed, 8 Mar 2017 12:56:30 +0000 (13:56 +0100)]
Bug 5410 - XSD regular expressions are interpreted as Java regexes (2/2)

Removal of xsd-regex parts from Yangtools.

Change-Id: I8bbe225f187c6ae215ceb9e144cac6bdbe1bddd6
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7945: Fix schema validation for augmentation of case 25/52025/4
Xiao Liang [Fri, 17 Feb 2017 23:51:58 +0000 (07:51 +0800)]
Bug 7945: Fix schema validation for augmentation of case

Add modification strategy of case augmentation as child of choice.

Change-Id: Ie7b03f2d06ab279f0dd9c85edf9a370b0f63abac
Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
7 years agoBug 5410 - XSD regular expressions are interpreted as Java regexes (1/2) 99/52999/6
Peter Kajsa [Wed, 8 Mar 2017 12:54:22 +0000 (13:54 +0100)]
Bug 5410 - XSD regular expressions are interpreted as Java regexes (1/2)

As both '^' and '$' are special anchor characters in java regular
expressions which are implicitly present in XSD regular expressions,
we need to escape them in case they are not defined as part of
character ranges i.e. inside regular square brackets.

Change-Id: Iafbf350f88ebdf96c30e1ccedbd00b90a93d521a
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7182 related: yang-maven-plugin no hard-coded target/ (target-ide/) 40/52440/9
Michael Vorburger [Wed, 1 Mar 2017 01:12:57 +0000 (02:12 +0100)]
Bug 7182 related: yang-maven-plugin no hard-coded target/ (target-ide/)

Change-Id: Ic90f8f9b808d353cce289010b4907de55204091f
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7424: Disallow child namespace collisions 00/51400/9
Peter Kajsa [Fri, 3 Feb 2017 13:25:27 +0000 (14:25 +0100)]
BUG-7424: Disallow child namespace collisions

All leafs, leaf-lists, lists, containers, choices, rpcs,
notifications, and anyxmls defined (directly or through a uses
statement) within a parent node or at the top level of the module
or its submodules share the same identifier namespace.

Change-Id: I1852d2ca5ebd07ba6c1ed21a5ceded3e87d67467
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 7865 - Extension argument is being restricted to identifier 91/52991/1
Peter Kajsa [Wed, 8 Mar 2017 08:48:11 +0000 (09:48 +0100)]
Bug 7865 - Extension argument is being restricted to identifier

Yang parser tries to create QName from unknownStatement argument by
process of SchemaPath construction what is incorrect, because argument
of unknownStatemet can be any string.

Change-Id: I60df2afb55efdc6b4c48f14809ecd77815180090
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-7424: introduce a putIfAbsent storage operation 62/52762/2
Robert Varga [Fri, 3 Mar 2017 12:56:51 +0000 (13:56 +0100)]
BUG-7424: introduce a putIfAbsent storage operation

The interface exposed by NamespaceBehaviour is not sufficient
to express the needs of all storages. Refactor addToLocalNamespace()
into two distict operations, create-or-replace and create so
we can cleanly implement ChildSchemaNodes namespace.

Change-Id: If85f6d87238e61f34ac022ffa63e62c9ae246d0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7898: clean up CrossSourceStatementReactor interface 14/52814/4
Robert Varga [Sat, 4 Mar 2017 12:52:36 +0000 (13:52 +0100)]
BUG-7898: clean up CrossSourceStatementReactor interface

Warnings emitted by BuildGlobalContext about requested features
come from insufficient isolation of public and private APIs. Correct
this error by moving the warnings to the public interface methods,
so the incorrect use is allowed without breaking the API contract.

While we are touching this area, deprecate redundant BuildAction
methods.

Change-Id: Ic77df07851f15bb6faabc7c9b4b466626e028d2f
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6856: Rpc definition should implicitly define input/output 04/48704/22
Igor Foltin [Tue, 28 Feb 2017 12:09:56 +0000 (13:09 +0100)]
Bug 6856: Rpc definition should implicitly define input/output

Empty input and output statements are now automatically
added to every rpc statement that does not declare them.

Change-Id: I799137f18fe6ac382c8488684514b746dafbefb5
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 7879 - refine target node was not found 39/52639/2
Peter Kajsa [Thu, 2 Mar 2017 11:36:11 +0000 (12:36 +0100)]
Bug 7879 - refine target node was not found

In case of uses-refine used in augment defined in submodule the yang
statment parser was not able to resolve target namespace, because augment
was definied in submodule. In consequence, leaf node retained its original
namespace and therefore refine target node was not found.

This patch fixes the bug described above.

Change-Id: I24668a2efb6853cfd07b515ea5671cd2bfde580c
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6878: Add support for parsing yang-specific XPath functions 38/51938/9
Igor Foltin [Thu, 16 Feb 2017 08:43:15 +0000 (09:43 +0100)]
Bug 6878: Add support for parsing yang-specific XPath functions

YANG 1.1 (RFC7950) introduces a set of yang-specific XPath functions.
YANG statement parser can now parse YANG 1.1 models which contain
these functions

Change-Id: Icfbf95db0d04a3f077133c38341f250cde4e56eb
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 7182: YangToSourcesProcessor deletes output directory 16/52416/3
Michael Vorburger [Tue, 28 Feb 2017 21:08:48 +0000 (22:08 +0100)]
Bug 7182: YangToSourcesProcessor deletes output directory

Now that a c/52087 has added a lifecycle-mapping-metadata.xml into the
yang-maven-plugin, for this to really properly work in-IDE even on full
builds (we're far from making this work incrementally..) it's important
that the output directory is cleaned.

This is because I've observed in testing that otherwise something else
(I'm not clear what) seems to prevent overwriting already existing
*.java files.  I've verified that with this change, the typical use case
of e.g. git pull master, some changes in *.yang files, you Project >
Clean... (full build, only) - red is gone!  (Finally.)

A full delete of an output directory (on a full rebuild) is, unrelated,
better anyway, as it gets rid of previously generated classes with names
that theoretically possibly don't exist anymore, imagine e.g. after a
renaming in YANG.

This fix is particular to in-IDE code generation, following the
lifecycle mapping.  It typically was never a problem on CLI, cauz
everyone always just does "mvn clean install" anyway - but it won't hurt
there either.  But for in-IDE, we have to clean ourselves; thus this
change.

The two *Test changes fix test failures introduced by this change.
Unless a misunderstood the intent - those tests appear to be wrong - how
can they intend the outputBaseDir to be the SOURCE dir of those YANG
models?!?  (That's what they do as-is, and that's why the test fails,
when the source gets deleted.)

Change-Id: Ie47294511b6f9c57cefdb305344045e112e8d05a
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
7 years agoRemove checkstyle plugin declaration 57/52357/2
Robert Varga [Tue, 28 Feb 2017 12:17:05 +0000 (13:17 +0100)]
Remove checkstyle plugin declaration

Checkstyle should not be run in aggregator poms. This patch fixes
a maven warning about missing version and should result in faster
compilation times.

Change-Id: I07d810fd05568865eb31f2f00fcc482fa4d0e31f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoFormat Module revisions 44/52344/2
Robert Varga [Tue, 28 Feb 2017 09:09:48 +0000 (10:09 +0100)]
Format Module revisions

Rather than printing out the date, use QNameModule's
getFormattedRevision() to print out revision in correct format.

Change-Id: I953429c331548fc1e0d83449e0c339d64a9790e4
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7568: account for module/submodule split 49/52349/1
Robert Varga [Tue, 28 Feb 2017 09:59:43 +0000 (10:59 +0100)]
BUG-7568: account for module/submodule split

The set of modules in the project does not map 1:1 to the set
of actual files, as modules have submodules. Correctly account
for this difference and track them separately.

Change-Id: I9eb4de37e59a9c1e9ca47143dd4be52f54ee396a
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7568: fix wrong translation 14/52314/1
Robert Varga [Mon, 27 Feb 2017 14:14:49 +0000 (15:14 +0100)]
BUG-7568: fix wrong translation

Translation should occur not the file name path, not the source.

Change-Id: If90169f8144a985bc7882cb77b482fd8b463291b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7850: make SourceIdentifier.getRevision() return null 52/52252/7
Robert Varga [Fri, 24 Feb 2017 13:18:49 +0000 (14:18 +0100)]
BUG-7850: make SourceIdentifier.getRevision() return null

getRevision() should follow its general contract and return null,
not a special string, when the revision is not found.

Change-Id: I74cd2648d218733e4ae26f7e849b72bd62b367ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7568: expose file name mapping function 19/52219/10
Robert Varga [Thu, 23 Feb 2017 16:10:57 +0000 (17:10 +0100)]
BUG-7568: expose file name mapping function

We currently perform a rather nasty hack with NamedFileInputStream
to communicate the target result file to the code generators.

Update the code generation interface to allow passing down a mapping
function. Once all plugins have been updated to remove use of
SourceStreamAware, we can switch it to renaming files.

Change-Id: I4370a778ed46f759dd796dfed7436cc3bd657287
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 6886 - [Yang 1.1] Update rules for handling of strings 26/51926/5
Peter Kajsa [Wed, 15 Feb 2017 19:08:25 +0000 (20:08 +0100)]
Bug 6886 - [Yang 1.1] Update rules for handling of strings

In Yang 1.1 an unquoted string cannot contain any single or double
quote characters and in double quoted string the backslash must not be
followed by any other character as those which are specified in RFC7950
Section 6.1.3.

Change-Id: Iec284b176ae04f3a908eb3c9d18eb5907d1b4c51
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoFix resource-based YangTextSchemaSource 55/52255/3
Robert Varga [Fri, 24 Feb 2017 13:56:39 +0000 (14:56 +0100)]
Fix resource-based YangTextSchemaSource

Resource-based lookup needs to trim the specified path, so that
only the file name remains -- otherwise the resulting source
identifier ends up including the full path.

Change-Id: I517139e16a2f259b22032462a607c3bd9a2277b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7850: fix SourceIdentifier.toYangFileName() 51/52251/3
Robert Varga [Fri, 24 Feb 2017 12:17:56 +0000 (13:17 +0100)]
BUG-7850: fix SourceIdentifier.toYangFileName()

Internals of this method assume the original, pre-broken semantics
of revision being null when not present. Fix this by comparing
to non-present string.

Change-Id: Id057ebfd5af31e83b6dc77145349825cff8f8f16
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoEliminate custom SimpleDateFormat instances 54/52254/1
Robert Varga [Fri, 24 Feb 2017 13:49:30 +0000 (14:49 +0100)]
Eliminate custom SimpleDateFormat instances

We have SimpleDateFormatUtil to capture a fast revision parser,
use that instead of rolling our own.

Change-Id: I9b907440b73d721d306d5a946fbee58b8be47bd1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7182: add M2E lifecycle mapping 87/52087/4
Robert Varga [Mon, 20 Feb 2017 21:52:37 +0000 (22:52 +0100)]
BUG-7182: add M2E lifecycle mapping

Add lifecycle mapping metadata. Execution will probably not work completely,
as the plugin architecture requires BUG-175 to be addressed, i.e. individual
generators should not be touching filesystem directly.

Change-Id: I7995de75c1817fb7bbdbc5e85790ad4e61a39486
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoUpdate StmtTestUtils 70/52070/7
Robert Varga [Mon, 20 Feb 2017 12:26:23 +0000 (13:26 +0100)]
Update StmtTestUtils

Do not use deprecated YangStatementSourceImpl. Also adjust tests
to throw Exception, thus ridding them of some complexity.

Change-Id: I549197204adc64edb60d44cc439d02dbd39c815e
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6885: [Yang 1.1] Disallow "when" and "if-feature" on list keys. 85/50785/13
Igor Foltin [Sun, 19 Feb 2017 11:56:10 +0000 (12:56 +0100)]
Bug 6885: [Yang 1.1] Disallow "when" and "if-feature" on list keys.

Starting with YANG 1.1, a leaf which is specified as a list key
cannot contain an if-feature or a when statement

Change-Id: I4e39dfb2d7597e1012354004f1cb6f0a56638b2a
Signed-off-by: Rashmi Pujar <rashmi.c.pujar@gmail.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 6884 - [Yang 1.1] Submodule can reference all definitions in all submodules 03/51903/4
Peter Kajsa [Mon, 13 Feb 2017 08:23:17 +0000 (09:23 +0100)]
Bug 6884 - [Yang 1.1] Submodule can reference all definitions in all submodules

Since Yang 1.1, it has been allowed a submodule to reference all definitions
in all submodules that belong to the same module, without using the "include"
statement. This patch also deals with possible circular chains of includes
between submodules.

Change-Id: I2b3d19fc2c867882fc89f042bbe5febaf89bc2ea
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoExpand Identifiable documentation 30/52030/4
Robert Varga [Sat, 18 Feb 2017 11:28:14 +0000 (12:28 +0100)]
Expand Identifiable documentation

Make sure the identifier returned cannot be null, as it does not make
sense.

Change-Id: I2d8c7a17487da66fe91f44a597d74abae82c10bd
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6887: [Yang 1.1] Allow enumerations and bits to be subtyped 53/51453/8
Igor Foltin [Mon, 6 Feb 2017 07:40:48 +0000 (08:40 +0100)]
Bug 6887: [Yang 1.1] Allow enumerations and bits to be subtyped

Starting with YANG 1.1, enumeration and bits types
can be restricted

An enumeration type can be restricted with one or more
"enum" statements, which enumerate a subset of the values
for the base type.

A bits type can be restricted with one or more "bit"
statements, which enumerate a subset of the values for
the base type.

Change-Id: If46991b858a2a9153a60de85645f6ec301fcb33f
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-7052: introduce YangStatementStreamSource 55/52055/10
Robert Varga [Sun, 19 Feb 2017 23:30:35 +0000 (00:30 +0100)]
BUG-7052: introduce YangStatementStreamSource

This untangles the parser implementation a bit, adding a more
modern StatementStreamSource.

Change-Id: Ic5fb23f088273e1a0993663bab237b6432924b47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoAdd utility YangTextSchemaSource factories 54/52054/6
Robert Varga [Sun, 19 Feb 2017 20:51:07 +0000 (21:51 +0100)]
Add utility YangTextSchemaSource factories

This adds the ability to directly instantiate a source from a File,
a combination of a file name and a ByteSource, or from a resource.

Also add SchemaSourceRepresentation.getSymbolicName(), which can be
used in error reporting to give humans some leads as to the source
of any problems encountered.

Change-Id: I1130d43f469bfa1556b015c5aa5f26472a69c51e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 7397 - yang-system-test could fail if zero yang files were found 98/51298/3
Peter Kajsa [Wed, 1 Feb 2017 13:00:02 +0000 (14:00 +0100)]
Bug 7397 - yang-system-test could fail if zero yang files were found

Yang-system-test fails with non-zero exit code, if zero yang files
were found.

Change-Id: Id9f1b08e2e937d009a029202df1591b93a1510f1
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7396 - yang-system-test could support recursive search 95/51295/4
Peter Kajsa [Wed, 1 Feb 2017 11:07:46 +0000 (12:07 +0100)]
Bug 7396 - yang-system-test could support recursive search

Yang-system-test: added new option '-r' for recursively search
sub-directories for yang files.

Change-Id: I265c0dfa1006aee5b7bb1a85342d162866232a3b
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7480 - yang-system-test: -p directories are for dependency search 18/51018/13
Peter Kajsa [Wed, 25 Jan 2017 17:13:45 +0000 (18:13 +0100)]
Bug 7480 - yang-system-test: -p directories are for dependency search

Yang statement parser is now able to distinguish between reqular and
library sources. Parser adds sources from library into resulting
SchemaContext only when needed to satisfy an import. In consequence,
only the sources required by regular sources are present in resulting
SchemaContext. Any other library sources are ignored and this also
applies to error reporting.

Also yang-system-test: -p directories are used now only for dependency
search.

Change-Id: I6a38fca16a923e7d2caa5a40e1c38469d98882e4
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6901 - [Yang 1.1] Default value MUST NOT be marked with an if-feature 24/50624/13
Peter Kajsa [Wed, 11 Jan 2017 13:33:35 +0000 (14:33 +0100)]
Bug 6901 - [Yang 1.1] Default value MUST NOT be marked with an if-feature

Definition of the default values MUST NOT be marked with an
"if-feature" statement in Yang 1.1.

Change-Id: Id05519bea6f5a3f7fe9c82ede6cb5ab805dbc93c
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoEliminate a boxing warning 77/52077/3
Robert Varga [Mon, 20 Feb 2017 14:30:49 +0000 (15:30 +0100)]
Eliminate a boxing warning

Method return type is Integer, hence use Integer.valueOf() instead
of Integer.parseInt(). Also switch to using a SourceException
constructor with built-in String.format().

Change-Id: Ie2b83d39ed8dd5c6d8ee5b15c349c2659ee9f96c
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDeprecate TextToASTTransformer.TRANSFORMATION 53/52053/3
Robert Varga [Sun, 19 Feb 2017 19:44:55 +0000 (20:44 +0100)]
Deprecate TextToASTTransformer.TRANSFORMATION

This is a really clunky way of transforming text, useful for repositories.
Deprecate this field if favor of a synchronous
TextToASTTransformer.transformText() method.

Also cleanup checkstyle warnings in touched files.

Change-Id: Iebabcb84d92e480708be1180b174f57d1552d4ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7568: silence YangTextSchemaContextResolver 52/52052/3
Robert Varga [Sun, 19 Feb 2017 19:20:59 +0000 (20:20 +0100)]
BUG-7568: silence YangTextSchemaContextResolver

YangTextSchemaContextResolver should understand when we are expanding
a not-present revision and not emit info's then. We still log expansions
on debug and info about mismatches.

This silences the noise on controller startup, but does not completely
fix the issue.

Change-Id: I1b5e4eed9b288e2c6d48b494630eee0dd1fa38c4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoMove features to top level 45/51845/4
Robert Varga [Tue, 14 Feb 2017 09:19:16 +0000 (10:19 +0100)]
Move features to top level

Since our structure is more flat than it used to be there is no
need to keep features in common directory.

Change-Id: I59c8a97f3b93ae0a8fc350f866541ae93c8dd539
Signed-off-by: Robert Varga <rovarga@cisco.com>