Commit Graph

150 Commits

Author SHA1 Message Date
Fabian Grünbichler
a05f1ee86c build: force debug symbols in release build
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>
2024-06-20 10:32:12 +02:00
Wolfgang Bumiller
e6334f92ae bump version to 0.7.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-06-07 13:26:13 +02:00
Dominik Csapak
88626c5430 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:

https://forum.proxmox.com/threads/146248/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-06-07 13:18:21 +02:00
Wolfgang Bumiller
32772d404e fix --help output formatting
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>
2024-04-05 08:19:04 +02:00
Thomas Lamprecht
a407a22c5e bump version to 0.7.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-04 18:18:52 +02:00
Thomas Lamprecht
01e10b840e 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>
2024-04-04 18:13:25 +02:00
Thomas Lamprecht
936f35152f version file: skip repo revision for now
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>
2024-04-04 18:05:02 +02:00
Wolfgang Bumiller
07e99acda3 add .version file to root of the fuse mount
containing 2 lines:
1) the cargo version as
2) the git commit hash

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-04 17:28:03 +02:00
Wolfgang Bumiller
6820bc1ff5 catch NotFound in handle_lookup explicitly
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>
2024-04-04 17:28:03 +02:00
Wolfgang Bumiller
722d868225 use send_replace on watch channels
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>
2024-04-04 17:28:03 +02:00
Wolfgang Bumiller
39350e691c use new InodeEntries for Datastores
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-04 17:28:03 +02:00
Wolfgang Bumiller
98a625e972 factor deduplicated entry lookup out of Dir
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-04 17:28:03 +02:00
Wolfgang Bumiller
d7d566bc7f refcount cache enable state
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>
2024-04-04 17:28:03 +02:00
Thomas Lamprecht
81a2fef39f bump version to 0.6.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-02 10:32:46 +02:00
Thomas Lamprecht
38602093f0 reformat let-else for better readability
`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>
2024-04-02 10:32:46 +02:00
Thomas Lamprecht
37f9b50ca1 update gitignore file
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-02 10:26:54 +02:00
Wolfgang Bumiller
676030c4be use session cookie to avoid generating a new one on each request
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-04-02 09:36:59 +02:00
Thomas Lamprecht
5337a0cbb7 bump version to 0.6.0
just to get the slightly more understandable (from user POV) changelog
update out

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-28 16:10:00 +01:00
Thomas Lamprecht
05d1c2cc3b d/changelog: expand and reword slightly
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-28 14:42:30 +01:00
Wolfgang Bumiller
8d35b4e3aa bump version to 0.5.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 13:45:21 +01:00
Wolfgang Bumiller
fe5382ec96 attempt to negotiate http2 protocol via alpn
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 13:21:43 +01:00
Wolfgang Bumiller
37e288655f bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 13:21:43 +01:00
Wolfgang Bumiller
7f20f7428f explicitly enable http2 in hyper
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 13:21:43 +01:00
Wolfgang Bumiller
0a1c92d558 fix error message when not finding password-file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 13:21:43 +01:00
Wolfgang Bumiller
47c252c18f guard read requests so they cannot fail with ENOSYS
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 10:51:31 +01:00
Wolfgang Bumiller
7f170ec39e update help to show how to specify a port
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 10:40:26 +01:00
Wolfgang Bumiller
30c61e7d43 litvms: add --port parameter
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-28 10:33:27 +01:00
Wolfgang Bumiller
922534ccd4 update d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 16:54:57 +01:00
Wolfgang Bumiller
6dd7bce923 clamp worker threads between 2 and 4 based on core count
via num_cpus

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 16:54:18 +01:00
Wolfgang Bumiller
5606270346 limit async runtime to 4 worker and 2 blocking threads
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>
2024-03-27 16:13:56 +01:00
Thomas Lamprecht
24fef09802 bump version to 0.5.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-27 15:20:41 +01:00
Wolfgang Bumiller
c532701af6 actually fail reads on http 500
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 14:57:37 +01:00
Wolfgang Bumiller
7f589f6040 limit to 4 concurrent requests and synchronize retry loops
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>
2024-03-27 14:45:42 +01:00
Thomas Lamprecht
72863f3044 bump version to 0.4.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-27 12:37:06 +01:00
Thomas Lamprecht
2a2f9ec931 esxi fuse: reduce log of retrying due to rate-limit to warn
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-27 12:36:35 +01:00
Thomas Lamprecht
e911e90824 bump version to 0.4.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-27 12:21:53 +01:00
Thomas Lamprecht
c2b9668dbb fix-up version tracked in cargo.toml
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-27 12:21:36 +01:00
Thomas Lamprecht
fff95895fd 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>
2024-03-27 12:19:05 +01:00
Thomas Lamprecht
251582b46a bump version to 0.4.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-27 12:13:14 +01:00
Max Carrara
9c9dc29835 listvms: remove unused import and unaccessed exception
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-03-27 11:44:52 +01:00
Wolfgang Bumiller
cd0243f9ea listvms.py: improve error message when password file is missing
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 10:51:33 +01:00
Wolfgang Bumiller
c2ba7f04da listvms.py: improve error message for invalid credentials
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 10:45:48 +01:00
Wolfgang Bumiller
58ad9385d4 listvms.py: just print the errors as they are
they are unexpected by nature...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 10:45:19 +01:00
Wolfgang Bumiller
555d5fe1d0 listvms.py: drop squeeze helper
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 10:43:32 +01:00
Wolfgang Bumiller
9ae699de15 listvms.py: actually don't use Path for the types
we just want to pass whatever we get onward to perl & rust and not
place restrictions on it

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-27 10:27:17 +01:00
Max Carrara
c7bd6d9ba7 use mypy for automatic type checks in Python
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>
2024-03-27 10:22:49 +01:00
Max Carrara
1563eddb55 listvms: run formatter
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>
2024-03-27 10:22:47 +01:00
Max Carrara
edf287b490 listvms: dump json directly to stdout
Signed-off-by: Max Carrara <m.carrara@proxmox.com>
2024-03-27 10:22:46 +01:00
Max Carrara
5f6e1d5bfb 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`.

[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>
2024-03-27 10:22:45 +01:00
Max Carrara
cda87e27df 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.

[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>
2024-03-27 10:22:43 +01:00