Commit Graph

2405 Commits

Author SHA1 Message Date
Wolfgang Bumiller
5b652dbad8 api-macro: schema tests for async fns
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:01:55 +01:00
Wolfgang Bumiller
943bc4de52 api-macro: more tests
Note that this one tests the fact that we do not do output
schema validation!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:58:27 +01:00
Wolfgang Bumiller
58158b495e api-macro: more invocation tests for api methods
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:56:45 +01:00
Wolfgang Bumiller
679ad01c03 api-macro: add expanded data to tests for verification
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:51:00 +01:00
Wolfgang Bumiller
b0ef405186 api: add test-harness feature
If enabled, the Schema type implements Eq and PartialEq for
testing the api macro better.

Note that these implementations don't make all too much
since since they also compare `dyn Fn` types which do not
implement Eq. Since they're also `&'static` they can't
really be runtime closures, so this should be fine, we know
they'll always point to some regular function.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:38:30 +01:00
Wolfgang Bumiller
08e1cf3c2f api-macro: support empty api macro on structs
The description comes from the doc comment, the field types
and description from field doc comments and types.
Previously we needed to add at least the hint that the
schema is an object schema. Now we support an empty #[api]
attribute as well.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:09:42 +01:00
Wolfgang Bumiller
7c6ebbdbf3 api-macro: support renamed struct fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:06:48 +01:00
Wolfgang Bumiller
2e63bf8422 api-macro: support rename_all in enums
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:29:56 +01:00
Wolfgang Bumiller
dd5cd3f311 api-macro: start using serde attribute helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:23:52 +01:00
Wolfgang Bumiller
799c993d63 api-macro: prepare to support serde::rename_all
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:17:20 +01:00
Wolfgang Bumiller
3626f57d2c api-macro: more option type handling
infer_type now also returns whether it was encapsualted in
an Option<>. So `type: String, optional: true` is now
inferred propertly from `Option<String>`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:37:34 +01:00
Wolfgang Bumiller
45af06f090 api-macro: derive optional values correctly
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:19:13 +01:00
Wolfgang Bumiller
46fe5832fb api-macro: reorganize field iteration
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:18:21 +01:00
Wolfgang Bumiller
9207e8aa9a api-macro: error on extraneous fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:16:12 +01:00
Wolfgang Bumiller
860a4fd0ad api-macro: add basic struct handling
- handle doc comments for descriptions
- infer fields from structs when possible
- perform some basic error checking

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:09:20 +01:00
Wolfgang Bumiller
e960a68b60 api-macro: factor out type inference for reuse with structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:09:08 +01:00
Wolfgang Bumiller
b9769de6b6 api-macro: split struct handling into newtype, regular, unit, ...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 12:11:04 +01:00
Wolfgang Bumiller
4c77a7fece api-macro: derive descriptions for structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 12:00:17 +01:00
Fabian Grünbichler
a6f21e7694 cargo: switch to use packaged crates by default
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-03 09:39:52 +01:00
Fabian Grünbichler
f667873d70 tools: remove accidentally commited debian/files
it's a build artifact, no need to version control it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-03 07:28:24 +01:00
Wolfgang Bumiller
43682dd416 version bump
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 14:42:28 +01:00
Wolfgang Bumiller
f214bcb652 api-macro: drop unused dev-dependencies
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 14:25:09 +01:00
Fabian Grünbichler
8bd5e82012 readme: add cargo config for packaged crates
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-02 14:07:12 +01:00
Fabian Grünbichler
94168b94c2 proxmox-tools: reference valgrind_request via git
to allow using 'cargo XXX' with cargo config pointing to packaged
sources instead of crates.io

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-02 14:00:27 +01:00
Wolfgang Bumiller
b659584f23 sys: add a bunch of error helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 13:47:53 +01:00
Wolfgang Bumiller
568ce10624 sys: add some helpful macros
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 13:47:53 +01:00
Wolfgang Bumiller
c52794b8ad api-macro: bump bytes to 0.5
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 12:45:07 +01:00
Wolfgang Bumiller
1a2aaad5a1 more versioning fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 12:33:13 +01:00
Wolfgang Bumiller
929161f030 -dev bump for proxmox crate as well
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 12:05:57 +01:00
Wolfgang Bumiller
496afe891e add a 'Versioning' readme section
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 11:50:30 +01:00
Wolfgang Bumiller
09345ac8c5 bump proxmox-tools to 0.1.1-dev.1
We now use this between package releases.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 11:32:21 +01:00
Wolfgang Bumiller
f90cbb7edd tools: fs: default to 644 for mode in replace_file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 10:06:40 +01:00
Fabian Grünbichler
c27369e136 proxmox: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
8840877c80 proxmox-api-macro: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
57565a5061 proxmox-sortable-macro: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
d6bf884814 proxmox-sys: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
f4d9e8157c proxmox-sys: update lazy-static to 1.4
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
08433fd330 proxmox-api: use proxmox-tools package in d/rules
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
92c645cee2 proxmox-api: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
36f03c0feb proxmox-api: update rustyline to 5.0.5
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
2ecd975608 proxmox-api: update lazy_static to 1.4
which is available in Debian unstable.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
fa4f892c19 proxmox-tools: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
a33d9a35db proxmox-tools: update regex and lazy_static
to those versions available in Debian unstable

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:15:24 +01:00
Wolfgang Bumiller
2abdbb5113 add a top level doc comment to fs submodule
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-19 12:01:36 +01:00
Dietmar Maurer
a185257e80 update to nix 0.16 2019-12-19 09:29:44 +01:00
Wolfgang Bumiller
ef612103f2 bump nix to 0.16
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-19 09:27:41 +01:00
Thomas Lamprecht
cfae8ae3d2 linux/procfs: add read_proc_stat
For now we just parse the CPU "time-spent" counters and calculate the
CPU usage of the whole system. As we do not want a total average we
use a state-full implementation, which calculates the usage since the
last request (if older than 1 second).

Somewhat modeled after our Perl version of this. But for the "total"
we do not use the:
> ($ctime - $last_proc_stat->{ctime}) * $clock_ticks * $cpucount;
calculation, but just add _all_ fields together, as that is the total
of CPU time.

Use a Reader-Writer lock to sync updating. First check under the
reader lock if the data is recent enough, else update it under the
writer lock.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-18 17:00:51 +01:00
Wolfgang Bumiller
1e7467ee11 cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 13:41:17 +01:00
Wolfgang Bumiller
85742a0d57 tools: create_path: return whether the dir was created
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 13:40:12 +01:00
Wolfgang Bumiller
867a530724 tools: create_dir: pass EEXIST to the caller
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 13:37:10 +01:00