Mandatory attributes in RPC input are not honoured
Description
Environment
Operating System: All
Platform: All
Attachments
is blocked by
Activity

Robert Varga January 1, 2019 at 4:14 PM
We will need to extract MandatoryLeafEnforcer – and probably some other portions of org.opendaylight.yangtools.yang.data.impl.schema.tree into yang-data-util where it would be usable by codecs.

vikram darsi March 28, 2017 at 2:32 PM
Attachment RPCInvocation.png has been added with description: RPCInvocation Image that is showing success when mandatory attrs are not passed

vikram darsi March 28, 2017 at 2:32 PM
screenshot is attached which shows RPC invocation success when mandatory attributes are not passed

vikram darsi March 28, 2017 at 2:30 PM
Please find the steps followed:
1. Created sample project using the below command
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.release/ -DarchetypeCatalog=http://nexus.opendaylight.org/content/repositories/opendaylight.release/archetype-catalog.xml -DarchetypeVersion=1.2.0-Boron
2. api/src/main/yang/normalizednodedemo.yang
module normalizednodedemo {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:normalizednodedemo";
prefix "normalizednodedemo";
revision "2015-01-05" {
description "Initial revision of normalizednodedemo model";
}
rpc say-hello {
input{
leaf name{
type string;
mandatory true;
}
}
}
}
3. impl/src/main/resources/impl-blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
Copyright © 2016 AdvaOptical.com and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
<reference id="dataBroker"
interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
odl:type="default" />
<bean id="provider"
class="com.adva.ensemble.controller.impl.NormalizedNodeDemoProvider"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
</bean>
<bean id="rpcDemo"
class="com.adva.ensemble.controller.impl.NNRpcDemo">
</bean>
<odl:rpc-implementation ref="rpcDemo" />
</blueprint>
4. impl/src/main/java
com.adva.ensemble.controller.impl.NNRpcDemo
package com.adva.ensemble.controller.impl;
import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.normalizednodedemo.rev150105.NormalizednodedemoService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.normalizednodedemo.rev150105.SayHelloInput;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
public class NNRpcDemo implements NormalizednodedemoService{
@Override
public Future<RpcResult<Void>> sayHello(SayHelloInput input) {
return RpcResultBuilder.<Void>success().buildFuture();
}
}
5. mvn clean install -Pq
6. karaf/target/assembly> bin/karaf debug
7. Launch APIDocs page: http://localhost:8181/apidoc/explorer/index.html
Invoke RPC : http://localhost:8181/restconf/operations/normalizednodedemo:say-hello
JSON : {
"input":{
}
}
RESPONSE : 200
RESPONSE CODE : No Content
NOTE: Mandatory attributes are not passed in the input.
Thanks
Vikram

Igor Foltín March 28, 2017 at 1:29 PMEdited
Could you please provide the exact steps you took to reproduce this behaviour?
Thanks
We are using ODL Boron.
Mandatory attributes inside RPC input are not honoured , therefore RPC’s can be invoked without passing mandatory attributes.
Whereas with RESTCONF url’s the mandatory attributes validation is happening
RESTCONF ERROR:
There is no Error to the North Bound(In the APIDOCS page), but in the server side, below logs are printed, CDS is not updated with the values as the validation is failed.
RPC ERROR:
Since there is no validation, it is returning the SUCCESSFUL RPC result to the North Bound