Re: [pve-devel] [PATCH pve-client] Use API definition for start/stop properties

2018-06-13 Thread Dietmar Maurer
> This works but currently 'qemu' is hard coded in the
> "merge_api_definition_properties" path which
> has the behavior that we ALWAYS get qemu "properties" where we want LXC
> properties often.
> 
> The only solution I can think of is to split those commands for Qemu/LXC
> as in:
>    
>     $ pveclient qemu start lola 100
>     $ pveclient lxc start lola 100
> 
> What do you think about this?

No, do not split. Keep current CLI, but do not use
merge_api_definition_properties()
for now.

> 
> 
> On 2018-06-13 14:17, René Jochum wrote:
> > ---
> >  PVE/APIClient/Commands/GuestStatus.pm | 18 ++
> >  PVE/APIClient/Helpers.pm  | 10 ++
> >  2 files changed, 20 insertions(+), 8 deletions(-)
> >
> > diff --git a/PVE/APIClient/Commands/GuestStatus.pm
> > b/PVE/APIClient/Commands/GuestStatus.pm
> > index 4a50164..7f90798 100644
> > --- a/PVE/APIClient/Commands/GuestStatus.pm
> > +++ b/PVE/APIClient/Commands/GuestStatus.pm
> > @@ -34,10 +34,11 @@ __PACKAGE__->register_method ({
> >  description => "Start a  guest (VM/Container).",
> >  parameters => {
> > additionalProperties => 0,
> > -   properties => {
> > -   remote => get_standard_option('pveclient-remote-name'),
> > -   vmid => get_standard_option('pve-vmid'),
> > -   },
> > +   properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> > +   '/nodes/{node}/qemu/{vmid}/status/start', 'POST', {
> > +   remote => get_standard_option('pveclient-remote-name'),
> > +   vmid => get_standard_option('pve-vmid'),
> > +   }),
> >  },
> >  returns => { type => 'null'},
> >  code => sub {
> > @@ -58,10 +59,11 @@ __PACKAGE__->register_method ({
> >  description => "Stop a guest (VM/Container).",
> >  parameters => {
> > additionalProperties => 0,
> > -   properties => {
> > -   remote => get_standard_option('pveclient-remote-name'),
> > -   vmid => get_standard_option('pve-vmid'),
> > -   },
> > +   properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> > +   '/nodes/{node}/qemu/{vmid}/status/stop', 'POST', {
> > +   remote => get_standard_option('pveclient-remote-name'),
> > +   vmid => get_standard_option('pve-vmid'),
> > +   }),
> >  },
> >  returns => { type => 'null'},
> >  code => sub {
> > diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
> > index 1ea8a5e..4eb596a 100644
> > --- a/PVE/APIClient/Helpers.pm
> > +++ b/PVE/APIClient/Helpers.pm
> > @@ -77,6 +77,16 @@ sub lookup_api_method {
> >  return $data;
> >  }
> >  
> > +sub merge_api_definition_properties {
> > +my ($path, $method, $properties) = @_;
> > +
> > +my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
> > +
> > +my %tmp = (%{$info->{parameters}->{properties}}, %$properties);
> > +
> > +return \%tmp;
> > +};
> > +
> >  sub complete_api_call_options {
> >  my ($cmd, $prop, $prev, $cur, $args) = @_;
> >  
> 
> 
> ___
> pve-devel mailing list
> pve-devel@pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] [PATCH pve-client] Use API definition for start/stop properties

2018-06-13 Thread Dietmar Maurer
comments inline:

> On June 13, 2018 at 2:17 PM René Jochum  wrote:
> 
> 
> ---
>  PVE/APIClient/Commands/GuestStatus.pm | 18 ++
>  PVE/APIClient/Helpers.pm  | 10 ++
>  2 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/PVE/APIClient/Commands/GuestStatus.pm
> b/PVE/APIClient/Commands/GuestStatus.pm
> index 4a50164..7f90798 100644
> --- a/PVE/APIClient/Commands/GuestStatus.pm
> +++ b/PVE/APIClient/Commands/GuestStatus.pm
> @@ -34,10 +34,11 @@ __PACKAGE__->register_method ({
>  description => "Start a  guest (VM/Container).",
>  parameters => {
>   additionalProperties => 0,
> - properties => {
> - remote => get_standard_option('pveclient-remote-name'),
> - vmid => get_standard_option('pve-vmid'),
> - },
> + properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> + '/nodes/{node}/qemu/{vmid}/status/start', 'POST', {
> + remote => get_standard_option('pveclient-remote-name'),
> + vmid => get_standard_option('pve-vmid'),
> + }),
>  },
>  returns => { type => 'null'},
>  code => sub {
> @@ -58,10 +59,11 @@ __PACKAGE__->register_method ({
>  description => "Stop a guest (VM/Container).",
>  parameters => {
>   additionalProperties => 0,
> - properties => {
> - remote => get_standard_option('pveclient-remote-name'),
> - vmid => get_standard_option('pve-vmid'),
> - },
> + properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> + '/nodes/{node}/qemu/{vmid}/status/stop', 'POST', {
> + remote => get_standard_option('pveclient-remote-name'),
> + vmid => get_standard_option('pve-vmid'),
> + }),
>  },
>  returns => { type => 'null'},
>  code => sub {
> diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
> index 1ea8a5e..4eb596a 100644
> --- a/PVE/APIClient/Helpers.pm
> +++ b/PVE/APIClient/Helpers.pm
> @@ -77,6 +77,16 @@ sub lookup_api_method {
>  return $data;
>  }
>  
> +sub merge_api_definition_properties {
> +my ($path, $method, $properties) = @_;
> +
> +my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
> +
> +my %tmp = (%{$info->{parameters}->{properties}}, %$properties);

Maybe we can/should make sure that we do not override existing properties?

> +
> +return \%tmp;
> +};
> +
>  sub complete_api_call_options {
>  my ($cmd, $prop, $prev, $cur, $args) = @_;
>  
> -- 
> 2.11.0
> 
> ___
> pve-devel mailing list
> pve-devel@pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] [PATCH pve-client] Use API definition for start/stop properties

2018-06-13 Thread René Jochum
This works but currently 'qemu' is hard coded in the
"merge_api_definition_properties" path which
has the behavior that we ALWAYS get qemu "properties" where we want LXC
properties often.

The only solution I can think of is to split those commands for Qemu/LXC
as in:
   
    $ pveclient qemu start lola 100
    $ pveclient lxc start lola 100

What do you think about this?


On 2018-06-13 14:17, René Jochum wrote:
> ---
>  PVE/APIClient/Commands/GuestStatus.pm | 18 ++
>  PVE/APIClient/Helpers.pm  | 10 ++
>  2 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/PVE/APIClient/Commands/GuestStatus.pm 
> b/PVE/APIClient/Commands/GuestStatus.pm
> index 4a50164..7f90798 100644
> --- a/PVE/APIClient/Commands/GuestStatus.pm
> +++ b/PVE/APIClient/Commands/GuestStatus.pm
> @@ -34,10 +34,11 @@ __PACKAGE__->register_method ({
>  description => "Start a  guest (VM/Container).",
>  parameters => {
>   additionalProperties => 0,
> - properties => {
> - remote => get_standard_option('pveclient-remote-name'),
> - vmid => get_standard_option('pve-vmid'),
> - },
> + properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> + '/nodes/{node}/qemu/{vmid}/status/start', 'POST', {
> + remote => get_standard_option('pveclient-remote-name'),
> + vmid => get_standard_option('pve-vmid'),
> + }),
>  },
>  returns => { type => 'null'},
>  code => sub {
> @@ -58,10 +59,11 @@ __PACKAGE__->register_method ({
>  description => "Stop a guest (VM/Container).",
>  parameters => {
>   additionalProperties => 0,
> - properties => {
> - remote => get_standard_option('pveclient-remote-name'),
> - vmid => get_standard_option('pve-vmid'),
> - },
> + properties => PVE::APIClient::Helpers::merge_api_definition_properties(
> + '/nodes/{node}/qemu/{vmid}/status/stop', 'POST', {
> + remote => get_standard_option('pveclient-remote-name'),
> + vmid => get_standard_option('pve-vmid'),
> + }),
>  },
>  returns => { type => 'null'},
>  code => sub {
> diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
> index 1ea8a5e..4eb596a 100644
> --- a/PVE/APIClient/Helpers.pm
> +++ b/PVE/APIClient/Helpers.pm
> @@ -77,6 +77,16 @@ sub lookup_api_method {
>  return $data;
>  }
>  
> +sub merge_api_definition_properties {
> +my ($path, $method, $properties) = @_;
> +
> +my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
> +
> +my %tmp = (%{$info->{parameters}->{properties}}, %$properties);
> +
> +return \%tmp;
> +};
> +
>  sub complete_api_call_options {
>  my ($cmd, $prop, $prev, $cur, $args) = @_;
>  


___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH pve-client] Use API definition for start/stop properties

2018-06-13 Thread René Jochum
---
 PVE/APIClient/Commands/GuestStatus.pm | 18 ++
 PVE/APIClient/Helpers.pm  | 10 ++
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/PVE/APIClient/Commands/GuestStatus.pm 
b/PVE/APIClient/Commands/GuestStatus.pm
index 4a50164..7f90798 100644
--- a/PVE/APIClient/Commands/GuestStatus.pm
+++ b/PVE/APIClient/Commands/GuestStatus.pm
@@ -34,10 +34,11 @@ __PACKAGE__->register_method ({
 description => "Start a  guest (VM/Container).",
 parameters => {
additionalProperties => 0,
-   properties => {
-   remote => get_standard_option('pveclient-remote-name'),
-   vmid => get_standard_option('pve-vmid'),
-   },
+   properties => PVE::APIClient::Helpers::merge_api_definition_properties(
+   '/nodes/{node}/qemu/{vmid}/status/start', 'POST', {
+   remote => get_standard_option('pveclient-remote-name'),
+   vmid => get_standard_option('pve-vmid'),
+   }),
 },
 returns => { type => 'null'},
 code => sub {
@@ -58,10 +59,11 @@ __PACKAGE__->register_method ({
 description => "Stop a guest (VM/Container).",
 parameters => {
additionalProperties => 0,
-   properties => {
-   remote => get_standard_option('pveclient-remote-name'),
-   vmid => get_standard_option('pve-vmid'),
-   },
+   properties => PVE::APIClient::Helpers::merge_api_definition_properties(
+   '/nodes/{node}/qemu/{vmid}/status/stop', 'POST', {
+   remote => get_standard_option('pveclient-remote-name'),
+   vmid => get_standard_option('pve-vmid'),
+   }),
 },
 returns => { type => 'null'},
 code => sub {
diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
index 1ea8a5e..4eb596a 100644
--- a/PVE/APIClient/Helpers.pm
+++ b/PVE/APIClient/Helpers.pm
@@ -77,6 +77,16 @@ sub lookup_api_method {
 return $data;
 }
 
+sub merge_api_definition_properties {
+my ($path, $method, $properties) = @_;
+
+my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
+
+my %tmp = (%{$info->{parameters}->{properties}}, %$properties);
+
+return \%tmp;
+};
+
 sub complete_api_call_options {
 my ($cmd, $prop, $prev, $cur, $args) = @_;
 
-- 
2.11.0

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel