2

I'm using github.com/Juniper/go-netconf/netconf library. Here is my RPC to get interface config:

rpcGetInterfaceConfig = "<get-configuration><configuration><interfaces><interface><name>%s</name></interface></interfaces></configuration></get-configuration>"     command := fmt.Sprintf(rpcGetInterfaceConfig, switchInterface)  reply, err := j.Session.Exec(netconf.RawMethod(command))

This is how reply.Data looks like:

<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm" junos:changed-seconds="1677335789" junos:changed-localtime="2023-03-01 04:43:09 UTC">     <junos:comment># Placeholder for QFX platform config.</junos:comment>     <interfaces>         <interface>             <name>et-1/0/1</name>             <native-vlan-id>101</native-vlan-id>             <mtu>9192</mtu>             <unit>                 <name>0</name>                 <family>                     <ethernet-switching>                         <interface-mode>trunk</interface-mode>                         <vlan>                             <members>vlan101</members>                             <members>vlan102</members>                             <members>vlan103</members>                         </vlan>                     </ethernet-switching>                 </family>             </unit>``         </interface>     </interfaces> </configuration> 

After some manupulations I'd like to restore the interface config:

rpcApplyConfig     = "<load-configuration format=\"xml\"><configuration>%s</configuration></load-configuration>"
command := fmt.Sprintf(rpcApplyConfig, config)
reply, err := j.Session.Exec(netconf.RawMethod(command))

And got an error in the reply message:

<load-configuration-results> <rpc-error> <error-type>protocol</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>syntax error, expecting &lt;/configuration&gt;</error-message> <error-info> <bad-element>configuration</bad-element> </error-info> </rpc-error> <rpc-error> <error-type>protocol</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-message>syntax error, expecting &lt;/configuration&gt;</error-message> <error-info> <bad-element>configuration</bad-element> </error-info> </rpc-error> <load-error-count>2</load-error-count> </load-configuration-results>

0 Answers0