b'\\ No newline at end of file'
1
# yfc -- YangForge Controller
3
[![Join the chat at https://gitter.im/saintkepha/yangforge](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/saintkepha/yangforge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
`yfc` is the command shell for the YangForge framework, providing
6
schema-driven application lifecycle management.
8
`YangForge` provides runtime JavaScript execution based on YANG schema
9
modeling language as defined in IETF drafts and standards
10
([RFC 6020](http://tools.ietf.org/html/rfc6020)).
12
[![NPM Version][npm-image]][npm-url]
13
[![NPM Downloads][downloads-image]][downloads-url]
15
[![NPM][history-image]][history-url]
17
Basically, the framework enables YANG schema language to *become* a
18
**programming** language.
20
It also utilizes YAML with custom tags to construct a portable module
23
It is written primarily using [CoffeeScript](http://coffeescript.org)
24
and runs on [Node.js](http://nodejs.org) and the **web browser** (yes, it's isomorphic).
26
This software is **sponsored** by
27
[ClearPath Networks](http://www.clearpathnet.com) on behalf of the
28
[OPNFV](http://opnfv.org) (Open Platform for Network Functions
29
Virtualization) community. For a reference implementation created entirely utilizing `YangForge`, please take a look at [OPNFV Promise](http://github.com/opnfv/promise) which provides future resource/capacity management (reservations/allocations) for virtualized infrastructure.
31
Please note that this project is under **active development**. Be sure
32
to check back often as new updates are being pushed regularly.
36
$ npm install -g yangforge
39
You must have `node >= 0.10.28` as a minimum requirement to run
44
Usage: yfc [options] [command]
49
build [options] [file] package the application for deployment
50
config manage yangforge service configuration (planned)
51
deploy deploy application into yangforge endpoint (planned)
52
info [options] [name] shows info about a specific module
53
publish [options] publish package to upstream registry (planned)
54
run [options] [modules...] runs one or more modules and/or schemas
55
schema [options] [file] process a specific YANG schema file or string
56
sign sign package to ensure authenticity (planned)
58
YANG driven JS application builder
62
-h, --help output usage information
63
-V, --version output the version number
64
--no-color disable color output
67
The `yfc` command-line interface is **runtime-generated** according to
68
[yangforge.yang](yangforge.yang) schema definitions. Please refer to
69
the schema section covering various `rpc` extension statements and
70
sub-statement definitions for a reference regarding different types of
71
command-line arguments, descriptions, and options processing syntax.
72
The corresponding **actions** for each of the `rpc` extensions are
73
implemented inside the `YangForge` YAML module
74
[package.yaml](package.yaml).
76
For comprehensive **usage documentation** around various CLI commands,
77
please refer to the [YangForge Examples README](examples#readme).
81
When you encounter errors or issues while utilizing the `yfc` command
82
line utility, you can set ENVIRONMENTAL variable `yfc_debug=1` to get
83
complete debug output of the `YangForge` execution log.
86
$ yfc_debug=1 yfc <some-command>
89
The output generated is very verbose and may or may not assist you in
90
determining the root cause. However, when reporting an issue into the
91
Github repository, it will be helpful to paste a snippet of the debug
92
output for quicker resolution by the project maintainer.
94
## Bundled YANG schema modules
96
There are a number of YANG schema modules commonly referenced and
97
utilized by other YANG modules during schema definition and they have
98
been *bundled* together into the `yangforge` package for convenience.
99
All you need to do is to `import <module name>` from your YANG schema
100
and they will be retrieved/resolved automatically.
102
name | description | reference
104
[complex-types](core/complex-types.yang) | extensions to model complex types and typed instance identifiers | RFC-6095
105
[iana-crypt-hash](core/iana-crypt-hash.yang) | typedef for storing passwords using a hash function | RFC-7317
106
[ietf-inet-types](core/ietf-inet-types.yang) | collection of generally useful types for Internet addresses | RFC-6991
107
[ietf-yang-types](core/ietf-yang-types.yang) | collection of generally useful derived data types | RFC-6991
109
Additional YANG modules will be bundled into the `yangforge` package
110
over time. Since `yangforge` facilitate *forging* of new YANG modules
111
and easily using them in your own projects, only industry standards
112
based YANG schema modules will be considered for native bundling at
115
## Bundled YANG features
117
name | description | dependency
119
[cli](features/cli.coffee) | generates command-line interface | none
120
[express](features/express.coffee) | generates HTTP/HTTPS web server instance | none
121
[restjson](features/restjson.coffee) | generates REST/JSON web services interface | express
122
[websocket](features/websocket.coffee) | generates socket.io interface | express
124
You can click on the *name* entry above for reference documentation on
127
## Using YangForge Programmatically
130
forge = require 'yangforge'
131
forge.import 'my-cool-schema.yang'
133
console.log app.info()
138
* **Parse** YAML/YANG/JSON schema files and generate runtime
139
JavaScript semantic object tree hierarchy
140
* **Import/Export** capabilities to load modules using customizable
141
importers based on regular expressions and custom import
142
routines. Ability to serialize module meta data into JSON format
143
that is portable across systems. Also exports serialized JS
144
functions as part of export meta data.
145
* **Runtime Generation** allows compiler to directly create a live JS
146
class object definition so that it can be instantiated via `new`
147
keyword and used immediately
148
* **Dynamic Extensions** enable compiler to be configured with
149
alternative `resolver` functions to change the behavior of produced
152
[YangForge](src/forge.coffee) itself is also a YANG schema
153
([yangforge.yang](./yangforge.yang)) **compiled** module. It is
154
compiled by the [yang-compiler](src/compiler.litcoffee) and
156
[yang-v1-extensions](core/yang-v1-extensions.yaml) submodule for
157
supporting the YANG version 1.0
158
([RFC 6020](http://tools.ietf.org/html/rfc6020)) specifications.
160
[yang-v1-extensions documentation](core/yang-v1-extensions.md) for
161
up-to-date info on YANG 1.0 language coverage status. It serves as a
162
good reference for writing new compilers, custom extensions, custom
163
typedefs, among other things.
165
### Primary interfaces
169
forge.import | local/remote async loading of one or more modules using filenames
170
forge.load | local async/sync loading of module(s), only one-at-a-time with sync
171
forge.compile | local sync compilation of a module, generates class obj that can be instantiated
172
forge.preprocess | local sync preprocessing of a module, constraint validations, schema manipulations
173
forge.parse | local sync parsing of a module, syntax validations, custom-tag resolutions
175
### Programmatic Usage Examples
177
The below examples can be executed using CoffeeScript REPL by running
178
`coffee` at the command-line from the top-directory of this repo.
180
Using the native YangForge module as a library:
183
forge = require 'yangforge'
187
description "a test";
188
leaf hello { type string; default "world"; }
192
# asynchronous load YANG schema
193
forge.load schema: yang
195
console.log app.get 'hello-world.hello'
196
app.set 'hello-world.hello', 'goodbye'
197
console.log app.get()
199
# synchronous load YANG schema
200
app = forge.load schmea: yang, async: false
201
console.log app.info format: 'json'
203
# compile YANG schema model as class object
204
HelloWorld = forge.compile schema: yang
205
hello = new HelloWorld 'hello-world': hello: 'howdy there'
206
console.log hello.get()
211
module embedded-world { leaf wow { type number; default 0; } }
213
{ "embedded-world": { "wow": 2 } }
216
# it can do YAML quite well
219
console.log app.get()
221
# sometimes you just want to preprocess to see what it becomes
222
console.log forge.preprocess yaml
225
Forging a new module/application for build/publish using YAML
226
(see also [complex-types](core/complex-types.yaml)):
228
name: some-new-application
229
schema: !yang some-new-application.yang
231
something-useful: !coffee/function
232
(input, output, done) ->
233
console.log input.get()
234
output.set 'important data'
238
Forging a new interface generator using YAML (see also
239
[cli example](features/cli.yaml)):
241
name: some-new-interface
242
description: Some new awesome interface
243
run: !coffee/function
245
# code logic to dynamically construct a new interface based on passed-in context
249
There are many other ways of interacting with the module's class
250
object as well as the instantiated class.
252
**More examples coming soon!**
254
## Literate CoffeeScript Documentation
256
The source code is documented in Markdown format. It's code combined
257
with documentation all-in-one.
259
* [YangForge](src/forge.coffee)
260
* [Compiler](src/compiler.litcoffee)
261
* [Features](features)
262
* [Module](package.yaml)
263
* [Schema](yangforge.yang)
264
* External Dependencies
265
* [data-synth library](http://github.com/saintkepha/data-synth)
266
* [js-yaml library](https://github.com/nodeca/js-yaml)
267
* [yang-parser library](https://gitlab.labs.nic.cz/labs/yang-tools/wikis/coffee_parser)
270
[Apache 2.0](LICENSE)
272
[npm-image]: https://img.shields.io/npm/v/yangforge.svg
273
[npm-url]: https://npmjs.org/package/yangforge
274
[downloads-image]: https://img.shields.io/npm/dm/yangforge.svg
275
[downloads-url]: https://npmjs.org/package/yangforge
276
[history-image]: https://nodei.co/npm-dl/yangforge.png?height=3
277
[history-url]: https://nodei.co/npm/yangforge