cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2564
Views
5
Helpful
4
Replies

NSO Java/YANG tailf:cli-completion-actionpoint example code not working

mohamkh7
Cisco Employee
Cisco Employee

Hi All,

 

I have written a sample java action-demo to explore how  tailf:cli-completion-actionpoint ( Tail-f YANG CLI extensions) works.

However when i invoke the completion-actionpoint (from CLI) I always get below errors in log files

ncs.log

no registration found for callpoint if-complete-action/completion of type=external

 devel.log

<ERR> 1-Dec-2018::21:03:28.952 zahid-VirtualBox ncs[29209]: devel-c no registration found for callpoint if-complete-action/completion of type=external
<ERR> 1-Dec-2018::21:03:28.952 zahid-VirtualBox ncs[29209]: ncs Return error {cs_error,undefined,misc,external,undefined,undefined,
<<"no registration found for callpoint if-complete-action/completion of type=external">>,
undefined,undefined,false}

 

Here is the yang definition

 module action-demo {
..namespace "http://com/example/actiondemo";
..prefix action-demo;

..import ietf-inet-types { prefix inet; }
..import tailf-common { prefix tailf; }
..import tailf-ncs { prefix ncs; }

..description "A small demo module to illustrate how to implement user defined actions";

..container action-demo {
....tailf:action myvpn-action {
......tailf:actionpoint actionpoint-myvpn;
......input {
........container endpoint {
..........tailf:cli-compact-syntax;
..........leaf device {
............type leafref {
..............path "/ncs:devices/ncs:device/ncs:name";
............}
............tailf:info "Endpoint Device";
............mandatory true;
..........}

..........leaf interface {
............tailf:info "Endpoint Port";
............type string;
............tailf:cli-completion-actionpoint if-complete-action;
............mandatory true;
..........}
........}
......}
....}
..}
}

 

 

Here is the Java code snippet

 public class ActionDemo {
private static Logger LOGGER = Logger.getLogger(ActionDemo.class);

// some code here
// ...

@ActionCallback(callPoint = "if-complete-action", callType = ActionCBType.COMPLETION)
Completion completion(DpActionTrans actx, char cliStyle, String token, char completionChar, ConfObject[] kp, String cmdPath, String cmdParamId,
ConfQname simpleType, String extra) throws DpCallbackException {
try {
LOGGER.info(String.format("completion() callback, actionpoint : %s", actx.getActionPoint()));

CompletionReply reply = Completion.newReply();
reply.addCompletion("fe-0/0", null);
reply.addCompletion("fe-0/1", null);
reply.addCompletion("ge-0/0", null);
reply.addCompletion("ge-0/1", null);
reply.setCompletionInfo("interfaces");
reply.setCompletionDesc("all device interfaces");
return reply;

} catch (Exception e) {
throw new DpCallbackException("completion failed", e);
}
}
}

 

package-meta-data.xml

 

<ncs-package xmlns="http://tail-f.com/ns/ncs-packages">
<name>action-demo</name>
<package-version>1.0</package-version>
<description>Java-based action-demo</description>
<ncs-min-version>2.0</ncs-min-version>

<!-- It's possible to add more components to the -->
<!-- same package, multiple services, data providers etc -->

<component>
<name>action-demo</name>
<callback>
<java-class-name>com.example.actiondemo.ActionDemo</java-class-name>
</callback>
</component>
</ncs-package>

 

 

Any help will be greatly appreciated.

 

Thanks

Zahid

 

1 Accepted Solution

Accepted Solutions

Seems as I misread your question.

Anyhow, to be honest I don't know.

 

One difference I see between what you have in the code snippet and the documentation is that your completion method is private (I believe), while in the docs it's public.

View solution in original post

4 Replies 4

yfherzog
Cisco Employee
Cisco Employee

Hi,

 

Check if your action package was loaded to NSO successfully: 'show packages package oper-status'

See that the package appears as 'UP'.

 

Also, from a quick look at the code, I think it might be that your Java code should have had ' callPoint="actionpoint-myvpn" ' rather than what you have at the moment.

Hi ,

Thanks for the reply,

oper-status of package is UP, here is the status with log

 

package oper-status
PACKAGE
PROGRAM META FILE
CODE JAVA BAD NCS PACKAGE PACKAGE CIRCULAR DATA LOAD ERROR
NAME UP ERROR UNINITIALIZED VERSION NAME VERSION DEPENDENCY ERROR ERROR INFO
------------------------------------------------------------------------------------------------------------
action-demo X - - - - - - - - -


ncs.log (debug logs)

<INFO> 02-Dec-2018::12:50:03.804 NcsDpMux JVM-Launcher: - NcsDpMUX 29-action-demo:action-demo--> OK
<DEBUG> 02-Dec-2018::12:50:03.805 DpPDEntry JVM-Launcher: - REGISTERING -->
<INFO> 02-Dec-2018::12:50:03.805 NcsDpMux JVM-Launcher: - register -->
<INFO> 02-Dec-2018::12:50:03.806 NcsDpMux JVM-Launcher: - register --> OK
<DEBUG> 02-Dec-2018::12:50:03.806 DpPDEntry JVM-Launcher: - REGISTERING --> OK
<INFO> 02-Dec-2018::12:50:03.809 DpMuxManager JVM-Launcher: - INSTANTIATE CALLBACK-COMPONENT ["action-demo:action-demo"] --> INSTANTIATED
<INFO> 02-Dec-2018::12:50:03.810 FSM JVM-Launcher: - [action-demo:action-demo] CLASSLOADED TO --> RUNNING
<TRACE> 02-Dec-2018::12:50:03.810 FSM JVM-Launcher: - event(INSTANTIATE_COMPONENT,action-demo:action-demo : [com.example.actiondemo.ActionDemo] [i] [State: RUNNING] [file:///home/zahid/ncs-run/state/packages-in-use/1/action-demo/private-jar/action-demo.jar]) => true
<INFO> 02-Dec-2018::12:50:03.810 DpMuxManager JVM-Launcher: - INSTANTIATE CALLBACK PD ["action-demo:action-demo"] --> INSTANTIATED
<INFO> 02-Dec-2018::12:50:03.810 NcsMain JVM-Launcher: - INSTANTIATE COMPONENT ["action-demo:action-demo"] --> DONE
<INFO> 02-Dec-2018::12:50:03.810 FSM JVM-Launcher: - [MAIN] LOADING_PACKAGES TO --> DEPLOYING
<TRACE> 02-Dec-2018::12:50:03.811 FSM JVM-Launcher: - event(INSTANTIATE_COMPONENT,{#Bin<<action-demo>>,#Bin<<action-demo>>}) => true
<INFO> 02-Dec-2018::12:50:03.811 NcsMain JVM-Launcher: - DONE COMMAND --> INSTANTIATE_COMPONENT

 

 

' callPoint="actionpoint-myvpn" '  is there in palce, i have not shown that in code snippet, as that is not relevant for this question.

tailf:cli-completion-actionpoint  Specifies that completion for the leaf values is done through a callback function.The argument is the name of an actionpoint, which must be implemented by custom code. In the
actionpoint, the completion() callback function will be invoked. See confd_lib_dp(3) for details

Seems as I misread your question.

Anyhow, to be honest I don't know.

 

One difference I see between what you have in the code snippet and the documentation is that your completion method is private (I believe), while in the docs it's public.

Good catch, I made the method completion method public.

It works.

Thanks