copy files to VC members

425 views
Skip to first unread message

Volkert Kreuk

unread,
May 10, 2014, 2:23:07 PM5/10/14
to junos-p...@googlegroups.com
Jeremy,

I am trying to use junos-eznc to copy a slax commit script to a virtual chassis (VC). 

File transfer to the VC master is straightforward with the SCP module, challenge however is copying the script from the master to each of the VC members.  Tried to issue the 'file copy <source> <destination>' cli command.  Unfortunately junos-eznc fails to execute this command - return message 'invalid command'.

Any advice?  Thanks in advance.

regards, Volkert

Jeremy Schulman

unread,
May 10, 2014, 2:32:30 PM5/10/14
to junos-p...@googlegroups.com
Hi Volkert,

There is a "file-copy" RPC that you can use.  If you look through the Junos XML RPC command reference, you will find it"
https://www.juniper.net/techpubs/en_US/junos13.3/information-products/topic-collections/junos-xml-ref-oper/index.html

Copies here:


    <rpc>
      <file-copy>
        <source>source</source> <!-- mandatory -->
        <destination>destination</destination> <!-- mandatory -->
        <source-address>source-address</source-address>
      </file-copy>
    </rpc>


Let me check if this is easily accomplished via junos-pyez.  Hope to have something back on this thread shortly.

Cheers,
-- Jeremy

Jeremy Schulman

unread,
May 10, 2014, 2:50:47 PM5/10/14
to junos-p...@googlegroups.com
Ok, there is a way to do this in junos-pyez that uses the filesystem module: jnpr.junos.utils.fs.
Here is a short snippet:

>>> from jnpr.junos import Device
>>> from jnpr.junos.utils.fs import FS
>>> dev = Device('red-vsrx')
>>
>>> dev.open()
Device(red-vsrx)
>>>
>>>
>>> dev.bind(fs=FS)


Now copy a file called "base.conf" that is in the local directory to "foo.conf" in the same directory:

>>> dev.fs.cp('base.conf','foo.conf')
True


I believe you should be able to do the same with other virtual chassis members where the destination value ('foo.conf') can be "fpc1:/var/tmp/foo.conf", for example.  I haven't tried this on a virtual-chassis system specifically.  So if you do, please let me know if it works OK.

Thank you!


Hope this helps.



Message has been deleted

Volkert Kreuk

unread,
May 10, 2014, 3:45:57 PM5/10/14
to junos-p...@googlegroups.com
Jeremy - seems to work.  Thanks

>>> netSession.fs.cp('/var/tmp/expand-interface-ranges.slax', 'fpc0:/var/db/scripts/commit/')
True


On Saturday, May 10, 2014 2:23:07 PM UTC-4, Volkert Kreuk wrote:
Reply all
Reply to author
Forward
0 new messages