first initial working version of REST API auto-generation via yang-express using xos-core, cord-core, and its dependent modules. validate/polish various YANG schema files, introduce 'cord-core.yang' data model schema, annotate copyright/license info inside YANG schemas, create initial controller logic bindings for various cord data models. build/packaging complete with dependency mappings
diff --git a/package.json b/package.json
index a692d35..47f925a 100644
--- a/package.json
+++ b/package.json
@@ -22,14 +22,20 @@
"models": {
"ietf-yang-types": "yang-js",
"ietf-inet-types": "yang-js",
+ "corenova-node": "corenova",
"xos-core": "./schema/xos-core.yang",
+ "cord-core": "./lib/cord-core.js",
"cord-device": "./schema/cord-device.yang",
- "cord-subscriber": "./schema/cord-subscriber.yang"
+ "cord-subscriber": "./lib/cord-subscriber.js"
},
"dependencies": {
"node-uuid": "^1.4.7",
"superagent": "^2.0.0",
- "yang-js": "^0.14.18"
+ "yang-express": "^0.2.1",
+ "yang-js": "^0.14.20"
+ },
+ "optionalDependencies": {
+ "corenova": "^1.0.0"
},
"devDependencies": {
"coffee-script": ">=1.7.0",
@@ -38,7 +44,7 @@
"rimraf": "^2.5.2",
"should": "~3.1.3"
},
- "main": "./lib/index.js",
+ "main": "./lib/server.js",
"scripts": {
"clean": "rimraf dist/* lib/*",
"prebuild": "npm run clean -s && mkdir -p dist",
@@ -46,6 +52,7 @@
"build": "npm run build:src",
"prepublish": "npm run build",
"pretest": "npm run build",
- "test": "mocha"
+ "test": "mocha",
+ "start": "node lib/server.js"
}
}
diff --git a/sample-data.json b/sample-data.json
new file mode 100644
index 0000000..5e5377e
--- /dev/null
+++ b/sample-data.json
@@ -0,0 +1,12 @@
+{
+ "api": {
+ "service": {},
+ "tenant": {}
+ },
+ "cord": {
+ "subscriber": [
+ { "id": 1, "service-specific-id": 1000 },
+ { "id": 2, "service-specific-id": 1001 }
+ ]
+ }
+}
diff --git a/schema/cord-core.yang b/schema/cord-core.yang
new file mode 100644
index 0000000..25d3d3a
--- /dev/null
+++ b/schema/cord-core.yang
@@ -0,0 +1,59 @@
+module cord-core {
+
+ namespace "urn:onlab:cord";
+ prefix cord;
+ yang-version 1.1;
+
+ organization
+ "Open Networking Lab (CORD) / Corenova Technologies";
+
+ contact
+ "Larry Peterson <llp@onlab.us>
+ Peter K. Lee <peter@corenova.com>";
+
+ description
+ "This module contains a collection of core models for CORD.
+
+ Copyright (c) 2016 ON.LAB and the persons identified as authors of
+ the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, is permitted pursuant to, and subject to the license
+ terms of the Apache License, Version 2.0 which accompanies this
+ distribution, and is available at
+ (http://www.apache.org/licenses/LICENSE-2.0).";
+
+ revision 2016-07-22 {
+ description "Initial revision.";
+ }
+
+ import xos-core { prefix xos; }
+ import cord-subscriber { prefix csub; }
+ import corenova-node { prefix node; }
+
+ /*** primary configuration tree for this module ***/
+
+ container cord {
+ list subscriber {
+ uses csub:subscriber-controller;
+ key "id";
+
+ description
+ "Authorative list of all subscriber instances";
+
+ leaf humanReadableName {
+ config false;
+ type string {
+ pattern '^cordSubscriber-\w+$';
+ }
+ }
+ action delete;
+ }
+ }
+
+ // here we augment the /api/tenant/cord API configuration tree in 'xos' module
+ augment "/xos:api/xos:tenant" {
+ container cord { node:map "/cord:cord"; }
+ }
+
+}
diff --git a/schema/cord-device.yang b/schema/cord-device.yang
index df77138..c0916ff 100644
--- a/schema/cord-device.yang
+++ b/schema/cord-device.yang
@@ -44,6 +44,5 @@
}
action update;
}
- action save;
}
}
diff --git a/schema/cord-subscriber.yang b/schema/cord-subscriber.yang
index bfb782f..8f3dae5 100644
--- a/schema/cord-subscriber.yang
+++ b/schema/cord-subscriber.yang
@@ -1,6 +1,7 @@
module cord-subscriber {
+
namespace "urn:onlab:cord:subscriber";
- prefix cord-sub;
+ prefix csub;
yang-version 1.1;
organization
@@ -10,15 +11,28 @@
"Larry Peterson <llp@onlab.us>
Peter K. Lee <peter@corenova.com>";
- import xos-core { prefix xos; }
- import cord-device { prefix dev; }
- import ietf-yang-types { prefix yang; }
- //import yang-node-link { prefix node; }
+ description
+ "This module contains CORD Subscriber model representing its
+ relationship to features, services, and devices.
+ Copyright (c) 2016 ON.LAB and the persons identified as authors of
+ the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, is permitted pursuant to, and subject to the license
+ terms of the Apache License, Version 2.0 which accompanies this
+ distribution, and is available at
+ (http://www.apache.org/licenses/LICENSE-2.0).";
+
revision 2016-07-14 {
description "Initial revision.";
}
+ import xos-core { prefix xos; }
+ import cord-device { prefix dev; }
+ import ietf-yang-types { prefix yang; }
+ import corenova-node { prefix node; }
+
identity cord-subscriber { base xos:subscriber; }
grouping subscriber {
@@ -85,110 +99,51 @@
}
}
- list devices {
+ list device {
uses dev:device;
- key 'mac';
+ key "mac";
action create {
- input {
- leaf mac {
- type yang:mac-address;
- mandatory true;
- }
- // other acceptable attributes that can be used during create
- }
+ input { uses dev:device; }
}
action update {
- input {
- leaf mac {
- type yang:mac-address;
- //must "../.[mac = current()]";
- mandatory true;
- }
- // other acceptable attributes for updating
- }
+ input { uses dev:device; }
}
- action delete {
- input {
- leaf mac {
- type yang:mac-address;
- //must "../.[mac = current()]";
- mandatory true;
- }
- // other acceptable attributes for updating
- }
- }
- }
-
- action save {
- description "when invoked, saves the model to a safe place";
+ action delete;
}
}
grouping subscriber-controller {
uses subscriber;
+ node:view "features identity related";
+
container features {
- leaf cdn {
- //path "../../services/cdn/enabled";
- }
- leaf uplink-speed {
- //path "../../uplink-speed";
- }
- leaf downlink-speed {
- //path "../../downlink-speed";
- }
- leaf uverse {
- //path "../../services/uverse/enabled";
- }
- leaf status {
- //path "../../status";
- }
+ leaf cdn { node:link "../../services/cdn/enabled"; }
+ leaf uplink-speed { node:link "../../uplink-speed"; }
+ leaf downlink-speed { node:link "../../downlink-speed"; }
+ leaf uverse { node:link "../../services/uverse/enabled"; }
+ leaf status { node:link "../../status"; }
+
action update {
description "when invoked, updates the features container (PUT)";
}
}
container identity {
- leaf account-num {
- //path "../../service-specific-id";
- }
- leaf name {
- //path "../../name";
- }
+ leaf account-num { node:link "../../service-specific-id"; }
+ leaf name { node:link "../../name"; }
+
action update {
description "when invoked, updates the identity container (PUT)";
}
}
container related {
- // placeholder where other services can augment for their info
- }
- }
-
- // primary configuration tree for this module
- list subscriber {
- uses subscriber-controller;
- key 'id';
-
- description
- "Authorative list of all subscriber instances";
-
- leaf humanReadableName {
config false;
- type string {
- pattern '^cordSubscriber-\w+$';
- }
- }
- action create;
- action delete;
- }
-
- // here we augment the /api/tenant/cord API configuration tree in 'xos' module
- augment "/xos:api/xos:tenant/xos:cord" {
- container subscriber {
- //path "/subscriber";
+ description
+ "placeholder where other services can augment for info they want to
+ share (READ-ONLY)";
}
}
-
}
diff --git a/schema/corenova-node.yang b/schema/corenova-node.yang
new file mode 100644
index 0000000..104c2e4
--- /dev/null
+++ b/schema/corenova-node.yang
@@ -0,0 +1,52 @@
+module corenova-node {
+ namespace "urn:corenova:node";
+ prefix node;
+
+ organization
+ "Corenova Technologies, Inc.";
+
+ contact
+ "Peter K. Lee <peter@corenova.com>";
+
+ description
+ "This module defines extensions to dynamically control schema node
+ display and access overlay controls";
+
+ feature corenova-node {
+ description
+ "this is to indicate the agent supports dynamic schema node
+ link/map/view.";
+ }
+
+ extension link {
+ description
+ "Links the current leaf (or leaf-list) to an alternate leaf in the
+ schema data tree. The current leaf becomes a 'mirror' instance
+ of the target node.";
+ argument target-node-path {
+ yin-element true;
+ }
+ }
+
+ extension map {
+ description
+ "Maps the current container (or list entry) to an alternate container
+ in the schema data tree. The target-node-path must not map to
+ leaf or leaf-list nodes. The current container will map to
+ additional data nodes found inside the alternate container. The
+ mapped data nodes behave similarly to the 'link' extension
+ case. It can be defined one or more times within the same
+ container to map across modules and other subtrees.";
+ argument target-node-path {
+ yin-element true;
+ }
+ }
+
+ extension view {
+ description
+ "Informs the interface layers that only the data nodes referenced
+ within the value argument should be made visible to the
+ consumer.";
+ argument value;
+ }
+}
diff --git a/schema/xos-core.yang b/schema/xos-core.yang
index b0d4eaf..82d1a7e 100644
--- a/schema/xos-core.yang
+++ b/schema/xos-core.yang
@@ -10,11 +10,28 @@
"Larry Peterson <llp@onlab.us>
Peter K. Lee <peter@corenova.com>";
+ description
+ "This module contains a collection of core models for XOS.
+
+ Copyright (c) 2016 ON.LAB and the persons identified as authors of
+ the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, is permitted pursuant to, and subject to the license
+ terms of the Apache License, Version 2.0 which accompanies this
+ distribution, and is available at
+ (http://www.apache.org/licenses/LICENSE-2.0).";
+
+ revision 2016-07-14 {
+ description "Initial revision.";
+ }
+
import ietf-yang-types { prefix yang; }
import ietf-inet-types { prefix inet; }
- revision 2016-07-14 {
- description "Initial revision.";
+ feature synchronizer {
+ description
+ "Enables configuration synchronization to the distributed store.";
}
identity kind;
@@ -31,7 +48,6 @@
}
grouping tenant-root {
-
description
"A Tenant Root is one of the things that can sit at the root of a chain
of tenancy. This object represents a node.";
@@ -63,7 +79,6 @@
config false;
// not exactly clear how this is populated
}
-
}
grouping subscriber {
@@ -71,22 +86,21 @@
refine kind { default subscriber; }
}
// seems we should have interesting attributes specific to subscriber?
-
}
- // main configuration tree for XOS
+ /*** main configuration tree for XOS ***/
container api {
+ description
+ "The primary configuration interaction endpoint";
+
container service {
- // placeholder endpoint for services
+ description
+ "placeholder endpoint for services to augment";
}
container tenant {
- container cord {
- // placeholder endpoint for augment
- }
- container onos {
- // placeholder endpoint for augment
- }
+ description
+ "placeholder endpoint for tenants to augment";
}
}
diff --git a/schema/yang-node-link.yang b/schema/yang-node-link.yang
deleted file mode 100644
index 1b93538..0000000
--- a/schema/yang-node-link.yang
+++ /dev/null
@@ -1,5 +0,0 @@
-module yang-node {
- extension link {
- argument name;
- }
-}
diff --git a/src/cord-core.coffee b/src/cord-core.coffee
new file mode 100644
index 0000000..1d27a26
--- /dev/null
+++ b/src/cord-core.coffee
@@ -0,0 +1,17 @@
+#
+# Author: Peter K. Lee (peter@corenova.com)
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+require('yang-js').register()
+
+module.exports = require('../schema/cord-core.yang').bind {
+
+ '/cord/subscriber/humanReadableName': -> "cordSubscriber-#{@get '../id'}"
+
+ '/cord/subscriber/delete': (input, resolve, reject) -> reject "not yet implemented"
+}
diff --git a/src/cord-device.coffee b/src/cord-device.coffee
new file mode 100644
index 0000000..ce6c892
--- /dev/null
+++ b/src/cord-device.coffee
@@ -0,0 +1,16 @@
+#
+# Author: Peter K. Lee (peter@corenova.com)
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+require('yang-js').register()
+
+module.exports = require('../schema/cord-device.yang').bind {
+
+ '/{device}/features/update': (input, resolve, reject) -> reject "not yet implemented"
+
+}
diff --git a/src/cord-subscriber.coffee b/src/cord-subscriber.coffee
new file mode 100644
index 0000000..7563aa7
--- /dev/null
+++ b/src/cord-subscriber.coffee
@@ -0,0 +1,32 @@
+#
+# Author: Peter K. Lee (peter@corenova.com)
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+require('yang-js').register()
+
+module.exports = require('../schema/cord-subscriber.yang').bind {
+
+ '/{subscriber}':
+ # auto-computed properties
+ 'device/subscriber': -> @get '../..'
+
+ # action bindings
+ 'device/create': (input, resolve, reject) -> reject "TBD"
+ 'device/update': (input, resolve, reject) -> reject "TBD"
+ 'device/delete': (input, resolve, reject) -> reject "TBD"
+
+ '/{subscriber-controller}':
+ # auto-computed properties
+ 'related': -> new Error "will return related objects once implemented"
+
+ # action bindings
+ 'features/update': (input, resolve, reject) -> reject "TBD"
+ 'identity/update': (input, resolve, reject) -> reject "TBD"
+
+}
+
diff --git a/src/server.coffee b/src/server.coffee
new file mode 100644
index 0000000..7e7b46c
--- /dev/null
+++ b/src/server.coffee
@@ -0,0 +1,11 @@
+yang = require('yang-js').register()
+
+require('yang-express').run {
+
+ port: 5050
+ models: [
+ yang.require 'cord-core'
+ ]
+ data: require '../sample-data.json'
+
+}