Skip to content

pyntc.utils.models

Data Models for Pyntc.

pyntc.utils.models.FileCopyModel dataclass

Data class to represent the specification for pulling a file from a URL to a network device.

Parameters:

Name Type Description Default
download_url str

The URL to download the file from. Can include credentials, but it's recommended to use the username and token fields instead for security reasons.

required
checksum str

The expected checksum of the file.

required
file_name str

The name of the file to be saved on the device.

required
file_size int

The expected size of the file. When supplied, remote_file_copy verifies the target device has room before starting the transfer. When omitted, the pre-transfer space check is skipped (callers can probe the source URL themselves and populate this field). Defaults to None.

None
file_size_unit str

Unit that file_size is expressed in. One of "bytes", "megabytes", "gigabytes". Only consulted when file_size is supplied. Defaults to "bytes".

'bytes'
hashing_algorithm str

The hashing algorithm to use for checksum verification. Defaults to "md5".

'md5'
timeout int

The timeout for the download operation in seconds. Defaults to 900.

900
username str

The username for authentication if required by the URL. Optional if credentials are included in the URL.

None
token str

The password or token for authentication if required by the URL. Optional if credentials are included in the URL.

None
vrf str

The VRF to use for the download if the device supports VRFs. Optional.

None
ftp_passive bool

Whether to use passive mode for FTP downloads. Defaults to True.

True

__post_init__()

Validate the input and prepare the clean URL after initialization.

from_dict(data) classmethod

Allows users to just pass a dictionary if they prefer.

to_dict()

Useful for logging or passing to other Nornir tasks.