[pve-devel] [PATCH v1 pve-esxi-import-tools 4/5] listvms: add arg parser, context manager for connections, fetch helper

Max Carrara m.carrara at proxmox.com
Wed Mar 20 18:00:56 CET 2024


On Wed Mar 20, 2024 at 1:45 PM CET, Wolfgang Bumiller wrote:
> 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...

Oh, thanks for pointing this out - I had assumed that, well, passwords
wouldn't contain spaces ... ever.

Mea culpa; will fix in v2.





More information about the pve-devel mailing list