VinodKumarS-Huawei
Committed by Gerrit Code Review

YMS broker and Notification handler

Change-Id: Ic3659b2c2ad26ea2db1f03725b4883f19db2cc41
Showing 21 changed files with 1040 additions and 50 deletions
......@@ -16,20 +16,195 @@
package org.onosproject.yms.ych;
import java.util.List;
import java.util.Map;
import org.onosproject.yms.ydt.YmsOperationType;
/**
* Abstraction of an entity which provides interfaces to YANG codec handler.
*
* In SBI, the provider or driver uses YANG management system as a CODEC
* utility. These providers/drivers use the YANG codec utility to register
* the device schema. YANG utils is used to generate the java files
* corresponding to the device schema. Provider or driver use these classes
* to seamlessly manage the device as java objects. While sending the request
* to device, drivers use the utility to translate the objects to protocol
* specific data representation and then send to the device.
* Protocol or driver use the same instance of the codec utility across multiple
* translation request.
* utility. Providers/drivers register the device schema with YANG management
* system. YANG utils is used to generate the java files corresponding to the
* device schema. Provider or driver use these classes to seamlessly manage
* the device as java objects. While sending the request to device, drivers
* use the utility to translate the objects to protocol specific data
* representation and then send to the device. Protocol or driver use the
* same instance of the codec utility across multiple translation request.
* Protocol or driver should not use the same instance of utility concurrently.
*/
public interface YangCodecHandler {
//TODO
/**
* Provider / driver needs to register the device schema with code handler.
* Then the provider / driver can use the codec handler to perform the
* codec operation. When the codec operation is being performed, the
* codec utility finds the mapping registered device model and perform the
* translation against the device schema.
*
* @param yangModule YANG utils generated class corresponding to SBI
* device schema module
*/
void addDeviceSchema(Class yangModule);
/**
* When the drivers / providers need to encode a protocol operation
* requests, which is in a single block, this encode API is used.
* A single protocol operation can span across multiple application, then
* the driver / provider need to provide the list of application(s) module
* object. Each module object contains the request information
* corresponding to that application.
*
* The protocols can have a logical root node which acts as a container
* of applications module node. For example in NETCONF, it could be
* data/filter/config, etc. Protocols needs to pass this parameter in the
* encode request, so that it is part of the encoded protocol packet.
* There is no validation done on the value of this parameter. It is up to
* the protocol to use it. It is a mandatory parameter and protocols must
* pass this parameter. In protocols like NETCONF, these logical root
* node may be in a specific name space, in such cases, it needs to be
* passed to encode it as part of the request. There could be additional
* tags that can be attached to the root node, for example in NETCONF,
* the tag type="subtree" can be specified. In such scenarios the
* required tags should be sent as a parameter.
*
* The provider / driver would require to operate on multiple schema
* nodes in a single request, for example it may be require to configure
* a tunnel and associate a QOS to this tunnel, in this scenario, it
* needs to have the tunnel related information in the tunnel module's
* Java object and and QOS related information in QOS modules Java
* object. So in a single request, it can send the list of Java objects
* corresponding to the modules which need to participate in the operation.
* If the request to be generated needs to be a wild card for no
* application(s), then this parameter needs to be null. For example a
* "empty filter" request in NETCONF get request.
* If the request to be generated needs to be a wild card for all
* application(s), then the driver / provider should not invoke this API,
* as there is no encoding of application related information for the
* operation, it is only limited to the protocol operation. For example a
* "no filter" request in NETCONF get request.
*
* @param rootName name of logical root node as required by
* the protocol
* @param rootNamespace namespace of logical root node as
* required by the protocol encoding. It is
* an optional parameter.
* @param tagAttributeLinkedMap Specifies the list of attributes that
* needs to be tagged with the logical root
* node. It is an optional parameter
* if not required for the protocol.
* @param yangModuleList list of YANG module's object(s)
* participating in the operation.
* @param dataFormat data format to which encoding to be done.
* @param protocolOperation protocol operation being performed
* @return string containing the requested applications object
* information encoded in protocol format.
*/
String encodeOperation(String rootName, String rootNamespace,
Map<String, String> tagAttributeLinkedMap,
List<Object> yangModuleList,
YangProtocolEncodingFormat dataFormat,
YmsOperationType protocolOperation);
/**
* When the drivers / providers need to encode protocol composite
* operation requests, which is split in a composite blocks, this encode
* composite operation API is used. The application module object
* containing the request information has both the resource identifier
* part and the resource information part.
*
* The protocols can have a logical root node which acts as a container
* of applications module node. For example in RESTCONF, it could be
* RootResource/data, etc. There is no validation done on the value
* of this parameter. It is upto the protocol to use it. It is a
* mandatory parameter and protocols must pass this parameter.
*
* The resource to be operated upon in the device is identified in a
* module's schema object. This modules object should contain the
* information about the resource on which the operation needs to be
* performed. The resource is identified by initial chain of objects for
* which operation type is none. Once the resource is reached using none
* operations, the actual information about the operation on the device
* is encoded.
*
* @param rootName name of logical root node as required by the
* protocol
* @param rootNamespace namespace of logical root node as required by
* the
* protocol encoding. It is optional, and there
* is no
* namespace set to the logical root node
* @param appModuleObject object containing the information about the
* resource on which the operation is being
* performed
* @param dataFormat data format to which request needs to
* be encoded
* @param protocolOperation protocol operation being performed
* @return the composite protocol operation request.
*/
YangCompositeEncoding encodeCompositeOperation(String rootName,
String rootNamespace,
Object appModuleObject,
YangProtocolEncodingFormat
dataFormat,
YmsOperationType
protocolOperation);
/**
* When the driver or provider receive the data from the SBI protocol, It
* will be in the protocol specific data representation. Drivers /
* provider need to interact with the device using native JAVA objects.
* Drivers use this decode method to translate the received
* protocol specific simple data to YANG modeled Java objects.
* If the response received is not in line with the schema, for example,
* there is some error info, etc, then the decode operation will throw an
* exception and decode operation will fail.
*
* @param protocolData input string containing the resource information
* in protocol format
* @param dataFormat data format from which decoding has to be done
* @param protocolOperation protocol operation being performed
* @return list of applications module/notification objects corresponding
* to the protocol data input
*/
List<Object> decode(String protocolData,
YangProtocolEncodingFormat dataFormat,
YmsOperationType protocolOperation);
/**
* When the driver or provider receive the composite data from the SBI
* protocol, It will be in the protocol specific data representation.
* Drivers / provider need to interact with the device
* using native JAVA objects. Drivers use this Decode method to translate
* the received protocol specific composite data to YANG modeled Java
* objects.
* If the response received is not in line with the schema, for example,
* there is some error info, etc, then the decode operation will throw an
* exception and decode operation will fail.
*
* @param protocolData composite protocol data containing the resource
* information
* @param dataFormat data format from which decoding has to be done
* @param protocolOperation protocol operation being performed
* @return application module/notification object corresponding to the
* protocol data infput
*/
Object decode(YangCompositeEncoding protocolData,
YangProtocolEncodingFormat dataFormat,
YmsOperationType protocolOperation);
/**
* Register the provider / driver specific overridden codec. This is can
* be used by provider to support any protocol specific extension or
* vendor specific implementation. This framework can also be used
* by providers / drivers to support any new protocol data format which
* is not supported by default in YANG codec utility.
*
* @param overriddenCodec provider / driver specific overridden instance
* of the codec
* @param dataFormat data format to which encoding to be done.
*/
void registerOverriddenCodec(YangDataTreeCodec overriddenCodec,
YangProtocolEncodingFormat dataFormat);
}
......
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ych;
/**
* Abstraction of an entity which has the composite protocol request.
*
* Protocols like RESTCONF, have split the schema specific information across
* different components in the protocol encoding.
*
* There is a resource identifier, which is part of the RESTCONF request URL.
* and there is the information about the resource being operated on in the
* request, this is part of the request body.
*/
public interface YangCompositeEncoding {
/**
* Retrieves the resource identifier on which the operation is being
* performed.
*
* @return the string representation of the resource being identified
*/
String getResourceIdentifier();
/**
* Retrieves the representation format of the resource identifier.
*
* @return the type of the resource identifier
*/
YangResourceIdentifierType getResourceIdentifierType();
/**
* Retrieves the resource information in the protocol encoding format.
*
* @return the resource information in the protocol encoding format
*/
String getResourceInformation();
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ych;
import org.onosproject.yms.ydt.YdtBuilder;
import org.onosproject.yms.ydt.YmsOperationType;
/**
* Abstraction of an entity which overrides the default codec.
*
* YANG has it extension framework which allows vendor / implementation
* specific operation or extensions. The default CODECs will fail to handle
* such protocol requests. In such scenarios, the providers can register
* their specific CODEC's with the YANG codec utility to translate the protocol
* specific data to abstract YANG data tree, from which it can be translate into
* the YANG modelled java objects for the provider / driver to operate on the
* device.
*/
public interface YangDataTreeCodec {
/**
* When the YMS need to encode simple protocol operation request,
* it will translate the YANG objects into an abstract YANG data tree and
* invoke this registered encode method. Protocol CODEC implementation
* needs to ensure the overridden method can handle any specific
* extension or representation of protocol data.
* The operation type will be set in YANG data tree builder.
*
* @param ydtBuilder Abstract YANG data tree contains the operation
* request
* @param protocolOperation protocol operation being performed
* @return protocol specific string representation.
*/
String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder,
YmsOperationType protocolOperation);
/**
* When the YMS need to encode composite protocol operation request, it
* will translate the YANG objects into an abstract YANG data
* tree and invoke this registered encode method. Protocol CODEC
* implementation needs to ensure the overridden method can handle any
* specific extension or representation of protocol data.
* The Initial chain of node in the YDT will have the operation type set
* to NONE to specify it is a resource identifier. The Resource
* information is maintained as a subtree to the resource identifier node.
*
* @param ydtBuilder Abstract YANG data tree contains the operation
* request
* @param protocolOperation protocol operation being performed
* @return composite response containing the requested operation
* information
*/
YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
YdtBuilder ydtBuilder, YmsOperationType protocolOperation);
/**
* When YMS decode simple protocol operation request it uses the
* registered decode method to translate the protocol data into a
* abstract YANG data tree. Then translate the abstract YANG data
* tree into the YANG modeled Java objects.
* The CODEC implementation are unaware of the schema against which they
* are performing the codec operation, so YMS will send the schema
* registry on which the YANG data tree needs to operate, so the code
* implementation needs to pass this schema registry to the get a YDT
* builder.
*
* @param protocolData input string containing the simple
* protocol data which needs to be decoded
* @param schemaRegistryForYdt Schema registry based on which the YANG
* data tree will be built
* @param protocolOperation protocol operation being performed
* @return decoded operation request in YANG data tree
*/
YdtBuilder decodeProtocolDataToYdt(String protocolData,
Object schemaRegistryForYdt,
YmsOperationType protocolOperation);
/**
* When YMS decode composite protocol operation request it uses the
* registered decode method to translate the protocol data into a
* abstract YANG data tree. Then translate the abstract YANG data
* tree into the YANG modeled Java objects.
* The CODEC implementation are unaware of the schema against which they
* are performing the codec operation, so YMS will send the schema
* registry on which the YANG data tree needs to operate, so the code
* implementation needs to pass this schema registry to the get a YDT
* builder.
*
* @param protocolData composite input string containing the
* protocol data which needs to be decoded
* @param schemaRegistryForYdt Schema registry based on which the YANG
* data tree will be built
* @param protocolOperation protocol operation being performed
* @return decoded operation request in YANG data tree
*/
YdtBuilder decodeCompositeProtocolDataToYdt(
YangCompositeEncoding protocolData, Object schemaRegistryForYdt,
YmsOperationType protocolOperation);
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ych;
/**
* Represents the protocol data representation.
*/
public enum YangProtocolEncodingFormat {
/**
* XML protocol encoding.
*/
XML_ENCODING,
/**
* JSON protocol encoding.
*/
JSON_ENCODING
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ych;
/**
* Represents the protocol data representation.
*/
public enum YangResourceIdentifierType {
/**
* Uniform Resource Identifier.
*/
URI
}
......@@ -16,8 +16,6 @@
package org.onosproject.yms.ydt;
import org.onosproject.yms.ymsm.YmsOperationType;
/**
* Abstraction of an entity which represent YANG data tree. This is used
* for exchanging information between YANG management system and NBI protocol.
......
......@@ -183,14 +183,26 @@ public interface YdtBuilder
void addLeaf(String name, String namespace, Set<String> valueSet);
/**
* Adds YANG list's keys value in the order defined in list's key statement.
* All the keys must be present any missing key or invalid key will result
* in exception.
* Adds an instance of a child list node, or adds a child leaf list with
* multiple instance.
* In case the name and namespace identifies the child list node, then
* the values for all the key leaves must be passed in the same order of
* schema. Then the effective YANG data tree will be like adding a list
* node, followed by adding the key leaves as the child to the list node.
* After this operation, the call to getCurNode will return the list node.
* In case the name and namespace identifies the child leaf-list, then
* the values identifies the instance of leaf list.
* After this operation, the call to getCurNode will return the leaf-list
* node.
*
* @param keysValueList values of the keys in URI in the same order
* @param name name of child to be added
* @param namespace namespace of child to be added, if it's null, parent's
* namespace will be applied to child
* @param valueList values of the keys in URI in the same order
* as defined in YANG file
*/
void addKeyLeafs(List<String> keysValueList);
void addMultiInstanceChild(String name, String namespace,
List<String> valueList);
/**
* Traverses up in YANG data tree to the parent node, it is to be used when
......
......@@ -22,5 +22,11 @@ package org.onosproject.yms.ydt;
* operation result etc.
*/
public interface YdtContextResponseInfo {
//TODO
/**
* Retrieve the context specific error information.
*
* @return context specific error information
*/
YdtErrorInfo getYdtErrorInfo();
}
......
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ydt;
/**
* Abstraction of an entity which contains context specific error info.
*/
public interface YdtErrorInfo {
/**
* Retrieves the application specific error tag corresponding to the
* error context in operation.
*
* @return application specific error tag corresponding to the error
* context in operation
*/
String getErrorAppTag();
/**
* Retrieves the error message corresponding to the error context in
* operation.
*
* @return the error message corresponding to the error context in operation
*/
String getErrorMessage();
}
......@@ -26,9 +26,22 @@ package org.onosproject.yms.ydt;
* YANG management system is responsible to split the protocol operation
* across application(s) which needs to participate, and collate the
* response(s) from application(s) and return an effective result of the
* operation request. The result of the operation request is returned in
* YMS operation result.
* operation request. The status of the operation execution is returned.
*/
public interface YmsOperationExecutionStatus {
// TODO
public enum YmsOperationExecutionStatus {
/**
* Successful execution of the operation.
*/
EXECUTION_SUCCESS,
/**
* Exception in execution of the operation.
*/
EXECUTION_EXCEPTION,
/**
* Error in execution of the operation.
*/
ERROR_EXCEPTION
}
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onosproject.yms.ymsm;
package org.onosproject.yms.ydt;
/**
* Represents type of root level operation for the request.
......@@ -59,23 +59,43 @@ public enum YmsOperationType {
* The YANG based request is to edit a config node / subtree in the data
* store.
*/
EDIT_CONFIG,
EDIT_CONFIG_REQUEST,
/**
* The YANG based request is to query a config node / subtree in the data
* store.
*/
QUERY_CONFIG,
QUERY_CONFIG_REQUEST,
/**
* The YANG based request is to query a node / subtree in the data store.
*/
QUERY,
QUERY_REQUEST,
/**
* The YANG based request is to execute an RPC defined in YANG.
*/
RPC,
RPC_REQUEST,
/**
* The YANG based response is for edit operation.
*/
EDIT_CONFIG_REPLY,
/**
* The YANG based response is for query config operation.
*/
QUERY_CONFIG_REPLY,
/**
* The YANG based response is for query operation.
*/
QUERY_REPLY,
/**
* The YANG based response is for a RPC operation.
*/
RPC_REPLY,
/**
* The YANG based request is to execute an RPC defined in YANG.
......
......@@ -19,10 +19,14 @@ package org.onosproject.yms.ymsm;
import java.util.List;
import org.onosproject.yms.ych.YangCodecHandler;
import org.onosproject.yms.ych.YangDataTreeCodec;
import org.onosproject.yms.ych.YangProtocolEncodingFormat;
import org.onosproject.yms.ydt.YdtBuilder;
import org.onosproject.yms.ydt.YdtResponse;
import org.onosproject.yms.ydt.YdtWalker;
import org.onosproject.yms.ydt.YmsOperationType;
import org.onosproject.yms.ynh.YangNotificationService;
import org.onosproject.yms.ysr.YangModuleLibrary;
/**
* Abstraction of an entity which provides interfaces to YANG management
......@@ -178,13 +182,6 @@ public interface YmsService {
* Depending on the operation type set in the YANG builder tree, the
* application(s) get / set / operation interface is invoked.
* These interface are part to the YANG modelled service interface.
*
* @param operationRequest operation request that was constructed
* by NBI protocol using YANG data tree
* builder. This operation request contains
* operation request that needs to be
* executed on the applicable application(s)
* @return returns the result of the operation execution.
* Depending on the operation type, the YANG response data tree can have
* the following information.
*
......@@ -213,10 +210,18 @@ public interface YmsService {
* will contain the application's RPC reply schema specific .
* NBI protocol to use a Yang data tree walker to construct the
* protocol specific reply.
*
* @param operationRequest operation request that was constructed
* by NBI protocol using YANG data tree
* builder. This operation request contains
* operation request that needs to be
* executed on the applicable application(s)
* @return returns the result of the operation execution.
*/
YdtResponse executeOperation(YdtBuilder operationRequest);
// TODO execute operation which directly take data format string as input.
/* TODO add execute operation which directly take data format string as
input.*/
/**
* Returns YANG notification service.
......@@ -287,6 +292,46 @@ public interface YmsService {
void unRegisterService(Object appManager, Class<?> yangService);
/**
* Protocols like RESTCONF, share the list of YANG modules it support.
* using ietf-yang-library
*
* Retrieves the YANG module library supported by the server.
*
* @return YANG module library supported by the server
*/
YangModuleLibrary getYangModuleLibrary();
/**
* Protocols like RESTCONF, use the definitions within the YANG modules
* advertised by the server are used to construct an RPC operation or
* data resource identifier.
*
* Schema Resource:
* The server can optionally support retrieval of the YANG modules it
* supports.
*
* @param moduleName YANG module name.
* @param moduleNamespace namespace in which the module is defined.
* @return YANG file contents of the requested YANG module.
*/
String getYangFile(String moduleName, String moduleNamespace);
/**
* Register protocol specific default CODEC. This is can be used by 1st
* protocol
* to support a protocol format CODEC. This CODEC will be used in both
* NBI and SBI.
*
* @param defaultCodec default codec to be used for a particular protocol
* data format
* @param dataFormat data format to which encoding to be done.
* Currently XML and
* JSON formats are supported.
*/
void registerDefaultCodec(YangDataTreeCodec defaultCodec,
YangProtocolEncodingFormat dataFormat);
/**
* Returns YANG codec handler utility.
*
* In SBI, the provider or driver uses YANG management system as a CODEC
......@@ -294,11 +339,14 @@ public interface YmsService {
* the device schema. YANG utils is used to generate the java files
* corresponding to the device schema. Provider or driver use these classes
* to seamlessly manage the device as java objects. While sending the
* request to device, drivers use the utility to translate the objects to
* protocol specific data representation and then send to the device.
* request
* to device, drivers use the utility to translate the objects to protocol
* specific data representation and then send to the device.
* Protocol or driver use the same instance of the codec utility across
* multiple translation request. Protocol or driver should not use the same
* instance of utility concurrently.
* multiple
* translation request.
* Protocol or driver should not use the same instance of utility
* concurrently.
*
* @return YANG codec utility
*/
......
/*
* Copyright 2015-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ynh;
import org.onosproject.yms.ydt.YdtContext;
/**
* Represents YANG notification which is a subject of YANG based event.
*
* YMS add themselves as a listener to applications. Application sends
* their notification in YANG utils generated notification. YMS obtains
* the module/sub-module schema tree in which this notification is contained
* and then convert this data to an abstract tree notation (YDT) with root
* node as the logical node with name "yangnotification" it contains
* module/sub-module node in which notification is contained.
* It sends the same to all the protocol who has added them as a listener
* as a YANG notification.
*
* This class represents YANG notification which contains the
* notification context in abstract tree notation.
*/
public class YangNotification {
/**
* YANG notification in form of abstract tree notation (YDT)
* Root node of notification root context will be logical node with
* name as "yangnotification", it contains module/sub-module node
* in which notification is contained.
*/
YdtContext notificationRootContext;
/**
* Creates an instance of YANG notification subject.
*
* @param notificationContext logical root node with name as
* "yangnotification"
*/
public YangNotification(YdtContext notificationContext) {
this.notificationRootContext = notificationContext;
}
/**
* Assign the YANG modeled notification data.
*
* @param notificationRootContext YANG data tree containing the data for
* the notification
*/
public void setNotificationRootContext(YdtContext notificationRootContext) {
this.notificationRootContext = notificationRootContext;
}
/**
* Returns YANG notification data.
*
* @return YANG data tree containing the data for the notification
*/
public YdtContext getNotificationRootContext() {
return notificationRootContext;
}
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ynh;
import org.onosproject.event.AbstractEvent;
/**
* Represents YANG notification event.
*
* YANG notification handler listens for the notification from the application.
* It convert the received notification in YANG notification events.
*
* YangNotificationEvent represents event generated by YANG management system
* in response to the YANG defined application notification. The applications
* notification information is in abstract YANG data tree.
*/
public class YangNotificationEvent
extends AbstractEvent<YangNotificationEvent.Type, YangNotification> {
/**
* Event type is the notification as defined in the YANG file.
*/
public enum Type {
/**
* Indicates a YANG notification.
*/
YANG_NOTIFICATION
}
/**
* YANG notification information shared to NBI protocol in YANG data tree
* using the registered callback.
*
* @param subject notification information in YANG data tree.
*/
public YangNotificationEvent(YangNotification subject) {
super(Type.YANG_NOTIFICATION, subject);
}
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ynh;
import org.onosproject.event.EventListener;
/**
* Abstraction of listener for YANG notification handler events.
* NBI protocols/interfaces supporting YANG notification needs to implement
* YANG notification listener and add themselves as a listener to YANG
* notification event.
*/
public interface YangNotificationListener
extends EventListener<YangNotificationEvent> {
}
......@@ -16,17 +16,86 @@
package org.onosproject.yms.ynh;
import org.onosproject.event.ListenerService;
/**
* Abstraction of an entity which provides interfaces to YANG notification
* service. YNH handles notification from the application/core and provide
* it to the protocols.
* <p>
* service. YANG notification handler receives the event notifications from
* application/core and provide it to the protocols.
*
* NBI Protocols which can support notification delivery for application(s)
* needs to add themselves as a listeners with YANG notification service.
* Protocols can use YANG notification service to check if a received
* Also based on registered schema YMS add themselves as a listener to
* applications. Application sends their notification in YANG utils generated
* notification. YMS obtains the module/sub-module schema tree in which this
* notification is contained and then convert this data to an abstract tree
* notation (YDT) with root node as the module/sub-module node in which
* notification is contained. It sends the same to all the protocol who has
* added them as a listener as a YANG notification.
*
* Also Protocols can use YANG notification service to check if a received
* notification should be filtered against any of their protocol specific
* filtering mechanism.
*/
public interface YangNotificationService {
//TODO
public interface YangNotificationService
extends ListenerService<YangNotificationEvent,
YangNotificationListener> {
/*
* Example of a use case of notification filtering.
* The following example illustrates how to select fault events which
* have severities of critical, major, or minor. The filtering criteria
* evaluation is as follows:
*
* ((fault & severity=critical) | (fault & severity=major) | (fault &
* severity=minor))
*
* <netconf:rpc netconf:message-id="101"
* xmlns:netconf="urn:ietf:params:xml:ns:netconf:base:1.0">
* <create-subscription
* xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
* <filter netconf:type="subtree">
* <event xmlns="http://example.com/event/1.0">
* <eventClass>fault</eventClass>
* <severity>critical</severity>
* </event>
* <event xmlns="http://example.com/event/1.0">
* <eventClass>fault</eventClass>
* <severity>major</severity>
* </event>
* <event xmlns="http://example.com/event/1.0">
* <eventClass>fault</eventClass>
* <severity>minor</severity>
* </event>
* </filter>
* </create-subscription>
* </netconf:rpc>
*/
/**
* Protocols have their own mechanism to support notification filtering
* or notification subscription. Depending on the protocol specification,
* the filtering is implemented in the protocol.
* The Protocol implementations are abstracted of the Schema, there are
* scenarios in which they need to check if the received notification
* is of interest as per the schema filtering / subscription.
* In such scenario, protocols can create a filtering / subscription YANG
* data tree and use the notification service to filter the notification
* subject against their filter.
*
* Filters the notification subject YANG data tree, with the specified
* filter of the NBI protocol. If the filter does not match for the
* passed notification subject, null will be returned.
* Otherwise, the part of the subject matching the filter will be returned.
*
* @param notificationSubject YANG notification subject reported by YANG
* notification service.
* @param notificationFilter Protocols data model specific notification
* filter represented in YANG data tree.
* @return filtered notification which passes the data model specific
* notification filter.
*/
YangNotification getFilteredSubject(YangNotification notificationSubject,
YangNotification notificationFilter);
}
......
......@@ -17,14 +17,11 @@
/**
* Provides interfaces to YANG notification handler. YNH handles notification
* from the application and provide it to the protocols.
*/
/**
* Provides interfaces to YANG notification service.
*
* NBI Protocols which can support notification delivery for application(s)
* needs to add themselves as a listeners with YANG notification service.
* Protocols can use YANG notification service to check if a received
* need to add themselves as a listeners with YANG notification service.
*
* Also protocols can use YANG notification service to check if a received
* notification should be filtered against any of their protocol specific
* filtering mechanism.
*/
......
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ysr;
/**
* Abstraction of an entity which provides YANG module identifiers.
* Reference RFC 7895
* YANG library provides information about all the YANG modules
* used by a network management server
*/
public interface YangModuleIdentifier {
/**
* retrieves the name of the YANG module.
*
* @return the name of the YANG module
*/
String getModuleName();
/**
* Retrieves revision of the YANG module.
*
* Reference RFC 7895
* Each YANG module and submodule within the library has a
* revision. This is derived from the most recent revision statement
* within the module or submodule. If no such revision statement
* exists, the module's or submodule's revision is the zero-length
* string.
*
* @return revision of the YANG module
*/
String getRevision();
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ysr;
import java.util.List;
/**
* Abstraction of an entity which provides YANG module information.
*
* Reference RFC 7895
* The following information is needed by a client application (for each
* YANG module in the library) to fully utilize the YANG data modeling
* language:
*
* o name: The name of the YANG module.
*
* o revision: Each YANG module and submodule within the library has a
* revision. This is derived from the most recent revision statement
* within the module or submodule. If no such revision statement
* exists, the module's or submodule's revision is the zero-length
* string.
*
* o submodule list: The name and revision of each submodule used by
* the module MUST be identified.
*
* o feature list: The name of each YANG feature supported by the
* server MUST be identified.
*
* o deviation list: The name of each YANG module used for deviation
* statements MUST be identified.
*/
public interface YangModuleInformation {
/**
* Retrieves the YANG modules identifier.
*
* @return YANG modules identifier
*/
YangModuleIdentifier getModuleIdentifier();
/**
* Retrieves the YANG modules namespace.
* The XML namespace identifier for this module.
*
* @return YANG modules namespace
*/
String getNamespace();
/**
* Reference RFC 7895
* Retrieves the list of YANG feature names from this module that are
* supported by the server, regardless of whether they are
* defined in the module or any included submodule.
*
* @return list of YANG features
*/
List<String> getFeatureList();
/**
* Retrieves the list of submodules in the module.
* The name and revision of each submodule used by
* the module MUST be identified.
*
* Each entry represents one submodule within the
* parent module.
*
* @return list of submodules in the module
*/
List<YangModuleIdentifier> getSubModuleIdentifier();
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yms.ysr;
/*-
* Abstraction of an entity which provides the servers YANG library information.
*
* Reference RFC 7895
* The "ietf-yang-library" module provides information about the YANG
* library used by a server. This module is defined using YANG version
* 1, but it supports the description of YANG modules written in any
* revision of YANG.
*
* Following is the YANG Tree Diagram for the "ietf-yang-library"
* module:
*
* +--ro modules-state
* +--ro module-set-id string
* +--ro module* [name revision]
* +--ro name yang:yang-identifier
* +--ro revision union
* +--ro schema? inet:uri
* +--ro namespace inet:uri
* +--ro feature* yang:yang-identifier
* +--ro deviation* [name revision]
* | +--ro name yang:yang-identifier
* | +--ro revision union
* +--ro conformance-type enumeration
* +--ro submodule* [name revision]
* +--ro name yang:yang-identifier
* +--ro revision union
* +--ro schema? inet:uri
*/
import java.util.List;
public interface YangModuleLibrary {
/**
* Retrieves the current module set id of the YANG library.
*
* Reference RFC7895.
* modules-state/module-set-id
*
* This mandatory leaf contains a unique implementation-specific
* identifier representing the current set of modules and submodules on
* a specific server. The value of this leaf MUST change whenever the
* set of modules and submodules in the YANG library changes. There is
* no requirement that the same set always results in the same "module-
* set-id" value.
*
* @return module set id of the YANG library
*/
String getModuleSetId();
/**
* Retrieves the current list of YANG modules supported in the server.
*
* Reference RFC 7895.
* modules-state/module
*
* This mandatory list contains one entry for each YANG data model
* module supported by the server. There MUST be an entry in this list
* for each revision of each YANG module that is used by the server. It
* is possible for multiple revisions of the same module to be imported,
* in addition to an entry for the revision that is implemented by the
* server.
*
* @return the current list of YANG modules supported in the server
*/
List<YangModuleInformation> getYangModuleList();
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* YANG schema registry (YSR) is responsible to maintain all the applications
* schemas defined in YANG. The YANG data tree builder depends on the schema
* registry to validate the tree building according to schema.
* YANG codec handler using the schema registry to maintain device schema.
*/
package org.onosproject.yms.ysr;