Skip to main content

huawei_file_transfer-V0.0.2 huawei_file_transfer-V0.0.2 is a Netmiko-based function that provides file transfer capabilities for Huawei devices

Project description

##huawei_file_transfer huawei_file_transfer is a Netmiko-based function that provides file transfer capabilities for Huawei devices. This function is modified for netmiko==4.2.0, so the version of netmiko needs to be >=4.0.0.At the same time, it provides hidden verification of the available size of the target space and the existence of files This function currently does not support file verification, The parameter of verify needs to be set to False. ###Installing

pip install huawei_file_transfer

##Example Usage ###Using the put of direction

from huawei_file_transfer import file_transfer
from netmiko import ConnectHandler

device_info = {
    "device_type": "huawei",
    "ip": "192.168.0.253",
    "username": "admin123",
    "password": "Huawei@123",
}


with ConnectHandler(**device_info) as connect:
    print("已经成功登陆设备" + device_info['ip'])
    output = file_transfer(
        connect,
        source_file="s5735-l1-v200r022sph150.pat",
        dest_file="s5735-l1-v200r022sph150.pat",
        file_system="flash:",
        direction="put",
        verify_file=False,
        overwrite_file=True,
    )
    print(output)

Results

{'file_exists': True, 'file_transferred': True, 'file_verified': False}

###Using the get of direction

from huawei_file_transfer import file_transfer
from netmiko import ConnectHandler

device_info = {
    "device_type": "huawei",
    "ip": "192.168.0.253",
    "username": "admin123",
    "password": "Huawei@123",
}


with ConnectHandler(**device_info) as connect:
    print("已经成功登陆设备" + device_info['ip'])
    output = file_transfer(
        connect,
        source_file="s5735-l1-v200r022sph150.pat",
        dest_file="s5735-l1-v200r022sph150.pat",
        file_system="flash:",
        direction="get",
        verify_file=False,
        overwrite_file=True,
    )
    print(output)

Results

{'file_exists': True, 'file_transferred': True, 'file_verified': False}

###Using process_bar functions to display the progress of transferring files in real time

from huawei_file_transfer import file_transfer,progress_bar
from netmiko import ConnectHandler

device_info = {
    "device_type": "huawei",
    "ip": "192.168.0.253",
    "username": "admin123",
    "password": "Huawei@123",
}


with ConnectHandler(**device_info) as connect:
    print("已经成功登陆设备" + device_info['ip'])
    output = file_transfer(
        connect,
        source_file="s5735-l1-v200r022sph150.pat",
        dest_file="s5735-l1-v200r022sph150.pat",
        file_system="flash:",
        direction="get",
        verify_file=False,
        overwrite_file=True,
        progress=progress_bar
    )
    print(output)

Results

Transferring file: s5735-l1-v200r022sph150.pat

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| (100.00%)
{'file_exists': True, 'file_transferred': True, 'file_verified': False}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huawei_file_transfer-0.0.2.tar.gz (14.1 kB view hashes)

Uploaded Source

Built Distribution

huawei_file_transfer-0.0.2-py3-none-any.whl (13.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page