Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scrapli SCP

Welcome to Scrapli SCP project!

This project is about to add smart SCP capability to Scrapli based connections. By smart, I mean various checks before and after the file copy to ensure the file copy is possible and successful.

These are the checks done by default:

  1. checksum
  2. existence of file at destination (also with hash)
  3. available space at destination
  4. scp enablement on device (and tries to turn it on if needed)
  5. restore configuration after transfer if it was changed
  6. check MD5 after transfer

Requirements

scrapli, scrapli-community, asyncssh, aiofiles

Installation

$ pip install scrapli-scp

Simple example

You can find it in test folder but the main part:

async with AsyncScrapli(**device) as conn:
    scp = AsyncSrapliSCP(conn)
    result = await scp.file_transfer("put", src=filename, dst=".", force_scp_config=True)
print(result)

Progress bar example

from rich.progress import Progress

with Progress(refresh_per_second=100) as progress:
    task = progress.add_task("Getting config...")

    def progress_handler(srcpath: bytes, dstpath: bytes, copied: int, total: int):  # arg signature is important!
        progress.update(task, completed=copied, total=total, description=dstpath.decode())

    async with AsyncScrapli(**device) as conn:
        scp: AsyncSCPFortiOS = AsyncSrapliSCP(conn)
        result = await scp.get_config(
            filename=filename,
            overwrite=True,
            force_scp_config=True,
            progress_handler=progress_handler
        )
print(result)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages