Skip to content

Commit

Permalink
app-admin/rex: Initial ebuild with adjust patches (#534)
Browse files Browse the repository at this point in the history
* app-admin/rex: Initial ebuild with adjust patches

Package-Manager: Portage-3.0.8, Repoman-2.3.11

* app-admin/rex: prepare to use I{drac4,lo} modules from CPAN

Package-Manager: Portage-3.0.8, Repoman-2.3.11

* dev-perl/Rex-Interface-Shell-Idrac4: initial ebuild for v0.1.0

Package-Manager: Portage-3.0.8, Repoman-2.3.11

* dev-perl/Rex-Interface-Shell-Ilo: initial ebuild for v0.1.0

Package-Manager: Portage-3.0.8, Repoman-2.3.11
  • Loading branch information
alip authored Jun 3, 2021
1 parent 96d5023 commit 1e1c6fa
Show file tree
Hide file tree
Showing 15 changed files with 859 additions and 0 deletions.
1 change: 1 addition & 0 deletions app-admin/rex/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST Rex-1.13.2.tar.gz 349355 BLAKE2B 49a3d2eacb16550dfc0649e93360b501dfc754d538ee65da8fb227791c5e6ce893067b1feea7f6254c579be3e8ae0bed88e68074faffd552f42bebf6cc2eb1be SHA512 6f7c677b117c9629e5a7a431cea2825bdb77d9eb5a5f005e5ab396ccd7552580ac7c1df6dd4e5cfd02e6ce46937b5a64c18dcf590a134e0f5fcd424bb45e5249
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
From a2e15c2fdc17d9257afe66f54d57e2ebb7f53784 Mon Sep 17 00:00:00 2001
From: Ali Polatel <[email protected]>
Date: Thu, 11 Apr 2019 14:49:14 +0200
Subject: [PATCH 1/2] LibVirt: Initial support for virtio-scsi virtual drives
(read: ssd trim)

1. Honour `driver_cache` and `driver_discard` keys in storage disk config.
2. Add a SCSI controller if any of the storage disks have SCSI as the target bus.

The SCSI model defaults to `virtio-scsi` and may be overriden by the
`scsi_model` parameter.

The second change is also a bug fix since without a SCSI controller
configuration a VM with a virtual disk attached to a SCSI bus won't
boot.
---
lib/Rex/Virtualization/LibVirt/create.pm | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/Rex/Virtualization/LibVirt/create.pm b/lib/Rex/Virtualization/LibVirt/create.pm
index 4f0776fa..956f73d9 100644
--- a/lib/Rex/Virtualization/LibVirt/create.pm
+++ b/lib/Rex/Virtualization/LibVirt/create.pm
@@ -329,11 +329,15 @@ sub _set_storage_defaults {
function => "0x0",
};
}
- elsif ( $store->{"bus"} eq "ide" && !exists $store->{"address"} ) {
+ elsif (
+ ( $store->{"bus"} =~ /\Aide|scsi\Z/ && !exists $store->{"address"} ) )
+ {
+ # The scsi conditional for the bus works around this error during virsh define:
+ # error: internal error: SCSI controller only supports 1 bus
$store->{"address"} = {
type => "drive",
controller => 0,
- bus => 1,
+ bus => $store->{"bus"} eq "scsi" ? 0 : 1,
unit => 0,
};
}
@@ -444,7 +448,14 @@ __DATA__

<% for my $disk (@{$::storage}) { %>
<disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
- <driver name="qemu" type="<%= $disk->{driver_type} %>"/>
+ <driver name="qemu" type="<%= $disk->{driver_type} %>"
+ <% if(exists $disk->{driver_cache}) { %>
+ cache="<%= $disk->{driver_cache} %>"
+ <% } %>
+ <% if(exists $disk->{driver_discard}) { %>
+ discard="<%= $disk->{driver_discard} %>"
+ <% } %>
+ />
<% if ($disk->{type} eq "file") { %>
<source file="<%= $disk->{file} %>"/>
<% } elsif ($disk->{file} eq "block") { %>
@@ -460,6 +471,11 @@ __DATA__
<controller type="ide" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
</controller>
+ <% if (grep { exists($_->{bus}) && $_->{bus} =~ /scsi/ } @{$::storage}) { %>
+ <controller type='scsi' index='0' model='<%= $::scsi_model // 'virtio-scsi' %>'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </controller>
+ <% } %>
<% for my $netdev (@{$::network}) { %>
<interface type="<%= $netdev->{type} %>">
<% if(exists $netdev->{mac}) { %>
--
2.28.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 9ccb48425932078f8fe3336576aa4498f895fb6d Mon Sep 17 00:00:00 2001
From: Chris Travers <[email protected]>
Date: Fri, 12 Feb 2021 10:19:01 +0100
Subject: [PATCH 2/2] t/issue/948.t: Fixing whitespace detection in test

---
t/issue/948.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/issue/948.t b/t/issue/948.t
index 5460058c..4e4468ae 100644
--- a/t/issue/948.t
+++ b/t/issue/948.t
@@ -26,7 +26,7 @@ sub Rex::Commands::File::file {
my ( $name, %params ) = @_;

my $fmt = get_image_format();
- like $params{content}, qr|<driver name="qemu" type="$fmt"/>|,
+ like $params{content}, qr|<driver name="qemu" type="$fmt"\s*/>|,
"Found file content for $fmt format.";
$count_file++;
}
--
2.28.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 0e0711c19c3d7518b591a0575fccf93cc69b9a7e Mon Sep 17 00:00:00 2001
From: "Maxine E. Aubrey" <[email protected]>
Date: Tue, 17 Mar 2020 11:36:28 +0100
Subject: [PATCH] Shell.pm: add iDRAC 4.00.00.00 support

---
lib/Rex/Interface/Shell.pm | 1 +
1 files changed, 1 insertions(+)

diff --git a/lib/Rex/Interface/Shell.pm b/lib/Rex/Interface/Shell.pm
index c11416d5..d9480910 100644
--- a/lib/Rex/Interface/Shell.pm
+++ b/lib/Rex/Interface/Shell.pm
@@ -19,6 +19,7 @@ my %SHELL_PROVIDER = (
bash => "Rex::Interface::Shell::Bash",
csh => "Rex::Interface::Shell::Csh",
idrac => "Rex::Interface::Shell::Idrac",
+ idrac4 => "Rex::Interface::Shell::Idrac4",
ksh => "Rex::Interface::Shell::Ksh",
sh => "Rex::Interface::Shell::Sh",
tcsh => "Rex::Interface::Shell::Tcsh",
--
2.28.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 0ed1472c8581960d58ce10f8015bbf93742a7d1e Mon Sep 17 00:00:00 2001
From: "Max E. Aubrey" <[email protected]>
Date: Mon, 15 Jul 2019 10:07:32 +0200
Subject: [PATCH] Shell.pm: add iLO support

---
lib/Rex/Interface/Shell.pm | 1 +
1 files changed, 1 insertions(+)

diff --git a/lib/Rex/Interface/Shell.pm b/lib/Rex/Interface/Shell.pm
index c11416d5..c10d78bc 100644
--- a/lib/Rex/Interface/Shell.pm
+++ b/lib/Rex/Interface/Shell.pm
@@ -19,6 +19,7 @@ my %SHELL_PROVIDER = (
bash => "Rex::Interface::Shell::Bash",
csh => "Rex::Interface::Shell::Csh",
idrac => "Rex::Interface::Shell::Idrac",
idrac4 => "Rex::Interface::Shell::Idrac4",
+ ilo => "Rex::Interface::Shell::Ilo",
ksh => "Rex::Interface::Shell::Ksh",
sh => "Rex::Interface::Shell::Sh",
tcsh => "Rex::Interface::Shell::Tcsh",
--
2.28.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 7cf37a10fd9c4899164fb72c8631118b252acd74 Mon Sep 17 00:00:00 2001
From: Oleksii Kliukin <[email protected]>
Date: Thu, 18 Jun 2020 23:36:42 +0200
Subject: [PATCH 1/2] Allow uploading files even when permissions cannot be
set.

By default, the "file" function uses sftp to upload the target file to
the server. During the upload, the Net::SFTP::Foreign runs chmod
unconditionally, failing if the target file is not owned by the ssh
user, unless that user is a root. This commit changes that behavior by
passing an optional "best_effort" flag that instructs sftp to continue
even if setting permissions has failed.

As a result, an unprivileged user will be able to use Rex scenarios that
call the "file" function without getting permission denied errors.
---
lib/Rex/Interface/Fs/OpenSSH.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Rex/Interface/Fs/OpenSSH.pm b/lib/Rex/Interface/Fs/OpenSSH.pm
index 01eea665..b9ddaa84 100644
--- a/lib/Rex/Interface/Fs/OpenSSH.pm
+++ b/lib/Rex/Interface/Fs/OpenSSH.pm
@@ -142,7 +142,7 @@ sub upload {
Rex::Commands::profiler()->start("upload: $source -> $target");

my $sftp = Rex::get_sftp();
- unless ( $sftp->put( $source, $target ) ) {
+ unless ( $sftp->put( $source, $target, best_effort => 1) ) {
Rex::Logger::debug("upload: $target is not writable");

Rex::Commands::profiler()->end("upload: $source -> $target");
--
2.28.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From 1935065ea0005c63fe2b4c19c5184ac61a0c7c7a Mon Sep 17 00:00:00 2001
From: Chris Traverswq <[email protected]>
Date: Wed, 15 Jul 2020 09:51:10 +0200
Subject: [PATCH 2/2] Only apply best effort option if sudo is not available.

This ensures the current behavior continues for ops but best effort
for writeable files allows other teams to apply changes.

Also began some initial POD for the OpenSSH module in functions touched.
---
lib/Rex/Interface/Fs/OpenSSH.pm | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/Rex/Interface/Fs/OpenSSH.pm b/lib/Rex/Interface/Fs/OpenSSH.pm
index b9ddaa84..80784e30 100644
--- a/lib/Rex/Interface/Fs/OpenSSH.pm
+++ b/lib/Rex/Interface/Fs/OpenSSH.pm
@@ -136,13 +136,32 @@ sub stat {
return %ret;
}

+=pod
+
+=head3 OpenSSH->upload($source, $target)
+
+Uploads an item from source to target.
+
+If sudo is enabled for the connection will set permissions etc too.
+Otherwise will only attempt to set permissions, and continue successfully
+if not.
+
+=cut
+
sub upload {
my ( $self, $source, $target ) = @_;

Rex::Commands::profiler()->start("upload: $source -> $target");

my $sftp = Rex::get_sftp();
- unless ( $sftp->put( $source, $target, best_effort => 1) ) {
+
+ # If we are not sudo, we need to fall back to best effort on
+ # file upload. The %best_effort hash will evaluate be expanded
+ # to best_effort => 1 if and and only if is_sudo returns false.
+
+ my %best_effort = ();
+ $best_effort{best_effort} = 1 unless Rex::is_sudo();
+ unless ( $sftp->put( $source, $target, %best_effort) ) {
Rex::Logger::debug("upload: $target is not writable");

Rex::Commands::profiler()->end("upload: $source -> $target");
--
2.28.0

Loading

0 comments on commit 1e1c6fa

Please sign in to comment.