Automation

 View Only
last person joined: 9 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Question on RPC format

     
    Posted 01-11-2023 01:10

    Hi.

     

    I do know that the PyEZ RPC message for getting Junos system information in XML format would look like this:

    <rpc>

       <get-system-information/>

    </rpc>

     

    But what is the RPC message format for getting Junos system information in text format?

     

     

    Thanks,

    Deepak


    Juniper Business Use Only



  • 2.  RE: Question on RPC format

    Posted 01-11-2023 03:44
    Hi Deepak,

    Maybe you need:

    data = dev.rpc.get_config(options={'format':'text'})
    print (etree.tostring(data, encoding='unicode', pretty_print=True))

    Thanks,
    Adrian.

    ------------------------------
    Teodor Adrian Soroceanu
    ------------------------------



  • 3.  RE: Question on RPC format

     
    Posted 01-11-2023 09:18

    Hi Adrian.

     

    Thanks for the response. I understand how to create the required RPC. But what does the RPC actually look like? How is the request for the response in text encoded in the rpc request? (This is more of an academic question, I guess).

     

    Thanks,

    Deepak


    Juniper Business Use Only






  • 4.  RE: Question on RPC format

     
    Posted 01-14-2023 08:13
    Edited by asharp 01-14-2023 08:22
    Hope that this helps.

    ssh vmx103 -s netconf
    <!-- No zombies were killed during the creation of this user interface -->
    <!-- user root, class super-user -->
    <nc:hello xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <nc:capabilities>
        <nc:capability>urn:ietf:params:netconf:base:1.0</nc:capability>
        <nc:capability>urn:ietf:params:netconf:capability:candidate:1.0</nc:capability>
        <nc:capability>urn:ietf:params:netconf:capability:confirmed-commit:1.0</nc:capability>
        <nc:capability>urn:ietf:params:netconf:capability:validate:1.0</nc:capability>
        <nc:capability>urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:netconf:base:1.0?module=ietf-netconf&amp;revision=2011-06-01</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:netconf:capability:candidate:1.0</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:netconf:capability:url:1.0?scheme=http,ftp,file</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2013-07-15</nc:capability>
        <nc:capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</nc:capability>
        <nc:capability>http://xml.juniper.net/netconf/junos/1.0</nc:capability>
        <nc:capability>http://xml.juniper.net/dmi/system/1.0</nc:capability>
      </nc:capabilities>
      <nc:session-id>6196</nc:session-id>
    </nc:hello>
    ]]>]]>
    
    <rpc><get-system-information/></rpc>
    <nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/20.1R0/junos">
    <system-information>
    <hardware-model>mx960</hardware-model>
    <os-name>junos</os-name>
    <os-version>20.1R1.11</os-version>
    <serial-number>xxxxxxxxx</serial-number>
    <host-name>vmx103</host-name>
    </system-information>
    </nc:rpc-reply>
    ]]>]]>
    
    <rpc><get-system-information format="text"/></rpc>
    <nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/20.1R0/junos">
    <output>
    Model: mx960
    Family: junos
    Junos: 20.1R1.11
    Hostname: vmx103
    </output>
    </nc:rpc-reply>
    ]]>]]>​
    
    <rpc><get-system-information format="json"/></rpc>
    <nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/20.1R0/junos">
    {
        "system-information" : [
        {
            "hardware-model" : [
            {
                "data" : "mx960"
            }
            ],
            "os-name" : [
            {
                "data" : "junos"
            }
            ],
            "os-version" : [
            {
                "data" : "20.1R1.11"
            }
            ],
            "serial-number" : [
            {
                "data" : "xxxxxxxxxx"
            }
            ],
            "host-name" : [
            {
                "data" : "vmx103"
            }
            ]
        }
        ]
    }
    </nc:rpc-reply>
    ]]>]]>
    <rpc><close-session/></rpc>
    <nc:rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/20.1R0/junos">
    <nc:ok/>
    </nc:rpc-reply>
    ]]>]]>
    <!-- session end at 2023-01-14 05:20:16 PST -->
    Regards

    ------------------------------
    Andy Sharp
    ------------------------------