Jira | ||||||
---|---|---|---|---|---|---|
|
Table of Contents |
---|
Purpose of spike
...
The purpose of this spike is to investigate how fields and depth can be implemented and used in conjunction with Restconf to gather attributes from xNFs and be able to determine the depth of information retrieved.
...
See https://tools.ietf.org/id/draft-ietf-netconf-restconf-07.xml and https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.3
The capabilities of both parameters as defined by RESTConf
Fields
The "fields" query parameter is used to optionally identify data nodes within the target resource to be retrieved in a GET method. The client can use this parameter to retrieve a subset of all nodes in a resource.
- ";" is used to select multiple nodes. For example, to retrieve only the "genre" and "year" of an album, use: "fields=genre;year".
- Parentheses are used to specify sub-selectors of a node. For example, to retrieve only the "label" and "catalogue‑number" of an album, use: "fields=admin(label;catalogue‑number)".
- "/" is used in a path to retrieve a child node of a node. For example, to retrieve only the "label" of an album, use: "fields=admin/label".
- This parameter is only allowed for GET methods on api, datastore, and data resources. A 400 Bad Request error is returned if used for other methods or resource types.
Fields example
Depth
The "depth" parameter is used to specify the number of nest levels returned in a response for a GET method. The first nest-level consists of the requested data node itself. Any child nodes which are contained within a parent node have a depth value that is 1 greater than its parent.
- The value of the "depth" parameter is either an integer between 1 and 65535, or the string "unbounded". "unbounded" is the default.
- This parameter is only allowed for GET methods on API, datastore, and data resources. A 400 Bad Request error is returned if it used for other methods or resource types.
- By default, the server will include all sub-resources within a retrieved resource, which have the same resource type as the requested resource. Only one level of sub-resources with a different media type than the target resource will be returned.
Depth Example
The support/limitations of both parameters as implemented by the 'rests' ODL module interface (SDN-C)
The "rests" odl interface supports fields and depth parameters
Assumptions
...
Code Block | ||||
---|---|---|---|---|
| ||||
module turing-machine {
namespace "http://example.net/turing-machine";
prefix "tm";
description
"Data model for the Turing Machine.";
revision 2013-12-27 {
description
"Initial revision.";
}
/* Typedefs */
typedef tape-symbol {
type string {
length "0..1";
}
description
"Type of symbols appearing in tape cells.
A blank is represented as an empty string where necessary.";
}
typedef cell-index {
type int64;
description
"Type for indexing tape cells.";
}
typedef state-index {
type uint16;
description
"Type for indexing states of the control unit.";
}
typedef head-dir {
type enumeration {
enum left;
enum right;
}
default "right";
description
"Possible directions for moving the read/write head, one cell
to the left or right (default).";
}
/* Groupings */
grouping tape-cells {
description
"The tape of the Turing Machine is represented as a sparse
array.";
list cell {
key "coord";
description
"List of non-blank cells.";
leaf coord {
type cell-index;
description
"Coordinate (index) of the tape cell.";
}
leaf symbol {
type tape-symbol {
length "1";
}
description
"Symbol appearing in the tape cell.
Blank (empty string) is not allowed here because the
'cell' list only contains non-blank cells.";
}
}
}
/* State data and Configuration */
container turing-machine {
description
"State data and configuration of a Turing Machine.";
leaf state {
type state-index;
config "false";
mandatory "true";
description |
...
rests bundle is enable by default
...
node has been mounted
Info |
---|
rests interface supports application/yang-data+json format |
rests Interface Fields Examples
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "turing-machine:turing-machine": { "transition-function": { "delta": [ { "output": { "Current state of the control unit. The initial "state": 1 is 0."; } leaf head-position { }type cell-index; config "false"; mandatory "true"; }, description "Position of tape {read/write head."; } container tape { config "outputfalse": {; description "The contents of the tape."; "state": 3uses tape-cells; } container transition-function { }description "The Turing Machine is configured by specifying },the transition function."; list delta {}, key "label"; { unique "input/state input/symbol"; description "output": { The list of transition rules."; leaf label { "state": 4type string; description } "An arbitrary label of the transition rule."; }, container input { {}, description {"Input parameters (arguments) of the transition rule."; leaf state { "output": { type state-index; mandatory "true"; "state": 2description "Current state of the control unit."; } } }, leaf symbol { {} type tape-symbol; mandatory ]"true"; } } } |
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ description "turing-machine:transition-function": { "delta": [Symbol read from the tape cell."; } { } container "output": { description "state": 1, "Output values of the transition rule."; leaf "symbol": "1"state { }type state-index; },description { "New state of the control unit. If this leaf "output": {is not present, the state doesn't "state": 3, change."; } leaf "symbol": "0"{ }type tape-symbol; },description {}, "Symbol to be written to the tape cell. If this leaf {is "output": { not present, the symbol doesn't change."; } "state": 4 leaf head-move { }type head-dir; },description {}, "Move the head one cell to the left or right"; { } "output": {} } } } /* RPCs */ rpc "state": 2initialize { description "Initialize the Turing Machine as }follows: 1. Put the control unit },into the initial state (0). 2. Move the read/write head to the tape cell {}with coordinate ] } } |
rests Interface Depth Examples
If the "fields" parameter is used to select descendant data nodes, then these nodes and all of their ancestor nodes have a "depth" value of "1".
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{} |
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "transition-function": { zero. 3. Write the string from the 'tape-content' input parameter to the tape, character by character, starting at cell 0. The tape is othewise empty."; input { leaf tape-content { type string; default "delta":; [ description {}, "The string with which the tape {},shall be initialized. The leftmost {}, symbol will be at tape coordinate 0."; {}, } } rpc run {}, description "Start the {}, Turing Machine operation."; } rpc run-until { {}description "Start the Turing ] Machine operation and } } |
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "transition-function": {let it run until it is halted or "delta": [ALL the defined breakpoint conditions are satisfied."; input { leaf state { type state-index; "label": "separator" description "What state }, the control unit has to be at for the execution to be {paused."; } leaf head-position { "label": "write separator" type cell-index; },description "Position of { tape read/write head for which the breakpoint applies."; } "label": "right summand" container tape { },description "What content { the tape has to have for the breakpoint to apply."; "label": "final step" uses tape-cells; } }, output { leaf step-count { type uint64; "label": "go home" description "The number of steps }, executed since the last 'run-until' call."; {} leaf halted { "label": "right end"type boolean; description }, "'True' if the Turing machine is { halted, 'false' if it is only paused."; } "label": "left summand" } ] } } |
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "transition-function": {} } /* Notifications */ notification halted { description "The Turing Machine has halted. This means that there is no transition rule for the current state and tape symbol."; leaf state { type state-index; mandatory "deltatrue": [; description { "The state of the control unit in which the machine has "label": "separator", halted."; } } "input":notification paused { description "The Turing machine has reached a breakpoint and was "state": 0,paused."; leaf state { type state-index; mandatory "symbol": "0"true"; description "State of }, the control unit in which the machine was paused."; } "output":leaf head-position { type cell-index; mandatory "true"; "state": 1,description "Position of tape read/write head when the machine was paused."; "symbol": "1" } container tape { description } "Content of the tape when the machine },was paused."; uses tape-cells; } } } |
Code Block | ||||
---|---|---|---|---|
| ||||
{ "turing-machine": { "transition-function": { "label "delta": "write separator",[ "input": { "statelabel": 2"separator", "symbolinput": "1"{ }, "state": 0, "output": { "statesymbol": 3,"0" "symbol": "0"}, "head-moveoutput": "left"{ } }"state": 1, { "labelsymbol": "right summand1", "input": { } "state": 1}, { "symbol": "1" } "label": "write separator", }, "input": { { "labelstate": "final step"2, "inputsymbol": {"1" "state": 3}, "symboloutput": ""{ }, "state": 3, "output": { "statesymbol": 4"0", } "head-move": "left" }, { } "label": "go home"}, "input": { "statelabel": "right 3summand", "symbolinput": "1"{ }, "state": 1, "output": { "head-movesymbol": "left1" } }, { "label": "rightfinal endstep", "input": { "state": 13, "symbol": "" }, "output": { "state": 2,4 "head-move": "left"} }, }, { { "label": "leftgo summandhome", "input": { "state": 03, "symbol": "1" }, } ]"output": { "head-move": "left" } } |
Note: Depth of 0 will result in a 400 (Bad Request)
Code Block | ||
---|---|---|
| ||
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Error 400 Bad Request</title>
</head>
<body>
<h2>HTTP ERROR 400</h2>
<p>Problem accessing
/rests/data/network-topology:network-topology/topology=topology-netconf/node=PNFDemo/yang-ext:mount/turing-machine:turing-machine/transition-function.
Reason:
<pre> Bad Request</pre>
</p>
</body>
</html> |
The feasibility/cost of NCMP 'translating' a fields-option without module information into a RESTConf compatible fields value. High level user story view of cost.
Fields that come in via NCMP will need to be translated into Restconf compatible fields.
Can we delegate to rests interface and supply fields "as is"
The feasibility/cost of support a 'depth' parameter for CPS cached data and/or ONAP DMI Plugin
High level user story view of cost
Will need to determine what is meant by cps cached data
...
},
{
"label": "right end",
"input": {
"state": 1,
"symbol": ""
},
"output": {
"state": 2,
"head-move": "left"
}
},
{
"label": "left summand",
"input": {
"state": 0,
"symbol": "1"
}
}
]
}
}
} |
Assumptions
# | Assumption | Notes |
---|---|---|
1 | rests bundle is enable by default | |
2 | node has been mounted |
Open Issues & Decisions
...
# | Question | Answer |
---|---|---|
1 | When field function is used to list attributes in child will the parent still be part of output? | Yes if we do not specifically use delta=separator/input?fields=state |
2 | When not supplied with the module, if one match is found then we can insert the module. If more than one submodule is found with the same top-level element then it becomes ambiguous and cannot be resolved. | The system will throw an exception in the scenario where more then one submodule |
The capabilities of both parameters as defined by RESTConf
...
Fields
The "fields" query parameter is used to optionally identify data nodes within the target resource to be retrieved in a GET method. The client can use this parameter to retrieve a subset of all nodes in a resource.
- ";" is used to select multiple nodes. For example, to retrieve only the "genre" and "year" of an album, use: "fields=genre;year".
- Parentheses are used to specify sub-selectors of a node. For example, to retrieve only the "label" and "catalogue‑number" of an album, use: "fields=admin(label;catalogue‑number)".
- "/" is used in a path to retrieve a child node of a node. For example, to retrieve only the "label" of an album, use: "fields=admin/label".
- This parameter is only allowed for GET methods on api, datastore, and data resources. A 400 Bad Request error is returned if used for other methods or resource types.
Fields Syntax
Code Block | ||||
---|---|---|---|---|
| ||||
'fields=' ( <module-name> ':' )? <container-name> ( '(' <leaf-name> ( ',' <leaf-name> )* ')' )?
( '/' ( <module-name> ':' )? <container-name> ( '(' <leaf-name> ( ',' <leaf-name> )* ')' )? )*
fields=/shops
fields=/shops/shop
fields=/shops/shop(postal-code,town)
fields=bookstore:/shops/shop
fields=bookstore:/shops/bookstore:shop(postal-code,town)
fields=bookstore:/shops/shop(postal-code,town)/bookmodule:book(title)
*<module-name> ':' is compulsory when 'changing' into a different module from the parent node
|
Depth
The "depth" parameter is used to specify the number of nest levels returned in a response for a GET method. The first nest-level consists of the requested data node itself. Any child nodes which are contained within a parent node have a depth value that is 1 greater than its parent.
- The value of the "depth" parameter is either an integer between 1 and 65535, or the string "unbounded". "unbounded" is the default.
- This parameter is only allowed for GET methods on API, datastore, and data resources. A 400 Bad Request error is returned if it used for other methods or resource types.
- By default, the server will include all sub-resources within a retrieved resource, which have the same resource type as the requested resource. Only one level of sub-resources with a different media type than the target resource will be returned.
Depth Example
The support/limitations of both parameters as implemented by the 'rests' ODL module interface (SDN-C)
...
The "rests" odl interface supports fields and depth parameters
Info |
---|
rests interface supports application/yang-data+json format |
The feasibility/cost of NCMP 'translating' a fields-option without module information
...
The feasibility/cost of NCMP 'translating' a fields-option without module information into a RESTConf compatible fields value. High level user story view of cost.
Alternatives
- Assume that the query is in one module and no module information is required - cost 0 but won't always work
- Insert module information at the start and each transition of module - might lead to unnecessarily long fields section
- Insert module information for each element - nicest option
Cost alternative three
- Combine the resource path and the fields path into a 'target' path
requires new interface/REST method on CPS core (assuming there is an anchor with this schema-set) - Walk schema context and check the module for each element
Throw exception when more than one solution is encountered - Insert module name where needed
Estimate: 1 or 2 user stories (1 or 2 weeks work)
The feasibility/cost of support a 'depth' parameter for CPS cached data and/or ONAP DMI Plugin
...
- At the moment we have code to to include all or no descendants
Estimate: 1 user story (1-2 days to modify existing all-or-nothing approach)
Interaction Between Fields & Depth Parameters
...
Note: Depth can be any value .> 0. However, all details above field in question will be added to output
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{
"transition-function": {
"delta": [
{
"output": {
"state": 1
}
},
{
"output": {
"state": 3
}
},
{},
{
"output": {
"state": 4
}
},
{},
{
"output": {
"state": 2
}
},
{}
]
}
} |
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{
"transition-function": {
"delta": [
{
"output": {
"state": 1
}
},
{
"output": {
"state": 3
}
},
{},
{
"output": {
"state": 4
}
},
{},
{
"output": {
"state": 2
}
},
{}
]
}
} |
Note: field take precedence so adding depth=2 is the same as depth=1
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{
"transition-function": {
"delta": [
{
"output": {
"state": 1,
"symbol": "1"
}
},
{
"output": {
"state": 3,
"symbol": "0"
}
},
{},
{
"output": {
"state": 4
}
},
{},
{
"output": {
"state": 2
}
},
{}
]
}
} |
Fields with module examples
...
...
...
...
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "transitionturing-functionmachine": { "deltatransition-function": [ { "output": { "state": 1 } delta": [ }, { { "output": { "state": 31 } }, }, {}, { { "output": { "state": 43 } } }, }, {}, {}, "output": { "stateoutput": 2 }{ }, {} "state": 4 ] } } |
Can also work with multiple fields as above
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "transition-function": { } }, "delta": [ {}, { "output": { "state": 1,2 "symbol": "1"} } , {}, {] } } } |
- We can get the child by using http://localhost:8282/rests/data/network-topology:network-topology/topology=topology-netconf/node=PNFDemo/yang-ext:mount/turing-machine:turing-machine/transition-function/delta=separator
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "outputturing-machine:delta": {[ { "statelabel": 3"separator", "symbol"input": "0"{ }"state": 0, }, {},"symbol": "0" {}, "output": { "state": 41, }"symbol": "1" }, } {},] } |
- We can get the child of delta, input in this case by appending delta label "seperator" and the child we want http://localhost:8282/rests/data/network-topology:network-topology/topology=topology-netconf/node=PNFDemo/yang-ext:mount/turing-machine:turing-machine/transition-function/delta=separator/input
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ { "output"turing-machine:input": { "state": 20, } }, "symbol": "0" } } |
- We can also get specific fields without ancestors in the tree http://localhost:8282/rests/data/network-topology:network-topology/topology=topology-netconf/node=PNFDemo/yang-ext:mount/turing-machine:turing-machine/transition-function/delta=separator/input?fields=state
JSON Viewer | ||||
---|---|---|---|---|
| ||||
{ "turing-machine:input": { {} ]"state": 0 } } |
Questions
...
Video of Demo
Setting up local netconf-pnp-simulator & SDNC environment
...
- Run docker load -i image.tar to to unpack netconf docker image v2.8.6
- Unzip certs.tar to same folder as docker-compose.yml (SDNC docker)
- Unpack sim.zip
- Run docker-compose up -d d
- Unpack sim.zip
- cd into sim & run Run sim/docker-compose -f docker-compose-sim.yml up -d (netconf-pnp-simulator docker)
- To access local SDNC/ODL use - http://localhost:8282/apidoc/explorer/index.html
- Credentials : - admin / Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
...