About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Technical Blog Post
Abstract
Netcool Configuration Manager - Juniper Device Script (CLI vs XML RPC)
Body
If you are familiar with NCM-managed Juniper devices, you should have noticed that there is an important command in the device script - isJunoOS - which takes a boolean value of either "true" or "false".
Eg.
diag.01.isJunoOs=false
OR
config.running.01.isJunoOs=true
The "isJunoOS" command orders NCM to either send the subsequent commands through Juniper CLI or XML RPC call.
When "isJunoOS" is set to true, NCM will enter "JunoOS" mode by establishing a XML RPC call to the device through the "enterJunoOS" code section:
#enter JunoOS
enterJunoOs.01.send=junoscript\r
enterJunoOs.02.wait=-->
enterJunoOs.03.send=<?xml version="1.0" encoding="us-ascii"?>\r
enterJunoOs.04.send=<junoscript version="1.0" junos:key="key">\r
enterJunoOs.05.wait=-->
When "isJunoOS" is set to false, NCM will terminate the XML RPC call session through the "exitJunoOS" code section and return to "CLI" mode:
#exit junoOs
exitJunoOS.01.send=<rpc><request-end-session/></rpc>\r
exitJunoOS.errorResponse=Error disconnecting from device.
While "CLI" mode is easier to manage, you can always opt for a fully XML RPC based device script by amending the codes.
Eg.
[FROM]
# Version
config.version.end=>
config.version.FIND-BEGIN.01=Kernel Software Suite [
config.version.FIND-END.01=]
config.version.FIND-BEGIN.02=Software Release [
config.version.FIND-END.02=]
config.version.FIND-BEGIN.03=Junos:
config.version.FIND-END.03=\r
config.version.01.isJunoOs=false
config.version.02.sendSaveReuse=show version\r
[TO]
# Version
config.version.end=</rpc-reply>
config.version.01.isJunoOs=true
config.version.02.clearReturnBuff=true
config.version.03.send=<rpc><get-software-information/></rpc>\r
config.version.FIND-BEGIN.01=<junos-version>
config.version.FIND-END.01=</junos-version>
More mappings of the CLI commands to XML RPC tag can be found here =>
If you increase the log level to DEBUG (loggerAdmin.sh -a -l DEBUG), you can see the following changes in the "worker.log" =>
[FROM]
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.01.isJunoOs
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:isJunoOs: false
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.exitJunoOs :: MSG:not in junos
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.02.sendSaveReuse
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Sending: show version^M
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.send :: MSG:Sending: show version^M
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-BEGIN.01
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-BEGIN.02
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-BEGIN.03
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-END.01
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-END.02
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-END.03
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.end
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:receiving until token:> Timeout:600000
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:setting deadline: 1539226334303^M maxDeadline: 1539226034303 timeout: 600000 maxResponseTimeout: 300000
2018.10.11 02:42:14 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:entering read loop, starting buffer length: 0
2018.10.11 02:42:15 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 845, receiveBufCount: 845, startIndex: 0, ifStartIndex: 0
...
2018.10.11 02:42:16 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.cutDataFromStringData :: MSG: Looking for Begin String: Junos:
2018.10.11 02:42:16 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.cutDataFromStringData :: MSG: found Begin String: Junos:
Found at 60
found End String:
Found at 69
2018.10.11 02:42:16 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.cutDataFromStringData :: MSG: Found Version String: 18.1R1.9^M
2018.10.11 02:42:16 GMT+00:00 OperationRunner-001-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.getConfig :: MSG: case os_version getVersionFileServer false: tmpConfigurationshow version ^M
Hostname: vsrx18-1^M
Model: vsrx^M
Junos: 18.1R1.9^M
JUNOS OS Kernel 64-bit [20180308.0604c57_builder_stable_11]^M
JUNOS OS libs [20180308.0604c57_builder_stable_11]^M
[TO]
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: enterJunoOs.01.send
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Sending: junoscript^M
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.send :: MSG:Sending: junoscript^M
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: enterJunoOs.02.wait
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Waiting for: -->
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:receiving until token:--> Timeout:600000
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:setting deadline: 1539227144851^M maxDeadline: 1539226844851 timeout: 600000 maxResponseTimeout: 300000
2018.10.11 02:55:44 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:entering read loop, starting buffer length: 0
2018.10.11 02:55:45 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 13, receiveBufCount: 13, startIndex: 0, ifStartIndex: 0
2018.10.11 02:55:45 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:checking for token: '-->' at index: 0, received count: 13
2018.10.11 02:55:46 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:entering read loop, starting buffer length: 13
2018.10.11 02:55:46 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 371, receiveBufCount: 358, startIndex: 13, ifStartIndex: 13
2018.10.11 02:55:46 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:checking for token: '-->' at index: 11, received count: 358
2018.10.11 02:55:46 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:found token: '-->' at index: 366
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.checkSocket :: MSG:Received: junoscript ^M
<?xml version="1.0" encoding="us-ascii"?>^M
<junoscript xmlns="http://xml.juniper.net/xnm/1.1/xnm" xmlns:junos="http://xml.juniper.net/junos/18.1R1/junos" schemaLocation="http://xml.juniper.net/junos/18.1R1/junos junos/18.1R1/junos.xsd" os="JUNOS" release="18.1R1.9" hostname="vsrx18-1" version="1.0">^M
<!-- session start at 2018-10-11 02:55:42 UTC -->^M
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: enterJunoOs.03.send
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Sending: <?xml version="1.0" encoding="us-ascii"?>^M
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.send :: MSG:Sending: <?xml version="1.0" encoding="us-ascii"?>^M
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: enterJunoOs.04.send
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Sending: <junoscript version="1.0" junos:key="key">^M
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.send :: MSG:Sending: <junoscript version="1.0" junos:key="key">^M
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: enterJunoOs.05.wait
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Waiting for: -->
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:receiving until token:--> Timeout:600000
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:setting deadline: 1539227147365^M maxDeadline: 1539226847365 timeout: 600000 maxResponseTimeout: 300000
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:entering read loop, starting buffer length: 0
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 122, receiveBufCount: 122, startIndex: 0, ifStartIndex: 0
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:checking for token: '-->' at index: 0, received count: 122
2018.10.11 02:55:47 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:found token: '-->' at index: 71
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.checkSocket :: MSG:Received: <!-- No zombies were killed during the creation of this user interface -->^M
<!-- user danielyeap, class j-super-user -->^M
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.enterJunoOs :: MSG:enter junos
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.02.clearReturnBuff
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:clearReturnBuff: true
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.03.send
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:Sending: <rpc><get-software-information/></rpc>^M
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.send :: MSG:Sending: <rpc><get-software-information/></rpc>^M
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-BEGIN.01
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.FIND-END.01
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.processCommands :: MSG:cmd: config.version.end
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:receiving until token:</rpc-reply> Timeout:600000
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:setting deadline: 1539227148412^M maxDeadline: 1539226848412 timeout: 600000 maxResponseTimeout: 300000
2018.10.11 02:55:48 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:entering read loop, starting buffer length: 0
2018.10.11 02:55:49 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 2072, receiveBufCount: 2072, startIndex: 0, ifStartIndex: 0
2018.10.11 02:55:49 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 4943, receiveBufCount: 2871, startIndex: 2072, ifStartIndex: 2072
2018.10.11 02:55:49 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:checking for token: '</rpc-reply>' at index: 2061, received count: 2871
2018.10.11 02:55:49 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:entering read loop, starting buffer length: 4943
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:exiting read loop, ending buffer length: 5441, receiveBufCount: 498, startIndex: 4943, ifStartIndex: 4943
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:checking for token: '</rpc-reply>' at index: 4932, received count: 498
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.receiveUntil :: MSG:found token: '</rpc-reply>' at index: 5427
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.socket.ComWrapper.checkSocket :: MSG:Received: <rpc-reply xmlns:junos="http://xml.juniper.net/junos/18.1R1/junos">^M
<software-information>^M
<host-name>vsrx18-1</host-name>^M
<product-model>vsrx</product-model>^M
<product-name>vsrx</product-name>^M
<junos-version>18.1R1.9</junos-version>^M
<package-information>^M
<name>os-kernel</name>^M
...
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.cutDataFromStringData :: MSG: Looking for Begin String: <junos-version>
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.cutDataFromStringData :: MSG: found Begin String: <junos-version>
Found at 218
found End String: </junos-version>
Found at 226
2018.10.11 02:55:50 GMT+00:00 OperationRunner-003-Worker1 FINEST WORKER Worker1 com.intelliden.icos.util.handlers.ComHandler.cutDataFromStringData :: MSG: Found Version String: 18.1R1.9
**************
Hope that helps to enhance your knowledge of NCM device scripts.
[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"","label":""},"Component":"","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}}]
UID
ibm11081695