Commit Graph

338 Commits

Author SHA1 Message Date
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
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
Wolfgang Bumiller
3c284b131d tools: fix create_path: don't use O_PATH
open(2) says file descriptors opened with O_PATH cannot be
passed to fchmod(), fchown(), etc.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 13:20:58 +01:00
Wolfgang Bumiller
5e1468bff8 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 13:20:58 +01:00
Dietmar Maurer
d0349e9ba9 src/cli/format.rs - print_help: by default, use verbose output for simply commands 2019-12-18 13:08:18 +01:00
Thomas Lamprecht
13007df318 api/macro: add NumberSchema
Adapted from the integer schema, uses f64 type.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 11:30:55 +01:00
Wolfgang Bumiller
81cac5fc29 replace create_dir_chown with create_dir using CreateOptions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 11:09:23 +01:00
Wolfgang Bumiller
ffcbcc117a deprecate file_set_contents{,_full}
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 10:46:28 +01:00
Wolfgang Bumiller
4bce3d76a2 tools: replace_file, make options not an option...
CreateOptions::new() creates an all-None option set anyway

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 10:04:22 +01:00
Wolfgang Bumiller
2387f9ef2b tools: introduce replace_file
nicer api with CreateOptions
see doc-comments for more info

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 10:01:46 +01:00
Wolfgang Bumiller
1d65ff88dd drop derive-builder dependency
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 10:00:30 +01:00
Wolfgang Bumiller
778983c1b0 remove old router macro documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-18 09:40:40 +01:00
Wolfgang Bumiller
79c9d6ab08 api-macro: remove now-unnecessary PropertySchema type
Schemas can now generally refer to an externally defined
schema.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-16 13:06:58 +01:00
Wolfgang Bumiller
3e5927a1b4 api-macro: generalized '{ schema: PATH }' schemas
allow 'schema: PATH' outside object property context

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-16 12:11:52 +01:00
Wolfgang Bumiller
808035f524 api-macro: support 'async fn' with new async api method
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-16 11:13:26 +01:00
Dietmar Maurer
7dadea06dd implement ApiHandler::Async 2019-12-16 09:53:25 +01:00
Wolfgang Bumiller
d9897316b8 api: update url crate to 2.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-13 11:30:09 +01:00
Wolfgang Bumiller
5d5918ef8e update bytes to 0.5
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-12 15:35:36 +01:00
Wolfgang Bumiller
f1fcdff9a3 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-12 15:35:30 +01:00
Wolfgang Bumiller
6d152f8930 updates for hyper 0.13 release
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-12 13:13:53 +01:00
Dietmar Maurer
bf7b939bdf proxmox-api/src/cli.rs: simplify cli setup using generics. 2019-12-09 17:38:18 +01:00
Dietmar Maurer
c9cec98ece proxmox-api/src/cli/format.rs - generate_nested_usage: fix formating with empty prefix 2019-12-06 10:14:22 +01:00
Wolfgang Bumiller
d00a096851 api: add 'router' and 'cli' features
Move API types into the router module and make router and
cli optional.

This way the 'router' module is the only thing with a
dependency on 'hyper', allowing the use of the schema alone
without pulling in the entire hyper stack.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 13:40:09 +01:00
Wolfgang Bumiller
2d12f81235 api: use http::{Parts,Response,Method}
hyper just reexports them

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 13:18:21 +01:00
Wolfgang Bumiller
ee1a7cd68b more clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 12:33:29 +01:00
Wolfgang Bumiller
65a284784b clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 11:42:34 +01:00
Wolfgang Bumiller
92ffe4c240 formatting fixup
please run `make` to check formatting before committing

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 11:33:12 +01:00
Wolfgang Bumiller
7c48247c58 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-05 11:32:48 +01:00
Wolfgang Bumiller
b81beb4dfb api-macro: allow methods without return types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 14:27:57 +01:00
Wolfgang Bumiller
c282c8ce23 api-macro: don't return Null without return schema
serde_json turns () into Null anyway, so there's no need to
check this!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 14:25:12 +01:00
Wolfgang Bumiller
f9d775924d api-macro: get enum description from doc comments
instead of:
    #[api(description: "Some description.")]
    pub enum { ... }

support:
    #[api]
    /// Some description.
    pub enum { ... }

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 11:52:03 +01:00
Wolfgang Bumiller
7609cf2bd4 api-macro: move doc-comment reading to util
The function attribute reader doesn't read any other
attributes anymore, so make it reusable!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 11:47:27 +01:00
Wolfgang Bumiller
8a6e741d6c api: let ConstRegexPattern deref to Regex
This way we can just use `SOME_REGEX.is_match()` again
without having to explicitly call `(SOME_REGEX.regex_obj)()`
first.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 11:06:03 +01:00
Wolfgang Bumiller
197b1bccb3 api-macro: rename SimpleIdent to FieldName
Initially it was a wrapper around Ident to avoid some
copies, but now it's what we use to allow hyphenated names
for fields in objects (as `syn::Ident` doesn't allow that at
all), so give it a more fitting name.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-04 09:06:31 +01:00
Wolfgang Bumiller
4de409c526 api-macro: support hyphenated parameter names
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-03 13:34:37 +01:00
Wolfgang Bumiller
f3f15c2893 api-macro: drop ToTokens for SimpleIdent
The user must be explicit about whether the ident or string
is required.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-03 11:58:40 +01:00
Wolfgang Bumiller
b7ecf3a597 api-macro: drop Deref of SimpleIdent
The user must always be explicit about whether the Ident or
the String is required, since they may differ.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-03 11:57:07 +01:00