Service Logic Interpreter Nodes
Table Of Contents
- 1 Table Of Contents
- 2 Schema
- 3 Supported node types
- 3.1 Flow Control
- 3.1.1 Block node
- 3.1.2 Break node
- 3.1.3 Call node
- 3.1.4 Exit node
- 3.1.5 For node
- 3.1.6 Return node
- 3.1.7 Set node
- 3.1.8 Switch node
- 3.1.9 While node
- 3.2 Device Management
- 3.2.1 Configure node
- 3.3 Java Plugin Support
- 3.3.1 Execute node
- 3.4 Recording
- 3.4.1 Record node
- 3.5 Resource Management
- 3.5.1 Delete node
- 3.5.2 Exists node
- 3.5.3 Get-resource node
- 3.5.4 Is-available node
- 3.5.5 Notify node
- 3.5.6 Release node
- 3.5.7 Reserve node
- 3.5.8 Save node
- 3.5.9 Update node
- 3.1 Flow Control
Schema
You can think of the JSON as Directed Graph source code and the XML as compiled code. The XML must conform to the schema at https://gerrit.onap.org/r/gitweb?p=ccsdk/sli/core.git;a=blob;f=sli/common/src/main/resources/svclogic.xsd;hb=refs/heads/master. The XML schema reveals what nodes are supported and which attributes are appropriate for each node. This page explains each node in plain English with accompanying code snippets as an alternative to reading the schema file itself.
Supported node types
The following built-in node types are currently supported:
Flow Control
Block node
Description
A block node is used to executes a set of nodes.
Attributes
atomic | if true, then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out. If unset it is treated as false. |
Parameters
None
Outcomes
None
Example
<block>
<record plugin="org.openecomp.sdnc.sli.recording.FileRecorder">
<parameter name="file" value="/tmp/gamma_r1.log" />
<parameter name="field1" value="__TIMESTAMP__"/>
<parameter name="field2" value="RESERVED"/>
<parameter name="field3" value="$asePort.uni_circuit_id"/>
</record>
<return status="success">
<parameter name="uni-circuit-id" value="$asePort.uni_circuit_id" />
</return>
</block>
Break node
Description
A break node is used to break out of a for or while loop.
Attributes
None
Parameters
None
Outcomes
None
Example
<break/>
Call node
Description
A call node is used to call another graph
Attributes
module | Module of directed graph to call. If unset, defaults to that of calling graph |
rpc | rpc of directed graph to call. |
version | version of graph to call, If unset, uses active version. |
mode | mode (sync/async) of graph to call. If unset, defaults to that of calling graph. |
Parameters
Not applicable
Outcomes
success | Sub graph returned success |
not-found | Graph not found |
failure | Subgraph returned success |
Example
<call rpc="svc-topology-reserve" mode="sync" />
Exit node
Description
An exit node is used to exit a graph without further execution
Attributes
None
Parameters
Not applicable
Outcomes
None
Example
For node
Description
A for node provides a fixed iteration looping mechanism, similar to the Java for loop
Attributes
atomic | if true, then if a node returns failure, subsequent nodes will not be executed and nodes already executed will be backed out. If unset it is treated as true. |
index | index variable |
start | initial value |
end | maximum value |
silentFailure | Optional boolean, when true for loops will not throw an exception for a null or invalid index. If unset it is treated as false. |
Parameters
Not applicable.
Outcomes
Not applicable. The status node has no outcomes.
Example
<for index="i" start="0" end="$network.num-segments"> <set> <parameter name="$vlanlist" value="eval($vlanlist+','+$network.segment[i].provider-segmentation-id)"/> </set> </for>
Return node
Description
A return node is used to return a status to the invoking MD-SAL application. The return node does not prevent the execution of subsequent nodes. The status set by the return node is tested by atomic for and block nodes.
Attributes
status | Status value to return (success or failure) |
Parameters
The following optional parameters may be passed to convey more detailed status information.
error-code | A brief, usually numeric, code indicating the error condition |
error-message | A more detailed error message |
Outcomes
Not applicable. The status node has no outcomes.
Example
<return status="failure"> <parameter name="error-code" value="1542" /> <parameter name="error-message" value="Activation failure" /> </return>
Set node
Description
A set node is used to set one or more values in the execution context
Attributes
only-if-unset | If true the set node will only execute if the current value of the target is null |
Parameters
Values to be set are passed as parameters
Outcomes
Not applicable. The set node has no outcomes.
Example
Switch node
Description
A switch node is used to make a decision based on its test attribute.
Attributes
test | Condition to test |
Parameters
None
Outcomes
Depends on the test condition
Example
While node
Description
A while node is used to create a while loop
Attributes
test | Condition to test |
do | Optional boolean, when true the loop executes once regardless of the test condition |
Parameters
None
Outcomes
Depends on the test condition
Example
Device Management
Configure node
Description
A configure node is used to configure a device.
Attributes
adaptor | Fully qualified Java class of resource adaptor to be used |
activate | Activate device/interface, for devices that support a separate activation step. |
key | SQL-like string specifying criteria for item to configure |
Parameters
Specific to device adaptor.
Outcomes
success | Device successfully configured |
not-found | Element to be configured does not exist. |
not-ready | Element is not in a state where it can be configured/activated |
already-active | Attempt to activate element that is already active |
failure | Configure failed for some other reason |
Example
Java Plugin Support
Execute node
Description
An execute node is used to execute Java code supplied as a plugin
Attributes
*** Parameters
plugin | Fully qualified Java class of plugin to be used |
method | Name of method in the plugin class to execute. Method must return void, and take 2 arguments: a Map (for parameters) and a SvcLogicContext (to allow plugin read/write access to context memory) |
emitsOutcome | Optional boolean value, when true the plugin must return a String which should represent an outcome |
Specific to plugin / method
Outcomes
success | Device successfully configured |
not-found | Plugin class could not be loaded |
unsupported-method | Named method taking (Map, SvcLogicContext) could not be found |
failure | Configure failed for some other reason |
Example
Recording
Record node
Description
A record node is used to record an event. For example, this might be used to log provisioning events.
Attributes
plugin | Fully qualified Java class to handle recording. |
Parameters
Parameters will depend on the plugin being used. For the FileRecorder class, the parameters are as follows
file | The file to which the record should be written |
field1 | First field to write. There will be field parameters for each field to write, from field1 through fieldN. A special value __TIMESTAMP__ may be assigned to a field to insert the current timestamp |
Outcomes
success | Record successfully written |
failure | Record could not be successfully written |
Example
Resource Management
Delete node
Description
A delete node is used to delete a resource from the local resource inventory.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to delete |
key | SQL-like string specifying key to delete |
Parameters
None
Outcomes
success | Resource specified deleted successfully. |
failure> | Resource specified was not deleted |
Example
Exists node
Description
An exists node is used to determine whether a particular instance of a resource exists. For example, this might be used to test whether a particular switch CLLI is provisioned.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to check |
key | SQL-like string specifying key to check for |
Parameters
None
Outcomes
true | Resource specified exists. |
false | Resource specified is unknown |
Example
Get-resource node
Description
A get-resource node is used to retrieve information about a particular resource and make it available to other nodes in the service logic tree. For example, this might be used to retrieve information about a particular uni-port.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to retrieve |
key | SQL-like string specifying criteria for retrieval |
pfx | Prefix to add to context variable names set for data retrieved |
select | String to specify, if key matches multiple entries, which entry should take precedence |
order-by | Prefix to add to context variable names set for data retrieved |
Parameters
None
Outcomes
success | Resource successfully retrieved |
not-found | Resource referenced does not exist |
failure | Resource retrieve failed for some other reason |
Example
Is-available node
Description
An is-available node is used to determine whether a particular type of resource is available. For example, this might be used to test whether any ports are available for assignment on a particular switch.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to check |
key | SQL-like string specifying key to check for |
pfx | Prefix to add to context variable names set for data retrieved |
Parameters
None
Outcomes
true | Resource requested is available |
false | Resource requested is not available |
Example
Notify node
Description
A notify node is used to inform an external application (e.g. A&AI) that a resource was updated.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Identifies resource that was updated |
action | Action that triggered notification to be sent (ADD/UPDATE/DELETE) |
Parameters
None
Outcomes
success | Notification was successful |
failure | Notification failed is not available |
Example
Release node
Description
A release node is used to mark a resource as no longer in use, and thus available for assignment.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to release |
key | SQL-like string specifying key to check of resource to release |
Parameters
None
Outcomes
success | Resource successfully released |
not-found | Resource referenced does not exist |
failure | Resource release failed for some other reason |
Example
Reserve node
Description
A reserve node is used to reserve a particular type of resource.. For example, this might be used to reserve a port on a particular switch.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to reserve |
key | SQL-like string specifying criteria for reservation |
select | String to specify, if key matches multiple entries, which entry should take precedence |
Parameters
None
Outcomes
success | Resource requested was successfully reserved |
failure | Resource requested was not successfully reserved |
Example
Save node
Description
A save node is used to save information about a particular resource to persistent storage. For example, this might be used to save information about a particular uni-port.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to save |
key | SQL-like string specifying criteria for retrieval |
force | If "true", save resource even if this resource is already stored in persistent storage |
pfx | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext |
Parameters
Values to save (columns) are specified as parameters, with each name corresponding to a column name and each value corresponding to the value to set.
Outcomes
success | Resource successfully saved |
failure | Resource save failed |
Example
Update node
Description
An update node is used to update information about a particular resource to persistent storage.
Attributes
plugin | Fully qualified Java class of resource adaptor to be used |
resource | Type of resource to update |
key | SQL-like string specifying criteria for retrieval |
pfx | Prefix to be prepended to variable names, when attributes are set in SvcLogicContext |
Parameters
Values to save (columns) are specified as parameters, with each name corresponding to a column name and each value corresponding to the value to set.
Outcomes
success | Resource successfully saved |
failure | Resource save failed |