[pve-devel] [PATCH common 3/3] AbstractMigrate: use get_ssh_base_cmd to assemble ssh_cmd

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 23 09:33:27 CET 2017


On Fri, Jan 20, 2017 at 04:13:13PM +0100, Thomas Lamprecht wrote:
> this sets the HostKeyAlias for us, so that users using the dedicated
> migration network do not need to add each cluster node to every
> cluster members known_hosts file for each network they want to use
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  src/PVE/AbstractMigrate.pm | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/PVE/AbstractMigrate.pm b/src/PVE/AbstractMigrate.pm
> index 772444a..11629ef 100644
> --- a/src/PVE/AbstractMigrate.pm
> +++ b/src/PVE/AbstractMigrate.pm
> @@ -125,8 +125,6 @@ my $eval_int = sub {
>      };
>  };
>  
> -my @ssh_opts = ('-o', 'BatchMode=yes');
> -my @ssh_cmd = ('/usr/bin/ssh', @ssh_opts);
>  sub migrate {
>      my ($class, $node, $nodeip, $vmid, $opts) = @_;
>  
> @@ -138,7 +136,7 @@ sub migrate {
>  	vmid => $vmid,
>  	node => $node,
>  	nodeip => $nodeip,
> -	rem_ssh => [ @ssh_cmd, "root\@$nodeip" ],
> +	rem_ssh => PVE::Cluster::get_ssh_base_cmd($node, $nodeip),

cyclical dependency territory ahead? :P

why not move this into the concrete migration implementations - we have
the needed data ($node and $nodeip), and instead of something like

 my $cmd = [@{$self->{rem_ssh}}, 'pvesm', 'free', "$storeid:$volname"];

in qemu-server/PVE/QemuMigrate.pm (and all the others) you could use
your new helper to generate the SSH command? pve-container and
qemu-server are allowed to use PVE::Cluster, pve-common should not
(although AbstratConfig also has two calls that we should probably
eliminate one way or another..).

>      };
>  
>      $self = bless $self, $class;
> @@ -165,7 +163,7 @@ sub migrate {
>  	if (defined($remote_migration_ip)) {
>  	    $nodeip = $remote_migration_ip;
>  	    $self->{nodeip} = $remote_migration_ip;
> -	    $self->{rem_ssh} = [ @ssh_cmd, "root\@$nodeip" ];
> +	    $self->{rem_ssh} = PVE::Cluster::get_ssh_base_cmd($node, $nodeip),

same as above

>  
>  	    $self->log('info', "use dedicated network address for sending " .
>  	               "migration traffic ($self->{nodeip})");
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list