Correct formatting (perltidy)

This commit is contained in:
NojuHD
2025-02-07 12:29:05 -05:00
parent 7bb26c2a7b
commit e6abf236a0
+29 -30
View File
@@ -38,9 +38,9 @@ my $default_hgsuffix = "";
my $DEBUG = 0;
my $cmd = {
iscsiadm => '/usr/bin/iscsiadm',
multipath => '/sbin/multipath',
blockdev => '/usr/sbin/blockdev'
iscsiadm => '/usr/bin/iscsiadm',
multipath => '/sbin/multipath',
blockdev => '/usr/sbin/blockdev'
};
### BLOCK: Configuration
@@ -145,18 +145,18 @@ sub exec_command {
sub scsi_scan_new {
print "Debug :: PVE::Storage::Custom::PureStoragePlugin::sub::scsi_scan_new\n" if $DEBUG;
my $fc_base = '/sys/class/fc_host';
my @fc_hosts = glob("$fc_base/*");
my $fc_base = '/sys/class/fc_host';
my @fc_hosts = glob( "$fc_base/*" );
die "Error :: sub::scsi_scan_new did not find fibre channel hosts.\n" unless @fc_hosts;
foreach my $fc_host (@fc_hosts) {
next unless ($fc_host =~ m/^(\/sys\/class\/fc_host\/\w+)$/);
my $adapter = basename($1);
my $scsi_host = File::Spec->catfile("/sys/class/scsi_host/", $adapter);
foreach my $fc_host ( @fc_hosts ) {
next unless ( $fc_host =~ m/^(\/sys\/class\/fc_host\/\w+)$/ );
my $adapter = basename( $1 );
my $scsi_host = File::Spec->catfile( "/sys/class/scsi_host/", $adapter );
if(-d $scsi_host) {
open my $fh, '>', File::Spec->catfile($scsi_host, "scan") or die "Error :: Cannot open file: $!";
if ( -d $scsi_host ) {
open my $fh, '>', File::Spec->catfile( $scsi_host, "scan" ) or die "Error :: Cannot open file: $!";
print $fh "- - -\n";
close $fh;
} else {
@@ -166,27 +166,27 @@ sub scsi_scan_new {
}
sub scsi_rescan_device {
my ($wwid) = @_;
my ( $wwid ) = @_;
print "Debug :: PVE::Storage::Custom::PureStoragePlugin::sub::scsi_rescan_device\n" if $DEBUG;
die "Error :: sub::scsi_rescan_device did not recive a wwid.\n" unless $wwid;
die "Error :: sub::scsi_rescan_device did not recive a wwid.\n" unless $wwid;
foreach my $device (glob('/sys/class/scsi_device/*')) {
next unless ($device =~ m/^(\/sys\/class\/scsi_device\/[\d\:\\]+)$/);
foreach my $device ( glob( '/sys/class/scsi_device/*' ) ) {
next unless ( $device =~ m/^(\/sys\/class\/scsi_device\/[\d\:\\]+)$/ );
my $tmppath = $1;
my $wwid_file = File::Spec->catfile($tmppath, "device/wwid");
my $wwid_file = File::Spec->catfile( $tmppath, "device/wwid" );
next unless -f $wwid_file;
open(my $wwid_fh, '<', $wwid_file) or die "Error :: Cannot open file: $!";
open( my $wwid_fh, '<', $wwid_file ) or die "Error :: Cannot open file: $!";
my $tmpwwid = <$wwid_fh>;
close($wwid_fh);
close( $wwid_fh );
$tmpwwid =~ s/^naa\.//;
$tmpwwid = "3" . lc($tmpwwid);
chomp($tmpwwid);
$tmpwwid = "3" . lc( $tmpwwid );
chomp( $tmpwwid );
if ($tmpwwid eq $wwid) {
open my $rescan, '>', File::Spec->catfile($tmppath, "device/rescan") or die "Error :: Cannot open file: $!";
if ( $tmpwwid eq $wwid ) {
open my $rescan, '>', File::Spec->catfile( $tmppath, "device/rescan" ) or die "Error :: Cannot open file: $!";
print $rescan "1\n";
close $rescan;
}
@@ -643,16 +643,15 @@ sub purestorage_resize_volume {
my ( $path, $wwid ) = $class->purestorage_get_wwn( $scfg, $volname );
my $protocol = $scfg->{ protocol };
if ($protocol == 1) {
if ( $protocol == 1 ) {
exec_command( [ $cmd->{ iscsiadm }, '--mode', 'node', '--rescan' ], 1 );
} elsif ($protocol == 2) {
scsi_rescan_device($wwid);
} elsif ($protocol == 3) {
} elsif ( $protocol == 2 ) {
scsi_rescan_device( $wwid );
} elsif ( $protocol == 3 ) {
die qq{"Error :: Protocol: "$protocol" isn't implemented yet.\n};
} else {
die qq{Error :: Protocol: "$protocol" isn't a valid protocol.\n};
}
# FIXME: wwid is probably ignored
exec_command( [ $cmd->{ multipath }, '-r', $wwid ], 1 );
@@ -977,11 +976,11 @@ sub map_volume {
exec_command( [ $cmd->{ multipath }, '-a', $wwid ], 1 );
my $protocol = $scfg->{ protocol };
if ($protocol == 1) {
if ( $protocol == 1 ) {
exec_command( [ $cmd->{ iscsiadm }, '--mode', 'session', '--rescan' ], 1 );
} elsif ($protocol == 2) {
} elsif ( $protocol == 2 ) {
scsi_scan_new();
} elsif ($protocol == 3) {
} elsif ( $protocol == 3 ) {
die qq{"Error :: Protocol: "$protocol" isn't implemented yet.\n};
} else {
die qq{Error :: Protocol: "$protocol" isn't a valid protocol.\n};