[pve-devel] [PATCH 06/19] phase2 : write vm config to externalcluster new vmid.conf

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Mar 9 13:38:32 CET 2017


On 02/22/2017 02:33 PM, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>   PVE/QemuMigrate.pm | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
> index a2fa17a..616632c 100644
> --- a/PVE/QemuMigrate.pm
> +++ b/PVE/QemuMigrate.pm
> @@ -473,6 +473,7 @@ sub phase2 {
>   
>       if ($self->{opts}->{externalcluster}) {
>   	$self->log('info', "Creating a new VM on remote external node '$self->{node}'");
> +
>   	## start on remote node
>   	my $cmdcreate = [@{$self->{rem_ssh}}];
>   	push @$cmdcreate , 'qm', 'create';
> @@ -484,6 +485,15 @@ sub phase2 {
>                   $vmid = $1;
>               }
>   	});
> +
> +	my $configout = "";
> +	foreach my $opt (keys %$conf) {
> +	    next if $opt eq 'snapshots';
> +	    next if $opt eq 'pending';
> +	    $configout .= "$opt: $conf->{$opt}\n";
> +	}
> +	my $cmdwrite = [@{$self->{rem_ssh}}," /bin/echo -e \"$configout\" > /etc/pve/qemu-server/$targetvmid.conf"];
> +        PVE::Tools::run_command($cmdwrite);
>       }
That looks a bit hacky :)

I'd do this when creating the VM on the remote side.

Instead of the qm create an API call with all the parameters set.
It should be not to hard to get the API call with all parameters from
the config, as the are already compatible (asserted by JSON schema) AFAIK.

>   
>       $self->log('info', "starting VM $vmid on remote node '$self->{node}'");





More information about the pve-devel mailing list