From 7877b4b452d8b997949304413fb4d11d39d8a92d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 17 Dec 2015 15:18:49 +0000 Subject: [PATCH] scstadmin: Merge trunk r6752 git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.1.x@6753 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scstadmin/scstadmin.sysfs/Makefile | 10 +- .../{scst-0.9.10 => scst-1.0.0}/MANIFEST | 0 .../{scst-0.9.10 => scst-1.0.0}/Makefile.PL | 0 .../{scst-0.9.10 => scst-1.0.0}/README | 0 .../lib/SCST/SCST.pm | 8 +- .../t/01-start-scst.t | 0 .../t/02-scst-attr.t | 0 .../t/03-targets.t | 0 .../{scst-0.9.10 => scst-1.0.0}/t/04-alua.t | 0 .../t/05-dynattr.t | 0 .../t/06-after-restore.conf} | 0 .../t/06-cont-on-err.t | 4 +- .../t/06-to-be-restored.conf} | 0 .../scst-1.0.0/t/07-result.conf | 38 +++ .../scst-1.0.0/t/07-scstadmin-args.t | 97 ++++++ .../t/99-stop-scst.t | 0 .../scst-1.0.0/t/after-restore.conf | 60 ++++ .../scst-1.0.0/t/to-be-restored.conf | 67 ++++ scstadmin/scstadmin.sysfs/scstadmin | 297 ++++++++++++++---- 19 files changed, 511 insertions(+), 70 deletions(-) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/MANIFEST (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/Makefile.PL (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/README (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/lib/SCST/SCST.pm (99%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/01-start-scst.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/02-scst-attr.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/03-targets.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/04-alua.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/05-dynattr.t (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10/t/after-restore.conf => scst-1.0.0/t/06-after-restore.conf} (100%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/06-cont-on-err.t (93%) rename scstadmin/scstadmin.sysfs/{scst-0.9.10/t/to-be-restored.conf => scst-1.0.0/t/06-to-be-restored.conf} (100%) create mode 100644 scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-result.conf create mode 100644 scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t rename scstadmin/scstadmin.sysfs/{scst-0.9.10 => scst-1.0.0}/t/99-stop-scst.t (100%) create mode 100644 scstadmin/scstadmin.sysfs/scst-1.0.0/t/after-restore.conf create mode 100644 scstadmin/scstadmin.sysfs/scst-1.0.0/t/to-be-restored.conf diff --git a/scstadmin/scstadmin.sysfs/Makefile b/scstadmin/scstadmin.sysfs/Makefile index 3a41eeb89..c728831ec 100644 --- a/scstadmin/scstadmin.sysfs/Makefile +++ b/scstadmin/scstadmin.sysfs/Makefile @@ -2,7 +2,7 @@ ifndef PREFIX PREFIX=/usr/local endif -MODULE_VERSION = 0.9.10 +MODULE_VERSION = 1.0.0 TOOL = scstadmin SBINDIR := $(PREFIX)/sbin @@ -13,18 +13,20 @@ install install_vendor: all $(MAKE) -C scst-$(MODULE_VERSION) $@ DESTDIR=$(DESTDIR) install -d $(DESTDIR)$(SBINDIR) install -m 755 $(TOOL) $(DESTDIR)$(SBINDIR) + regex="s|%INSTALLSITELIB%|$$(make -sC scst-$(MODULE_VERSION) print-INSTALLSITELIB | grep -v ^make)|"; echo "$${regex}"; sed -i "$${regex}" $(DESTDIR)$(SBINDIR)/$(TOOL) uninstall: -rm -f $(DESTDIR)$(SBINDIR)/$(TOOL) $(MAKE) -C scst-$(MODULE_VERSION) uninstall perl-module: - @cd ./scst-$(MODULE_VERSION); \ - perl Makefile.PL PREFIX=$(PREFIX); + @cd ./scst-$(MODULE_VERSION) && \ + perl Makefile.PL PREFIX=$(PREFIX) && \ + printf '\nprint-%%:\n\t@echo '"'"'$$($$*)'"'"'\n' >> Makefile $(MAKE) -C scst-$(MODULE_VERSION) test: - $(MAKE) -C scst-$(MODULE_VERSION) test + $(MAKE) -C scst-$(MODULE_VERSION) test #TEST_VERBOSE=1 clean: -$(MAKE) -C scst-$(MODULE_VERSION) clean diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/MANIFEST b/scstadmin/scstadmin.sysfs/scst-1.0.0/MANIFEST similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/MANIFEST rename to scstadmin/scstadmin.sysfs/scst-1.0.0/MANIFEST diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/Makefile.PL b/scstadmin/scstadmin.sysfs/scst-1.0.0/Makefile.PL similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/Makefile.PL rename to scstadmin/scstadmin.sysfs/scst-1.0.0/Makefile.PL diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/README b/scstadmin/scstadmin.sysfs/scst-1.0.0/README similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/README rename to scstadmin/scstadmin.sysfs/scst-1.0.0/README diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm similarity index 99% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm rename to scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index 2eb5055e2..6bef8619b 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -289,7 +289,7 @@ use vars qw(@ISA @EXPORT $VERSION); use vars qw($TGT_TYPE_HARDWARE $TGT_TYPE_VIRTUAL); -$VERSION = '0.9.10'; +$VERSION = '1.0.0'; $TGT_TYPE_HARDWARE = 1; $TGT_TYPE_VIRTUAL = 2; @@ -2224,7 +2224,7 @@ sub addLun { my $o_string = ""; foreach my $attribute (keys %{$attributes}) { my $value = $$attributes{$attribute}; - $o_string .= "$attribute=$value; "; + $o_string .= "$attribute=$value;"; } $o_string =~ s/\s$//; @@ -2415,7 +2415,7 @@ sub replaceLun { my $o_string = ""; foreach my $attribute (keys %{$attributes}) { my $value = $$attributes{$attribute}; - $o_string .= "$attribute=$value; "; + $o_string .= "$attribute=$value;"; } $o_string =~ s/\s$//; @@ -4135,7 +4135,7 @@ sub openDevice { my $o_string = ""; foreach my $attribute (keys %{$attributes}) { my $value = $$attributes{$attribute}; - $o_string .= "$attribute=$value; "; + $o_string .= "$attribute=$value;"; } $o_string =~ s/\s$//; diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/01-start-scst.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/01-start-scst.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/01-start-scst.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/02-scst-attr.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/02-scst-attr.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/02-scst-attr.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/03-targets.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/03-targets.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/03-targets.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/04-alua.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/04-alua.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/04-alua.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/05-dynattr.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/05-dynattr.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/05-dynattr.t diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-after-restore.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/after-restore.conf rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-after-restore.conf diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-cont-on-err.t similarity index 93% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-cont-on-err.t index ada3d17a4..c91b85c7e 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/06-cont-on-err.t +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-cont-on-err.t @@ -64,6 +64,6 @@ die("Creation of SCST object failed") if (!defined($SCST)); setup($SCST); -testRestoreConfig(File::Spec->catfile($testdir, "to-be-restored.conf"), - File::Spec->catfile($testdir, "after-restore.conf")); +testRestoreConfig(File::Spec->catfile($testdir, "06-to-be-restored.conf"), + File::Spec->catfile($testdir, "06-after-restore.conf")); diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-to-be-restored.conf similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/to-be-restored.conf rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/06-to-be-restored.conf diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-result.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-result.conf new file mode 100644 index 000000000..8bee55a95 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-result.conf @@ -0,0 +1,38 @@ +# Automatically generated by SCST Configurator v... + + +HANDLER vdisk_fileio { + DEVICE disk0 { + filename /dev/scstadmin-regression-test-vdisk + read_only 1 + } + + DEVICE disk1 { + filename /dev/scstadmin-regression-test-vdisk + nv_cache 1 + } +} + +HANDLER vdisk_nullio { + DEVICE nodev { + dummy 1 + } +} + +TARGET_DRIVER scst_local { + TARGET local { + LUN 0 nodev + + GROUP ig { + LUN 0 disk0 { + read_only 1 + } + LUN 1 disk1 + + INITIATOR ini1 + + INITIATOR ini2 + } + } +} + diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t new file mode 100644 index 000000000..352481b90 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/07-scstadmin-args.t @@ -0,0 +1,97 @@ +#!perl + +use strict; +use Cwd qw(abs_path); +use File::Basename; +use File::Spec; +use Test; + +my $testdir; +my $scstadmin_pm_dir; +my $scstadmin_dir; +my $scstadmin; +my $redirect_file = "/tmp/07-output.txt"; +my $redirect; + +BEGIN { + unlink($redirect_file); + $testdir = dirname(abs_path($0)); + $scstadmin_pm_dir = dirname($testdir); + $scstadmin_dir = dirname($scstadmin_pm_dir); + $scstadmin = File::Spec->catfile($scstadmin_dir, "scstadmin"); + unless(grep /blib/, @INC) { + unshift(@INC, File::Spec->catdir($scstadmin_pm_dir, "lib")); + } + plan tests => 2; +} + +use Data::Dumper; +use SCST::SCST; +use File::Temp qw/tempfile/; + +sub setup { + my $SCST = shift; + + my ($drivers, $errorString) = $SCST->drivers(); + my %drivers = map { $_ => 1 } @{$drivers}; + ok(exists($drivers{'scst_local'})); + system("dd if=/dev/zero of=/dev/scstadmin-regression-test-vdisk bs=1M count=1 >/dev/null 2>&1"); +} + +sub teardown { + system("rm -f /dev/scstadmin-regression-test-vdisk"); +} + +sub attributeTest { + my $expected = shift; + my $tmpfilename1 = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-07-$$-1"); + my $tmpfilename2 = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-07-$$-2"); + my $diff = File::Spec->catfile(File::Spec->tmpdir(), + "scstadmin-test-07-$$-diff"); + + system("$scstadmin -clear_config -force -noprompt -no_lip $redirect"); + system("$scstadmin -open_dev nodev -handler vdisk_nullio -attributes dummy=1 $redirect"); + system("$scstadmin -open_dev disk0 -handler vdisk_fileio -attributes filename=/dev/scstadmin-regression-test-vdisk,read_only=1 $redirect"); + system("$scstadmin -open_dev disk1 -handler vdisk_fileio -attributes filename=/dev/scstadmin-regression-test-vdisk,nv_cache=1 $redirect"); + system("$scstadmin -driver scst_local -add_target local $redirect"); + system("$scstadmin -driver scst_local -target local " . + "-add_lun 0 -device nodev $redirect"); + system("$scstadmin -driver scst_local -target local -add_group ig " . + "$redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_init ini1 $redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_init ini2 $redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_lun 0 -device disk0 $redirect"); + system("$scstadmin -driver scst_local -target local -group ig " . + "-add_lun 1 -device disk1 $redirect"); + system("$scstadmin -write_config $tmpfilename1 >/dev/null"); + system("awk 'BEGIN { t = 0 } /^# Automatically generated by SCST Configurator v/ { \$0 = \"# Automatically generated by SCST Configurator v...\" } /^TARGET_DRIVER.*{\$/ { if (\$0 != \"TARGET_DRIVER scst_local {\") t = 1 } /^}\$/ { if (t == 1) t = 2 } /^\$/ { if (t == 2) { t = 3 } } /^./ { if (t == 3) { t = 0 } } { if (t == 0) print }' <$tmpfilename1 >$tmpfilename2"); + my $compare_result = system("diff -u $tmpfilename2 $expected >$diff"); + ok($compare_result, 0); + if ($compare_result == 0) { + unlink($tmpfilename2); + unlink($tmpfilename1); + } +} + +my $_DEBUG_ = 0; +if ($_DEBUG_) { + $redirect = ">>$redirect_file"; + open(my $logfile, '>>', $redirect_file); + select $logfile; +} else { + $redirect = ">/dev/null"; +} + +my $SCST = eval { new SCST::SCST($_DEBUG_) }; +die("Creation of SCST object failed") if (!defined($SCST)); + +setup($SCST); + +attributeTest(File::Spec->catfile($testdir, "07-result.conf")); + +teardown(); diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/t/99-stop-scst.t b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/99-stop-scst.t similarity index 100% rename from scstadmin/scstadmin.sysfs/scst-0.9.10/t/99-stop-scst.t rename to scstadmin/scstadmin.sysfs/scst-1.0.0/t/99-stop-scst.t diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/t/after-restore.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/after-restore.conf new file mode 100644 index 000000000..8f5291be5 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/after-restore.conf @@ -0,0 +1,60 @@ +# Automatically generated by SCST Configurator v... + + +HANDLER vdisk_fileio { + DEVICE disk01 { + filename /proc/cpuinfo + } +} + +TARGET_DRIVER scst_local { + TARGET local1 { + session_name local1_session + + LUN 0 disk01 + LUN 1 disk01 + + GROUP group_without_luns_with_attrs { + + addr_method FLAT + } + + GROUP initiator_group { + LUN 0 disk01 + LUN 1 disk01 { + read_only 1 + } + LUN 2 disk01 + + INITIATOR ini1 + + INITIATOR ini2 + + INITIATOR ini3 + } + } +} + +DEVICE_GROUP dg01 { + DEVICE disk01 + + TARGET_GROUP tg01a { + group_id 1 + preferred 1 + state active + + TARGET tgt_a { + rel_tgt_id 2 + } + } + + TARGET_GROUP tg01b { + group_id 2 + state active + + TARGET tgt_b { + rel_tgt_id 3 + } + } +} + diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/t/to-be-restored.conf b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/to-be-restored.conf new file mode 100644 index 000000000..9e56bc187 --- /dev/null +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/t/to-be-restored.conf @@ -0,0 +1,67 @@ +# Automatically generated by SCST Configurator v3.0.0-pre2. + + +HANDLER vdisk_fileio { + DEVICE disk01 { + filename /proc/cpuinfo + } +} + +TARGET_DRIVER ib_srpt { + TARGET no_such_target { + enabled 1 + } +} + +TARGET_DRIVER scst_local { + TARGET local1 { + session_name local1_session + + LUN 0 disk01 + LUN 1 disk01 + + GROUP initiator_group { + LUN 0 disk01 + LUN 1 disk01 { + read_only 1 + } + LUN 2 disk01 + + INITIATOR ini1 + + INITIATOR ini2 + + INITIATOR ini3 + } + + GROUP group_without_luns_with_attrs { + + addr_method FLAT + } + } +} + +DEVICE_GROUP dg01 { + DEVICE disk01 + + TARGET_GROUP tg01a { + group_id 1 + preferred 1 + state active + + TARGET tgt_a { + rel_tgt_id 2 + } + } + + TARGET_GROUP tg01b { + group_id 2 + preferred 0 + state active + + TARGET tgt_b { + rel_tgt_id 3 + } + } +} + diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 4a5b4556c..b6bac0e8d 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -204,8 +204,10 @@ Target Driver Operations -issue_lip [] [-driver ] : Issue a LIP for a specific driver/target or for all drivers and targets. - -no_lip : Don\'t automatically issue a LIP after applying + -lip : Issue a LIP after having applied FC configuration changes. + -no_lip : Don\'t automatically issue a LIP after having + applied FC configuration changes. Options -nonkey : When writing a config file or listing attributes, @@ -240,12 +242,27 @@ Examples: EndUsage } -use SCST::SCST 0.9.10; +use strict; +use Cwd qw(abs_path); +use File::Basename; +use File::Spec; +use Test; + +BEGIN { + my $site_lib = '%INSTALLSITELIB%'; + if ($site_lib =~ '^%') { + my $scstadmindir = dirname(abs_path($0)); + $site_lib = File::Spec->catdir($scstadmindir, "scst-1.0.0", + "blib", "lib"); + } + unshift(@INC, $site_lib); +} + +use SCST::SCST 1.0.0; use Getopt::Long; use IO::File; use IO::Dir; use POSIX; -use strict; my $_DEF_CONFIG_ = '/etc/scst.conf'; @@ -349,6 +366,7 @@ sub getArgs { my $enableTarget; my $disableTarget; my $issueLip; + my $lip; my $noLip; my $handler; @@ -444,6 +462,7 @@ sub getArgs { 'enable_target=s' => \$enableTarget, 'disable_target=s' => \$disableTarget, 'issue_lip:s' => \$issueLip, + 'lip' => \$lip, 'no_lip' => \$noLip, 'handler=s' => \$handler, @@ -478,9 +497,10 @@ sub getArgs { $_NOPROMPT_ = TRUE if (defined($_NOPROMPT_)); $_CONT_ON_ERR_ = TRUE if (defined($_CONT_ON_ERR_)); - $force = TRUE if (defined($force)); + $force = TRUE if (defined($force)); $nonkey = TRUE if (defined($nonkey)); - $noLip = TRUE if (defined($noLip)); + $lip = TRUE if (defined($lip)); + $noLip = TRUE if (defined($noLip)); my $query_mode = defined($listHandler) || defined($listDevice) || defined($listDeviceGroup) || defined($listTargetGroup) || defined($listDriver) || defined($listTarget) || defined($listGroup) || defined($listSessions) || @@ -707,25 +727,104 @@ sub getArgs { } } - return ($applyConfig, $clearConfig, $writeConfig, $checkConfig, - $listScstAttr, $listHandler, $listDevice, $listDeviceGroup, $listTargetGroup, $listDriver, $listTarget, $listGroup, - $listSessions, $listHandlerAttr, $listDeviceAttr, $listDriverAttr, $listTargetAttr, - $listDeviceGroupAttr, $listTargetGroupAttr, $listTargetGroupTargetAttr, - $listGroupAttr, $listLunAttr, $listInitiatorAttr, $setScstAttr, $setHandlerAttr, - $setDeviceAttr, $setDriverAttr, $setTargetAttr, $setGroupAttr, $setLunAttr, $setInitiatorAttr, - $setDeviceGroupAttr, $setTargetGroupAttr, $setTargetGroupTargetAttr, - $addDriverAttr, $addTargetAttr, $remDriverAttr, $remTargetAttr, - $openDev, $closeDev, $resyncDev, - $addDevGroup, $removeDevGroup, $addDevGroupDevice, $removeDevGroupDevice, - $addTargetGroup, $removeTargetGroup, $addTargetGroupTarget, $removeTargetGroupTarget, - $addTarget, $removeTarget, - $addGroup, $removeGroup, - $addInitiator, $removeInitiator, $moveInitiator, $clearInitiators, - $addLun, $removeLun, $replaceLun, $clearLuns, - $enableTarget, $disableTarget, $issueLip, $noLip, - $handler, \%_attributes, - $driver, $target, $group, $to, $device,, $deviceGroup, $targetGroup, - $nonkey, $force); + my %args = ( + applyConfig => $applyConfig, + clearConfig => $clearConfig, + writeConfig => $writeConfig, + checkConfig => $checkConfig, + + listScstAttr => $listScstAttr, + listHandler => $listHandler, + listDevice => $listDevice, + listDeviceGroup => $listDeviceGroup, + listTargetGroup => $listTargetGroup, + listDriver => $listDriver, + listTarget => $listTarget, + listGroup => $listGroup, + + listSessions => $listSessions, + listHandlerAttr => $listHandlerAttr, + listDeviceAttr => $listDeviceAttr, + listDriverAttr => $listDriverAttr, + listTargetAttr => $listTargetAttr, + + listDeviceGroupAttr => $listDeviceGroupAttr, + listTargetGroupAttr => $listTargetGroupAttr, + listTargetGroupTargetAttr => $listTargetGroupTargetAttr, + + listGroupAttr => $listGroupAttr, + listLunAttr => $listLunAttr, + listInitiatorAttr => $listInitiatorAttr, + setScstAttr => $setScstAttr, + setHandlerAttr => $setHandlerAttr, + + setDeviceAttr => $setDeviceAttr, + setDriverAttr => $setDriverAttr, + setTargetAttr => $setTargetAttr, + setGroupAttr => $setGroupAttr, + setLunAttr => $setLunAttr, + setInitiatorAttr => $setInitiatorAttr, + + setDeviceGroupAttr => $setDeviceGroupAttr, + setTargetGroupAttr => $setTargetGroupAttr, + setTargetGroupTargetAttr => $setTargetGroupTargetAttr, + + addDriverAttr => $addDriverAttr, + addTargetAttr => $addTargetAttr, + remDriverAttr => $remDriverAttr, + remTargetAttr => $remTargetAttr, + + openDev => $openDev, + closeDev => $closeDev, + resyncDev => $resyncDev, + + addDevGroup => $addDevGroup, + removeDevGroup => $removeDevGroup, + addDevGroupDevice => $addDevGroupDevice, + removeDevGroupDevice => $removeDevGroupDevice, + + addTargetGroup => $addTargetGroup, + removeTargetGroup => $removeTargetGroup, + addTargetGroupTarget => $addTargetGroupTarget, + removeTargetGroupTarget => $removeTargetGroupTarget, + + addTarget => $addTarget, + removeTarget => $removeTarget, + + addGroup => $addGroup, + removeGroup => $removeGroup, + + addInitiator => $addInitiator, + removeInitiator => $removeInitiator, + moveInitiator => $moveInitiator, + clearInitiators => $clearInitiators, + + addLun => $addLun, + removeLun => $removeLun, + replaceLun => $replaceLun, + clearLuns => $clearLuns, + + enableTarget => $enableTarget, + disableTarget => $disableTarget, + issueLip => $issueLip, + lip => $lip, + noLip => $noLip, + + handler => $handler, + attributes => \%_attributes, + + driver => $driver, + target => $target, + group => $group, + to => $to, + device => $device, + deviceGroup => $deviceGroup, + targetGroup => $targetGroup, + + nonkey => $nonkey, + force => $force, + ); + return \%args; } sub main { @@ -736,25 +835,103 @@ sub main { # We need to run as root if ( $> ) {die("This program must run as root.\n");} - my ($applyConfig, $clearConfig, $writeConfig, $checkConfig, - $listScstAttr, $listHandler, $listDevice, $listDeviceGroup, $listTargetGroup, $listDriver, $listTarget, $listGroup, - $listSessions, $listHandlerAttr, $listDeviceAttr, $listDriverAttr, $listTargetAttr, - $listDeviceGroupAttr, $listTargetGroupAttr, $listTargetGroupTargetAttr, - $listGroupAttr, $listLunAttr, $listInitiatorAttr, $setScstAttr, $setHandlerAttr, - $setDeviceAttr, $setDriverAttr, $setTargetAttr, $setGroupAttr, $setLunAttr, $setInitiatorAttr, - $setDeviceGroupAttr, $setTargetGroupAttr, $setTargetGroupTargetAttr, - $addDriverAttr, $addTargetAttr, $remDriverAttr, $remTargetAttr, - $openDev, $closeDev, $resyncDev, - $addDevGroup, $removeDevGroup, $addDevGroupDevice, $removeDevGroupDevice, - $addTargetGroup, $removeTargetGroup, $addTargetGroupTarget, $removeTargetGroupTarget, - $addTarget, $removeTarget, - $addGroup, $removeGroup, - $addInitiator, $removeInitiator, $moveInitiator, $clearInitiators, - $addLun, $removeLun, $replaceLun, $clearLuns, - $enableTarget, $disableTarget, $issueLip, $noLip, - $handler, $attributes, - $driver, $target, $group, $to, $device, $deviceGroup, $targetGroup, - $nonkey, $force) = getArgs(); + my $args = getArgs(); + + my $applyConfig = $args->{applyConfig}; + my $clearConfig = $args->{clearConfig}; + my $writeConfig = $args->{writeConfig}; + my $checkConfig = $args->{checkConfig}; + + my $listScstAttr = $args->{listScstAttr}; + my $listHandler = $args->{listHandler}; + my $listDevice = $args->{listDevice}; + my $listDeviceGroup = $args->{listDeviceGroup}; + my $listTargetGroup = $args->{listTargetGroup}; + my $listDriver = $args->{listDriver}; + my $listTarget = $args->{listTarget}; + my $listGroup = $args->{listGroup}; + + my $listSessions = $args->{listSessions}; + my $listHandlerAttr = $args->{listHandlerAttr}; + my $listDeviceAttr = $args->{listDeviceAttr}; + my $listDriverAttr = $args->{listDriverAttr}; + my $listTargetAttr = $args->{listTargetAttr}; + + my $listDeviceGroupAttr = $args->{listDeviceGroupAttr}; + my $listTargetGroupAttr = $args->{listTargetGroupAttr}; + my $listTargetGroupTargetAttr = $args->{listTargetGroupTargetAttr}; + + my $listGroupAttr = $args->{listGroupAttr}; + my $listLunAttr = $args->{listLunAttr}; + my $listInitiatorAttr = $args->{listInitiatorAttr}; + my $setScstAttr = $args->{setScstAttr}; + my $setHandlerAttr = $args->{setHandlerAttr}; + + my $setDeviceAttr = $args->{setDeviceAttr}; + my $setDriverAttr = $args->{setDriverAttr}; + my $setTargetAttr = $args->{setTargetAttr}; + my $setGroupAttr = $args->{setGroupAttr}; + my $setLunAttr = $args->{setLunAttr}; + my $setInitiatorAttr = $args->{setInitiatorAttr}; + + my $setDeviceGroupAttr = $args->{setDeviceGroupAttr}; + my $setTargetGroupAttr = $args->{setTargetGroupAttr}; + my $setTargetGroupTargetAttr = $args->{setTargetGroupTargetAttr}; + + my $addDriverAttr = $args->{addDriverAttr}; + my $addTargetAttr = $args->{addTargetAttr}; + my $remDriverAttr = $args->{remDriverAttr}; + my $remTargetAttr = $args->{remTargetAttr}; + + my $openDev = $args->{openDev}; + my $closeDev = $args->{closeDev}; + my $resyncDev = $args->{resyncDev}; + + my $addDevGroup = $args->{addDevGroup}; + my $removeDevGroup = $args->{removeDevGroup}; + my $addDevGroupDevice = $args->{addDevGroupDevice}; + my $removeDevGroupDevice = $args->{removeDevGroupDevice}; + + my $addTargetGroup = $args->{addTargetGroup}; + my $removeTargetGroup = $args->{removeTargetGroup}; + my $addTargetGroupTarget = $args->{addTargetGroupTarget}; + my $removeTargetGroupTarget = $args->{removeTargetGroupTarget}; + + my $addTarget = $args->{addTarget}; + my $removeTarget = $args->{removeTarget}; + + my $addGroup = $args->{addGroup}; + my $removeGroup = $args->{removeGroup}; + + my $addInitiator = $args->{addInitiator}; + my $removeInitiator = $args->{removeInitiator}; + my $moveInitiator = $args->{moveInitiator}; + my $clearInitiators = $args->{clearInitiators}; + + my $addLun = $args->{addLun}; + my $removeLun = $args->{removeLun}; + my $replaceLun = $args->{replaceLun}; + my $clearLuns = $args->{clearLuns}; + + my $enableTarget = $args->{enableTarget}; + my $disableTarget = $args->{disableTarget}; + my $issueLip = $args->{issueLip}; + my $lip = $args->{lip}; + my $noLip = $args->{noLip}; + + my $handler = $args->{handler}; + my $attributes = $args->{attributes}; + + my $driver = $args->{driver}; + my $target = $args->{target}; + my $group = $args->{group}; + my $to = $args->{to}; + my $device = $args->{device}; + my $deviceGroup = $args->{deviceGroup}; + my $targetGroup = $args->{targetGroup}; + + my $nonkey = $args->{nonkey}; + my $force = $args->{force}; $SCST = new SCST::SCST($_DEBUG_); @@ -770,7 +947,7 @@ sub main { condExit("Configuration has errors, aborting.") if ($rc); last if ($force && prompt()); my $changes = applyConfiguration($force); - $rc = issueLip() if ($changes && !$noLip); + $rc = issueLip() if ($changes && $lip); last SWITCH; }; defined($checkConfig) && do { @@ -786,7 +963,7 @@ sub main { defined($clearConfig) && do { last if (prompt()); $rc = clearConfiguration(); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); last SWITCH; }; defined($listHandler) && do { @@ -945,14 +1122,14 @@ sub main { defined($addDriverAttr) && do { print "\n-> Making requested changes.\n"; $rc = addDriverDynamicAttributes($addDriverAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; defined($addTargetAttr) && do { print "\n-> Making requested changes.\n"; $rc = addTargetDynamicAttributes($driver, $addTargetAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -960,7 +1137,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeDriverDynamicAttributes($remDriverAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -968,7 +1145,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeTargetDynamicAttributes($driver, $remTargetAttr, $attributes); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -982,14 +1159,14 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = closeDevice($handler, $closeDev, $force); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; defined($resyncDev) && do { print "\n-> Making requested changes.\n"; $rc = resyncDevice($resyncDev); - $rc = issueLip() if (!$rc && !$noLip); + $rc = issueLip() if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1051,7 +1228,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeVirtualTarget($driver, $removeTarget); - $rc = issueLip($driver) if (!$rc && !$noLip); + $rc = issueLip($driver) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1071,7 +1248,7 @@ sub main { defined($addInitiator) && do { print "\n-> Making requested changes.\n"; $rc = addInitiator($driver, $target, $group, $addInitiator); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1079,7 +1256,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeInitiator($driver, $target, $group, $removeInitiator); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1087,7 +1264,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = moveInitiator($driver, $target, $group, $moveInitiator, $to); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1095,14 +1272,14 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearInitiators($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; defined($addLun) && do { print "\n-> Making requested changes.\n"; $rc = addLun($driver, $target, $device, $addLun, $attributes, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1110,7 +1287,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = removeLun($driver, $target, $removeLun, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1118,7 +1295,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = replaceLun($driver, $target, $group, $replaceLun, $device, $attributes); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; }; @@ -1126,7 +1303,7 @@ sub main { last if (prompt()); print "\n-> Making requested changes.\n"; $rc = clearLuns($driver, $target, $group); - $rc = issueLip($driver, $target) if (!$rc && !$noLip); + $rc = issueLip($driver, $target) if (!$rc && $lip); print "\t-> Done.\n"; last SWITCH; };