they then get stripped into their own package anyway, but without this we don't
get debug symbols at all with rustc >= 1.77
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
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:
https://forum.proxmox.com/threads/146248/
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
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>
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>
this is currently not produced, but better safe than sorry, since we
do have NotFound as well as Errno(ENOENT) meaning the same thing
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
To avoid errors about closed channels, as we'd then keep a receiver
without a sender in the active-lookup tables.
Signed-off-by: Wolfgang Bumiller <w.bumiller@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>
like we do for the qemu backup drivers, instead of having tokio just
spawn as many as there are cores, which is excessive...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
this is a very simple variant with a semaphore for the concurrent
requests and a mutex for the retry loop...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
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>
This commit adds mypy [0] as build dependency and ensures it is
invoked during the package build process.
mypy can also be manually invoked via `make lint`.
A mypy.ini file [1] is also added to disable errors regarding missing
type stubs for pyVmomi and pyVim.
[0]: https://www.mypy-lang.org/
[1]: https://mypy.readthedocs.io/en/stable/config_file.html
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
This commit formats the script using `black -l 80` [0], even though we
don't have an official style guide for Python.
[0]: https://github.com/psf/black
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
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`.
[0]: https://docs.python.org/3.11/library/argparse.html
[1]: https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
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.
[0]: https://docs.python.org/3.9/whatsnew/3.9.html#type-hinting-generics-in-standard-collections
[1]: https://docs.python.org/3.11/library/pathlib.html
[2]: https://docs.python.org/3.11/library/dataclasses.html
Signed-off-by: Max Carrara <m.carrara@proxmox.com>