05-01-2019 10:59 PM
Hi,
I am trying to read a csv file from an OS directory and parse its output to nso config. I wanted to implement on the same lines as that of nso in-built command:
admin@ncs(config)# load merge
Possible completions:
<filename> README.ncs devices.xml logs/ ncs-cdb/ ncs.conf netsim/ packages/ scripts/ state/ storedstate target/
When one presses tab in this command, content of ncs-run directory gets listed. I would like to have similar behavior for my service such that when I do: my_service service_name <tab> everything in home directory should get listed.
Thanks,
Shashank Srivastava
05-01-2019 11:48 PM
05-02-2019 03:06 PM
When one presses tab in this command, content of ncs-run directory gets listed. I would like to have similar behavior for my service such that when I do: my_service service_name <tab> everything in home directory should get listed.
What you need is a completion callback. You can use the extension tailf:cli-completion-actionpoint in your model, and implement a callback to provide the completions. A small snippet is provided in the javadoc for com.tailf.dp.Completion in the NSO documentation. I provide it here for reference:
Having a YANG model snippet like the following:
container application { leaf file-name { type string; tailf:cli-completion-actionpoint "file-complete" { tailf:cli-completion-id "path"; } } }
The corresponding completion action is as follows:
@ActionCallback(callPoint = "file-complete", callType = ActionCBType.COMPLETION) public Completion completion(DpActionTrans actx, char cliStyle, String token, char completionChar, ConfObject[] kp, String cmdPath, String cmdParamId, ConfQname simpleType, String extra) throws DpCallbackException { .... // User processing of the completion .... CompletionReply reply = Completion.newReply(); reply.addCompletion("completion-entry1", null); ... reply.addCompletion("completion-entryN", null); reply.setCompletionInfo("my-info"); reply.setCompletionDesc("my-description"); return reply; }
/Ram
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide