* [pve-devel] [PATCH manager] api: factor out shell command schema
@ 2025-09-02 12:55 Wolfgang Bumiller
2025-09-03 16:01 ` Thomas Lamprecht
2025-09-04 16:53 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 2 replies; 4+ messages in thread
From: Wolfgang Bumiller @ 2025-09-02 12:55 UTC (permalink / raw)
To: pve-devel
So we only sort the enum keys once and the documentation and API dumps
don't keep reordering them, and to deduplicate the cmd and cmd-opts
schema.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
PVE/API2/Nodes.pm | 68 ++++++++++++++---------------------------------
1 file changed, 20 insertions(+), 48 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index ce7eecaf1..636789277 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1103,6 +1103,23 @@ my $shell_cmd_map = {
},
};
+my @shell_cmd_params = (
+ cmd => {
+ type => 'string',
+ description => "Run specific command or default to login (requires 'root\@pam')",
+ enum => [sort keys %$shell_cmd_map],
+ optional => 1,
+ default => 'login',
+ },
+ 'cmd-opts' => {
+ type => 'string',
+ description => "Add parameters to a command. Encoded as null terminated strings.",
+ requires => 'cmd',
+ optional => 1,
+ default => '',
+ },
+);
+
sub get_shell_command {
my ($user, $shellcmd, $args) = @_;
@@ -1156,22 +1173,7 @@ __PACKAGE__->register_method({
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
- cmd => {
- type => 'string',
- description =>
- "Run specific command or default to login (requires 'root\@pam')",
- enum => [keys %$shell_cmd_map],
- optional => 1,
- default => 'login',
- },
- 'cmd-opts' => {
- type => 'string',
- description =>
- "Add parameters to a command. Encoded as null terminated strings.",
- requires => 'cmd',
- optional => 1,
- default => '',
- },
+ @shell_cmd_params,
websocket => {
optional => 1,
type => 'boolean',
@@ -1307,22 +1309,7 @@ __PACKAGE__->register_method({
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
- cmd => {
- type => 'string',
- description =>
- "Run specific command or default to login (requires 'root\@pam')",
- enum => [keys %$shell_cmd_map],
- optional => 1,
- default => 'login',
- },
- 'cmd-opts' => {
- type => 'string',
- description =>
- "Add parameters to a command. Encoded as null terminated strings.",
- requires => 'cmd',
- optional => 1,
- default => '',
- },
+ @shell_cmd_params,
},
},
returns => {
@@ -1437,22 +1424,7 @@ __PACKAGE__->register_method({
properties => {
node => get_standard_option('pve-node'),
proxy => get_standard_option('spice-proxy', { optional => 1 }),
- cmd => {
- type => 'string',
- description =>
- "Run specific command or default to login (requires 'root\@pam')",
- enum => [keys %$shell_cmd_map],
- optional => 1,
- default => 'login',
- },
- 'cmd-opts' => {
- type => 'string',
- description =>
- "Add parameters to a command. Encoded as null terminated strings.",
- requires => 'cmd',
- optional => 1,
- default => '',
- },
+ @shell_cmd_params,
},
},
returns => get_standard_option('remote-viewer-config'),
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH manager] api: factor out shell command schema
2025-09-02 12:55 [pve-devel] [PATCH manager] api: factor out shell command schema Wolfgang Bumiller
@ 2025-09-03 16:01 ` Thomas Lamprecht
2025-09-04 12:27 ` Wolfgang Bumiller
2025-09-04 16:53 ` [pve-devel] applied: " Thomas Lamprecht
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2025-09-03 16:01 UTC (permalink / raw)
To: Proxmox VE development discussion, Wolfgang Bumiller
Am 02.09.25 um 14:55 schrieb Wolfgang Bumiller:
> So we only sort the enum keys once and the documentation and API dumps
> don't keep reordering them, and to deduplicate the cmd and cmd-opts
> schema.
>
> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> ---
> PVE/API2/Nodes.pm | 68 ++++++++++++++---------------------------------
> 1 file changed, 20 insertions(+), 48 deletions(-)
>
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index ce7eecaf1..636789277 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -1103,6 +1103,23 @@ my $shell_cmd_map = {
> },
> };
>
> +my @shell_cmd_params = (
not really much difference in practice, but why not a %hash map?
> + cmd => {
> + type => 'string',
> + description => "Run specific command or default to login (requires 'root\@pam')",
> + enum => [sort keys %$shell_cmd_map],
> + optional => 1,
> + default => 'login',
> + },
> + 'cmd-opts' => {
> + type => 'string',
> + description => "Add parameters to a command. Encoded as null terminated strings.",
> + requires => 'cmd',
> + optional => 1,
> + default => '',
> + },
> +);
> +
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH manager] api: factor out shell command schema
2025-09-03 16:01 ` Thomas Lamprecht
@ 2025-09-04 12:27 ` Wolfgang Bumiller
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Bumiller @ 2025-09-04 12:27 UTC (permalink / raw)
To: Thomas Lamprecht; +Cc: Proxmox VE development discussion
On Wed, Sep 03, 2025 at 06:01:22PM +0200, Thomas Lamprecht wrote:
> Am 02.09.25 um 14:55 schrieb Wolfgang Bumiller:
> > So we only sort the enum keys once and the documentation and API dumps
> > don't keep reordering them, and to deduplicate the cmd and cmd-opts
> > schema.
> >
> > Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> > ---
> > PVE/API2/Nodes.pm | 68 ++++++++++++++---------------------------------
> > 1 file changed, 20 insertions(+), 48 deletions(-)
> >
> > diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> > index ce7eecaf1..636789277 100644
> > --- a/PVE/API2/Nodes.pm
> > +++ b/PVE/API2/Nodes.pm
> > @@ -1103,6 +1103,23 @@ my $shell_cmd_map = {
> > },
> > };
> >
> > +my @shell_cmd_params = (
>
> not really much difference in practice, but why not a %hash map?
typo, sorry
>
> > + cmd => {
> > + type => 'string',
> > + description => "Run specific command or default to login (requires 'root\@pam')",
> > + enum => [sort keys %$shell_cmd_map],
> > + optional => 1,
> > + default => 'login',
> > + },
> > + 'cmd-opts' => {
> > + type => 'string',
> > + description => "Add parameters to a command. Encoded as null terminated strings.",
> > + requires => 'cmd',
> > + optional => 1,
> > + default => '',
> > + },
> > +);
> > +
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied: [PATCH manager] api: factor out shell command schema
2025-09-02 12:55 [pve-devel] [PATCH manager] api: factor out shell command schema Wolfgang Bumiller
2025-09-03 16:01 ` Thomas Lamprecht
@ 2025-09-04 16:53 ` Thomas Lamprecht
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2025-09-04 16:53 UTC (permalink / raw)
To: pve-devel, Wolfgang Bumiller
On Tue, 02 Sep 2025 14:55:13 +0200, Wolfgang Bumiller wrote:
> So we only sort the enum keys once and the documentation and API dumps
> don't keep reordering them, and to deduplicate the cmd and cmd-opts
> schema.
>
>
Applied, with a s/@/%/ to use a "native" hash for clarity, thanks!
[1/1] api: factor out shell command schema
commit: 25bc89015220a71999f43ca003f4d9a9d496d78d
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-04 16:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-02 12:55 [pve-devel] [PATCH manager] api: factor out shell command schema Wolfgang Bumiller
2025-09-03 16:01 ` Thomas Lamprecht
2025-09-04 12:27 ` Wolfgang Bumiller
2025-09-04 16:53 ` [pve-devel] applied: " Thomas Lamprecht
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.