From: Stefan Priebe <g...@profihost.ag>
Signed-off-by: root <r...@neuerserver.de-nserver.de.de-nserver.de> --- data/PVE/Tools.pm | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/data/PVE/Tools.pm b/data/PVE/Tools.pm index 27b4361..b42a5f2 100644 --- a/data/PVE/Tools.pm +++ b/data/PVE/Tools.pm @@ -30,6 +30,7 @@ template_replace safe_print trim extract_param +build_ssh_opt ); my $pvelogdir = "/var/log/pve"; @@ -888,4 +889,31 @@ sub dir_glob_foreach { } } +sub build_ssh_opt { + my ( $opts ) = @_; + my @ssh_opts = (); + + # we only accept options we know and we have defaults for + # you can also delete options by passing the key with value + # undef + my $defaults = { + cipher => { opt => '-c', default => 'blowfish' }, + mode => { opt => '-o', default => 'BatchMode=yes' }, + }; + + foreach my $option ( sort keys %$defaults ) { + if ( $opts && ref($opts) eq "HASH" && exists $opts->{$option} ) { + + # option was passed as undef so skip this one + next if ( !defined $opts->{$option} ); + push( @ssh_opts, ( $defaults->{$option}{opt}, $opts->{$option} ) ); + } + else { + push( @ssh_opts, ( $defaults->{$option}{opt}, $defaults->{$option}{default} ) ); + } + } + + return @ssh_opts; +} + 1; -- 1.7.2.5 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel