Skip to content

Commit

Permalink
Merge pull request #1185 from okurz/enhance/backend_ssh
Browse files Browse the repository at this point in the history
backend: DRY on check_socket method
  • Loading branch information
okurz committed Aug 6, 2019
2 parents 7147b64 + fb41818 commit 9b02bf5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 40 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -22,6 +22,7 @@ backendexec_DATA = \
backend/svirt.pm \
backend/pvm.pm \
backend/spvm.pm \
backend/ssh.pm \
backend/virt.pm

consolesexecdir = $(pkglibexecdir)/consoles
Expand Down
11 changes: 1 addition & 10 deletions backend/ipmi.pm
Expand Up @@ -20,7 +20,7 @@ use strict;
use warnings;
use autodie ':all';

use base 'backend::baseclass';
use base 'backend::ssh';

require File::Temp;
use File::Temp ();
Expand Down Expand Up @@ -137,15 +137,6 @@ sub is_shutdown {
return $ret =~ m/is off/;
}

sub check_socket {
my ($self, $fh, $write) = @_;

if ($self->check_ssh_serial($fh)) {
return 1;
}
return $self->SUPER::check_socket($fh, $write);
}

sub get_mc_status {
my ($self) = @_;

Expand Down
10 changes: 0 additions & 10 deletions backend/s390x.pm
Expand Up @@ -63,14 +63,4 @@ sub do_stop_vm {
return;
}

sub check_socket {
my ($self, $fh, $write) = @_;

if ($self->check_ssh_serial($fh)) {
return 1;
}

return $self->SUPER::check_socket($fh, $write);
}

1;
11 changes: 1 addition & 10 deletions backend/spvm.pm
Expand Up @@ -18,7 +18,7 @@ package backend::spvm;
use strict;
use warnings;

use base 'backend::virt';
use base qw(backend::virt backend::ssh);

use testapi qw(get_var get_required_var check_var);
use IO::Select;
Expand Down Expand Up @@ -92,15 +92,6 @@ sub is_shutdown {
return 0;
}

sub check_socket {
my ($self, $fh, $write) = @_;

if ($self->check_ssh_serial($fh)) {
return 1;
}
return $self->SUPER::check_socket($fh, $write);
}

sub stop_serial_grab {
my ($self) = @_;

Expand Down
34 changes: 34 additions & 0 deletions backend/ssh.pm
@@ -0,0 +1,34 @@
# Copyright © 2019 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

package backend::ssh;

use strict;
use warnings;

use base 'backend::baseclass';


sub new {
return shift->SUPER::new;
}

sub check_socket {
my ($self, $fh, $write) = @_;
return 1 if $self->check_ssh_serial($fh);
return $self->SUPER::check_socket($fh, $write);
}

1;
11 changes: 1 addition & 10 deletions backend/svirt.pm
Expand Up @@ -19,7 +19,7 @@ package backend::svirt;
use strict;
use warnings;

use base 'backend::virt';
use base qw(backend::virt backend::ssh);

use File::Basename;
use IO::Scalar;
Expand Down Expand Up @@ -392,15 +392,6 @@ sub serial_terminal_log_file {
. get_required_var('JOBTOKEN');
}

sub check_socket {
my ($self, $fh, $write) = @_;

if ($self->check_ssh_serial($fh)) {
return 1;
}
return $self->SUPER::check_socket($fh, $write);
}

sub stop_serial_grab {
my ($self) = @_;

Expand Down

0 comments on commit 9b02bf5

Please sign in to comment.