GithubHelp home page GithubHelp logo

Comments (8)

sekur avatar sekur commented on June 30, 2024 1

@shlomiassaf - thanks for the details, it really helps.

I think the issue may be with how yang-js is handling extensions from an included submodule. Looks like a bug. Let me try to reproduce and will let you know what I find.

Thanks!

from yang-js.

sekur avatar sekur commented on June 30, 2024 1

@shlomiassaf - thanks for flagging this issue!

So after digging into it, I found that it was a rather nasty state bleed-over issue with how I was treating the argument sub-statement. The fix itself was fairly minor but I've committed the change along with something else I was working on so it may be less obvious based on the changeset.

You can try the fix now from the master branch. I'll probably publish a new 'yang-js' package later today so you can try that as well.

from yang-js.

sekur avatar sekur commented on June 30, 2024

Enabled extension attachment via .bind() in 731ff72

from yang-js.

shlomiassaf avatar shlomiassaf commented on June 30, 2024

@saintkepha I'm unable to import and parse.

I get this error: encountered unknown extension 'tailf:my-extension'

I'v imported the file declaring the extension (with the same prefix)

I believe it's related to this issue, can you provide an example how to use the .bind() method to attach extensions?

Thanks!

from yang-js.

sekur avatar sekur commented on June 30, 2024

Hi @shlomiassaf - I don't think the issue you're encountering is related to the ability to provide custom extension handling capability described in this ticket.

Take a look at the test case for using imported custom extension definition: https://github.com/corenova/yang-js/blob/master/test/extension/extension.coffee#L36

The error of encountered unknown extension usually means that it was unable to resolve the extension my-extension statement within the imported module prefix with tailf. I would check to make sure that the module that contains the extension my-extension statement is being properly imported by the module that is trying to use it.

The .bind() method as enhanced by this ticket enables custom compile logic to be used for implementing the extension and is not affected during parse operation itself.

Also, for more extensive diagnostics, you can always run with DEBUG=yang:* as the environmental variable.

from yang-js.

shlomiassaf avatar shlomiassaf commented on June 30, 2024

@saintkepha Thanks for the quick response, the imports are there, here's a simplified exapmle:

FILE: module-ext-demo.yang

submodule module-ext-demo {

  belongs-to module-demo {
    prefix mdemo;
  }

  extension arg-type {
    description
      "Specifies the type of the argument.";
  }
}

FILE: module-demo.yang

module module-demo {
  prefix mdemo;

  include module-ext-demo {
  }

  extension info {
    argument text {
      mdemo:arg-type {
        type string;
      }
    }

    description "info";
  }

}

FILE: model-demo.yang

module model-demo {
 namespace "http://tail-f.com/ned/cisco-nx";
  prefix nx;

  import module-demo {
    prefix mdemo;
  }

  typedef test {
    type union {
      type uint32 {
        mdemo:info "SomeInfo";
      }
      type enumeration {
        enum auto {
          mdemo:info "More Info"";
        }
      }
    }
  }
}

I run this code:

  Yang.import('./module-demo.yang');
  Yang.parse(fs.readFileSync('./model-demo.yang');

It fails on the 1st line:

ExpressionError: [module(module-demo)/extension(info)/argument(text)/mdemo:arg-type] encountered unknown extension 'mdemo:arg-type'
    at Yang.Element.error (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/element.js:64:13)
    at Yang.Expression.error (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/expression.js:191:40)
    at Yang.error (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/yang.js:313:35)
    at Yang.<anonymous> (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/yang.js:277:24)
    at EventEmitter.g (events.js:291:16)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:188:7)
    at Yang.emit (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/yang.js:319:33)
    at Yang.Expression.compile (/Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/expression.js:67:12)
    at /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/node_modules/yang-js/lib/expression.js:80:18

DEBUG log:

  yang:schema [match] with extension mdemo:arg-type +0ms
  yang:schema [match] check if current module's prefix +3ms
  yang:schema [match] checking if submodule's parent +1ms
  yang:schema [match] check if one of current module's imports +0ms
  yang:expression [module(module-demo)] compile enter... (undefined) +3ms
  yang:element [module(module-demo)] found 1 new extension(s) +1ms
  yang:expression [module(module-demo)/prefix] compile enter... (undefined) +0ms
  yang:expression [module(module-demo)/prefix] compile: ok +0ms
  yang:expression [module(module-demo)/include(module-ext-demo)] compile enter... (undefined) +0ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/yang-demo/package.json +1ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/package.json +0ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/package.json +1ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/cisco/package.json +0ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/Cisco/package.json +0ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/Desktop/package.json +0ms
  yang:schema [resolve] module-ext-demo in /Users/shlomiassaf/package.json +0ms
  yang:schema [resolve] module-ext-demo in /Users/package.json +0ms
  yang:schema [resolve] checking if /Users/shlomiassaf/Desktop/Cisco/cisco/github-vts/vts-client/yang-demo/module-ext-demo.yang exists +0ms
  yang:schema retrying import(./module-demo.yang) +3ms
  yang:schema [match] with extension mdemo:arg-type +2ms
  yang:schema [match] check if current module's prefix +0ms
  yang:schema [match] checking if submodule's parent +0ms
  yang:schema [match] check if one of current module's imports +0ms
  yang:expression [module(module-demo)] compile enter... (undefined) +0ms
  yang:element [module(module-demo)] found 1 new extension(s) +1ms
  yang:expression [module(module-demo)/prefix] compile enter... (undefined) +0ms
  yang:expression [module(module-demo)/prefix] compile: ok +0ms
  yang:expression [module(module-demo)/include(module-ext-demo)] compile enter... (undefined) +0ms
  yang:expression [submodule(module-ext-demo)] compile enter... (undefined) +0ms
  yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)] compile enter... (undefined) +0ms
  yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)/prefix] compile enter... (undefined) +1ms
  yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)/prefix] compile: ok +0ms
  yang:expression [submodule(module-ext-demo)/belongs-to(module-demo)] compile: ok +0ms
  yang:expression [submodule(module-ext-demo)/extension(arg-type)] compile enter... (undefined) +0ms
  yang:expression [submodule(module-ext-demo)/extension(arg-type)/description] compile enter... (undefined) +1ms
  yang:expression [submodule(module-ext-demo)/extension(arg-type)/description] compile: ok +0ms
  yang:expression [module(module-demo)/extension(info)/argument(text)] compile enter... (undefined) +0ms
  yang:expression [module(module-demo)/extension(info)/argument(text)/mdemo:arg-type] compile enter... (undefined) +0ms
  yang:schema [match] with extension mdemo:arg-type +0ms
  yang:schema [match] check if current module's prefix +0ms
  yang:schema [match] with extension mdemo:arg-type +1ms
  yang:schema [match] check if current module's prefix +0ms
  yang:schema [match] with extension mdemo:arg-type +0ms
  yang:schema [match] check if current module's prefix +0ms
  yang:schema [match] with extension mdemo:arg-type +0ms
  yang:schema [match] check if current module's prefix +0ms

from yang-js.

shlomiassaf avatar shlomiassaf commented on June 30, 2024

Thank you for the hard work!

from yang-js.

shlomiassaf avatar shlomiassaf commented on June 30, 2024

Thanks!

from yang-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.