06-11-2020 09:38 AM - edited 06-11-2020 09:39 AM
Hello,
I can get the value of description on device interface using python maapi as below:
import ncs.maapi as maapi
with ncs.maapi.single_read_trans('admin', 'system', db=ncs.OPERATIONAL) as m:
root = ncs.maagic.get_root(m)
print(root.devices.device['mydevice'].config.ios__interface.GigabitEthernet['1'].description)
my_interface_desc
Instead of getting a single value, can I get the output of all configuration below the interface (e.g. description, ip address, negotiation, ...) using python maapi, something like:
root.ncs__devices.device['mydevice'].config.ios__interface.GigabitEthernet['1'].?
06-25-2020 01:15 PM
I do not believe you can get what you want in Python. What I can think about is the encodeXML() method in Java. This will return you the full sub-tree structure from your object that you can print in XML format (or decode at your wish). Please remember that a "config" in CDB is a tree and not a "string".
public List<ConfXMLParam> encodeXML() throws NavuException
NavuNode
NavuNode
as the topmost NavuNode
to a ConfXMLParam
array.
The returning ConfXMLParam
array contains no values except for list keys. The leaf elements are encoded as ConfXMLParamLeaf
therefore the returning array could be used as a input parameter to NavuNode.getValues(ConfXMLParam[])
on the current elements parent.
NavuNode node = ...; //cxa contains structure that does not contains values except for //keys in list elements ConfXMLParam[] cxa = node.encodeXML().toArray(new ConfXMLParam[0]); NavuNode parent = node.getParent(); //contains sub-tree with all the values ConfXMLParam[] cxb = parent.getValues(cxa);
encodeXML
in class NavuNode
ConfXMLParam
of the sub-tree (including key values) with key values.NavuException
- If the operation could not be performed for some reasonsConfXMLParam
, ConfXMLParamValue
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