[pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Mar 20 13:45:59 CET 2024
On Tue, Mar 19, 2024 at 04:32:49PM +0100, Max Carrara wrote:
> + at contextmanager
> +def connect_to_esxi_host(args: EsxiConnectonArgs) -> vim.ServiceInstance:
> + """Opens a connection to an ESXi host with the given username and password
> + contained in the password file.
> + """
> + ssl_context = (
> + ssl._create_unverified_context()
> + if args.skip_cert_verification
> + else None
> + )
> +
> + with open(args.password_file) as pw_file:
> + password = pw_file.read().strip()
This strips all whitespace from both sides, which is not what we want.
(Not that I particularly care whether esxi even allows spaces in
passwords at all...)
The old code specifically only stripped a single trailing *newline*,
mainly for when you edit the file with eg. vim which defaults to adding
one...
More information about the pve-devel
mailing list