Daniel Kral [Wed, 21 Aug 2024 13:57:48 +0000 (15:57 +0200)]
fix #5587: add support for older version of vmx storage filepaths
Allow the ESXi storage disk entry property "fileName" to be flatcased
("filename") in addition to being camelcased ("fileName"). This adds
compatibility with older ESXi .vmx configuration files.
Dominik Csapak [Fri, 10 May 2024 13:56:57 +0000 (15:56 +0200)]
improve error handling before mounting
when we fail early in the mount process, we did not log any error to the
syslog, but only the top most one to stderr.
sadly we were not able to see them anywhere, so improve the log by
* log the complete error chain with log::error (so we also can see the
causes)
* add more context hints
This can help debug issues where we failed early and could not see any
error output otherwise, e.g. this thread in the forum:
For the sake of having the string indented, we use
backslash-line-continuations, but they swallow up all the spaces at
the beginning of the next line, so we use `\n \` explicitly with
spaces between the newline and the line-continuation to introduce the
indentation in the output.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
esxi: add help and version flags as long and short option
even though this is in libexec and not meant for direct use it can be
still useful to get the version of the installed file to compare with
the one of a mounted FS, or to get the help output if one is testing
something manually.
So add the classic -v or --version and the -h or --help flags,
respectively.
Any of those will cause an early (successful) exit.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
The current git revision is not exposed by cargo, so we'd need a
build.rs script to get this, like we do in PBS (well in a sub-crate to
avoid frequent costly rebuilds). For now that's not worth it, having
the version exposed is enough to see if the mount is old.
And do not concat the three version atoms manually, we can use the
CARGO_PKG_VERSION environment variable.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Otherwise, if the kernel has multiple `Open` requests for a file, a
`Release` request will disable the cache for all of them. This was
not a problem without Open/Release, as Lookups aren't dropped as long
as any references are around...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
`cargo fmt` still mostly ignores let-else, so format it manually in
how most examples use it, with the just the inside of the else branch
block on a new, indented line. As otherwise, with no indentation
change between the assignment and the else in a new line it reads like
being two separate statements.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Wed, 27 Mar 2024 11:19:01 +0000 (12:19 +0100)]
buildsys: skip checking build-dependencies for generating the DSC
allows to build a DSC that is then further used via sbuild, or the
like, without having to install all build-dependencies on the host one
is connected to.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Max Carrara [Fri, 22 Mar 2024 18:06:21 +0000 (19:06 +0100)]
listvms: add arg parser, context manager for connections, fetch helper
In order to make the CLI interface more friendly to humans, Python's
`argparse` [0] module from the standard library is used to parse the
arguments provided to the script. Each option and positional argument
also contain a short help text that is shown when running the script
with either "-h" or "--help".
Additionally, this commit also adds a context manager [1] for
establishing connections to an ESXi host. The context manager ensures
that the connection is closed in its inner `finally` block.
The inner part of the VM-data-fetching loop in `main()` is factored
out into a separate helper function, which now raises a `RuntimeError`
if the datacenter of a VM cannot be looked up.
In general, should any exception be thrown inside the loop, its output
is subsequently logged to stderr. The loop then just continues like
before.
Any exception that is not caught inside of `main()` is now printed to
stderr, followed by exiting with `1`.
Overall, the script's behaviour and output on successful operations
remains the same, except regarding unsuccessful argument parsing and
displaying error messages. In other words, invocations prior to this
patch should result in the same JSON output (if successful).
This was tested by piping the outputs of this script before and after
this commit through `jq` and then comparing the outputs with `diff`.
Max Carrara [Fri, 22 Mar 2024 18:06:20 +0000 (19:06 +0100)]
listvms: improve typing and add dataclasses to represent dicts
This commit replaces some of the explicitly imported types from the
`typing` module with their inbuilt counterparts, e.g. `typing.List`
becomes `list`. This is supported since Python 3.9 [0].
Additionally, file paths are now represented as `pathlib.Path` [1],
which also checks whether the given string is actually a valid path
when constructed.
Furthermore, the `dict`s with values of mixed types are now
represented as dataclasses [2] instead, in order to make them more
type-safe (--> allow for better linting).
Because dataclasses and `pathlib.Path`s are not JSON-serializable by
default however, a helper function is added, which allows for more
fine-grained control regarding how those objects are serialized.
Thomas Lamprecht [Tue, 12 Mar 2024 15:14:31 +0000 (16:14 +0100)]
Revert "buildsys: add d/rustup_home, register force system toolchain"
This reverts commit 826e60c5c59f05cc3a0ac033a66f16d0f46ef89a, it's
introduction of an absolute link to /usr breaks source directory
boundary, failing dpkg-source.
Devs that need to have rustup and related binaries earlier in $PATH
than the system ones can just create a system toolchain via something
like `rustup toolchain link system /usr` and be done, it's their
custom setup/environment that breaks build, so default packaging
should not have to care, at least not in a way that breaks default
build in clean environments (like sbuild).
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Sun, 10 Mar 2024 14:45:04 +0000 (15:45 +0100)]
buildsys: allow to generate packages artefacts at the top-level
Allow building packages with their output being written at the
top-level, just like basically all our other repos (that contain a
hand-full of source packages at max), and make that the default.
If one want to have a double directory hierarchy for the build they
can just call:
make OUTPUT_DIR=build/ deb
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Sun, 10 Mar 2024 14:39:55 +0000 (15:39 +0100)]
packagin: ship script and tool in arch-agnostic /usr/libexec
no need to use the architecture triple, not like we plan to support
co-installable multi-arch anyway.
Rather just use the arch-agnostic /usr/libexec dir, which the FHS
specifies for:
> Directory contains binaries for internal use only and they are not
> meant to be executed directly by users shell or scripts.
Which pretty much is what this tools are made for, in our use case
anyway.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
We cache file sizes, but if the vmx config files change they can of
course very well also change their size, in which case we might get an
http 416 Range Not Satisfiable response. Let's consider the File
handle to be at EOF at that point.
additionally, partial reads return a `content-range` header which
includes the file's size, so use this to keep track of it
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>