The current way we handle network file transfers is rather messy. There are multiple scripts that independently wrap curl and ssh for file transfers:
vyatta-remote-copy.pl (used exclusively for tech support file uploads).Completely removed. vyatta-image-tools.pl contains its own ad hoc routines for curl and rsync for some strange reason even though vyatta-remote-copy.pl is available.Deserves to be removed eventually. Erstwhile remote.py (used for config management).Rewritten. vyatta-save-config.pl (also used for config management). vyatta-load-user-key.pl for loadkey, which also needs to be more robust.Deprecated in favour of generate public-key-command. Deserves to be removed eventually. vyatta-commit-push.pl. install-image.
- get_latest_iso.py uses requests directly.
All of them spend a lot of effort figuring out the given protocol and fiddling with host keys.
The solution is writing a single all-Python script as the one-stop solution for all remote transfers in the codebase. Python standard library comes with ftplib, which is an adequate FTP client for our needs, although there is nothing for SSH. Paramiko is a well-known, reliable SSH library for Python, suited exactly for this purpose. It would save us from relying on curl and herding host keys.
loadkey currently breaks on some keys and the rewrite needs to tolerate both bare keys and keys with user/host info.