From a0ce0340d0f95514008cfac751fe58748bbadd88 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 20 Mar 2008 00:04:16 +0000 Subject: * Switched indent used in Perl-code and settings files from tabs to 4 spaces. May need some manual corrections here and there, but should basically be ok. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1658 95ad53e4-c205-0410-b2fa-d234c58c8868 --- os-plugins/slxos-plugin | 470 ++++++++++++++++++++++++------------------------ 1 file changed, 235 insertions(+), 235 deletions(-) (limited to 'os-plugins/slxos-plugin') diff --git a/os-plugins/slxos-plugin b/os-plugins/slxos-plugin index 4f242ad1..e94be5d4 100755 --- a/os-plugins/slxos-plugin +++ b/os-plugins/slxos-plugin @@ -37,22 +37,22 @@ use OpenSLX::Utils; my %option; GetOptions( - 'help|?' => \$option{helpReq}, - 'man' => \$option{manReq}, - 'verbose' => \$option{verbose}, - 'version' => \$option{versionReq}, - ) + 'help|?' => \$option{helpReq}, + 'man' => \$option{manReq}, + 'verbose' => \$option{verbose}, + 'version' => \$option{versionReq}, +) or pod2usage(2); pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $option{helpReq}; if ($option{manReq}) { - # avoid dubious problem with perldoc in combination with UTF-8 that - # leads to strange dashes and single-quotes being used - $ENV{LC_ALL} = 'POSIX'; - pod2usage(-verbose => 2); + # avoid dubious problem with perldoc in combination with UTF-8 that + # leads to strange dashes and single-quotes being used + $ENV{LC_ALL} = 'POSIX'; + pod2usage(-verbose => 2); } if ($option{versionReq}) { - system('slxversion'); - exit 1; + system('slxversion'); + exit 1; } openslxInit(); @@ -60,239 +60,239 @@ openslxInit(); my $action = shift @ARGV || ''; if ($action =~ m[^list-at]i) { - my $plugin = shift @ARGV; - print - $plugin - ? _tr("List of attributes supported by '%s' plugin:\n", $plugin) - : _tr("List of plugin attributes:\n"); - my $attrs = {}; - require OpenSLX::OSPlugin::Roster; - OpenSLX::OSPlugin::Roster->addAllAttributesToHash($attrs, $plugin); - print join( - '', - map { - my $attr = $attrs->{$_}; - my $stage - = $attr->{applies_to_vendor_os} ? '[stage 1]' : '[stage 3]'; - - if ($option{verbose}) { - my $output; - my $fill = ' ' x 28; - for my $key (qw( description content_descr content_regex )) { - $output .= "\n\t $key:" . ( ' ' x (15 - length($key)) ); - chomp(my $value = $attr->{$key} || ''); - $value =~ s{\n}{\n$fill}igms; - $output .= $value; - } - "\n\t$stage: $_$output\n"; - } - else { - "\t$stage: $_\n"; - } - } - sort { - my $stageDiff - = ($attrs->{$b}->{applies_to_vendor_os} || '') - cmp ($attrs->{$a}->{applies_to_vendor_os} || ''); - return $stageDiff ? $stageDiff : $a cmp $b; - } - keys %$attrs - ); + my $plugin = shift @ARGV; + print + $plugin + ? _tr("List of attributes supported by '%s' plugin:\n", $plugin) + : _tr("List of plugin attributes:\n"); + my $attrs = {}; + require OpenSLX::OSPlugin::Roster; + OpenSLX::OSPlugin::Roster->addAllAttributesToHash($attrs, $plugin); + print join( + '', + map { + my $attr = $attrs->{$_}; + my $stage + = $attr->{applies_to_vendor_os} ? '[stage 1]' : '[stage 3]'; + + if ($option{verbose}) { + my $output; + my $fill = ' ' x 28; + for my $key (qw( description content_descr content_regex )) { + $output .= "\n\t $key:" . ( ' ' x (15 - length($key)) ); + chomp(my $value = $attr->{$key} || ''); + $value =~ s{\n}{\n$fill}igms; + $output .= $value; + } + "\n\t$stage: $_$output\n"; + } + else { + "\t$stage: $_\n"; + } + } + sort { + my $stageDiff + = ($attrs->{$b}->{applies_to_vendor_os} || '') + cmp ($attrs->{$a}->{applies_to_vendor_os} || ''); + return $stageDiff ? $stageDiff : $a cmp $b; + } + keys %$attrs + ); } elsif ($action =~ m[^list-av]i) { - print _tr("List of available plugins:\n"); - require OpenSLX::OSPlugin::Roster; - my $pluginInfo = OpenSLX::OSPlugin::Roster->getAvailablePlugins(); - print join( - '', - map { - if ($option{verbose}) { - my $fill = ' ' x 12; - chomp(my $descr = $pluginInfo->{$_}->{description} || ''); - $descr =~ s{\n}{\n$fill}igms; - "\n\t$_\n\t $descr\n"; - } - else { - "\t$_\n"; - } - } - sort keys %$pluginInfo - ); + print _tr("List of available plugins:\n"); + require OpenSLX::OSPlugin::Roster; + my $pluginInfo = OpenSLX::OSPlugin::Roster->getAvailablePlugins(); + print join( + '', + map { + if ($option{verbose}) { + my $fill = ' ' x 12; + chomp(my $descr = $pluginInfo->{$_}->{description} || ''); + $descr =~ s{\n}{\n$fill}igms; + "\n\t$_\n\t $descr\n"; + } + else { + "\t$_\n"; + } + } + sort keys %$pluginInfo + ); } elsif ($action =~ m[^list-i]i) { - if (scalar(@ARGV) != 1) { - print STDERR _tr( - "You need to specify exactly one vendor-OS!\n" - ); - pod2usage(2); - } - my $vendorOSName = shift @ARGV; - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - # create OSPlugin-engine for given vendor-OS and ask it for the installed - # plugins: - my $engine = OpenSLX::OSPlugin::Engine->new; - $engine->initialize(undef, $vendorOSName); - my @installedPlugins = $engine->getInstalledPlugins(); - - if (!@installedPlugins) { - push @installedPlugins, { plugin_name => '' }; - } - print _tr("List of plugins installed in vendor-OS '$vendorOSName':\n"); - print join( - '', - map { - if ($option{verbose}) { - my $attributes - = _tr("The following attributes were applied:") - . "\n\t "; - my $attrs = $_->{attrs}; - my $attrInfo = {}; - OpenSLX::OSPlugin::Roster->addAllStage1AttributesToHash( - $attrInfo, $_->{plugin_name} - ); - $attributes .= join( - "\n\t ", - map { - my $stage - = $attrInfo->{$_}->{applies_to_vendor_os} - ? '[stage 1]' - : '[stage 3]'; - "$stage $_=" - . (defined $attrs->{$_} ? $attrs->{$_} : '-') - } - sort { - (($attrInfo->{$b}->{applies_to_vendor_os} || '') - cmp ($attrInfo->{$a}->{applies_to_vendor_os} || '')) - || ($a cmp $b); - } - keys %$attrs - ); - "\n\t$_->{plugin_name}\n\t $attributes\n"; - } - else { - "\t$_->{plugin_name}\n"; - } - } - sort @installedPlugins - ); + if (scalar(@ARGV) != 1) { + print STDERR _tr( + "You need to specify exactly one vendor-OS!\n" + ); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + # create OSPlugin-engine for given vendor-OS and ask it for the installed + # plugins: + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize(undef, $vendorOSName); + my @installedPlugins = $engine->getInstalledPlugins(); + + if (!@installedPlugins) { + push @installedPlugins, { plugin_name => '' }; + } + print _tr("List of plugins installed in vendor-OS '$vendorOSName':\n"); + print join( + '', + map { + if ($option{verbose}) { + my $attributes + = _tr("The following attributes were applied:") + . "\n\t "; + my $attrs = $_->{attrs}; + my $attrInfo = {}; + OpenSLX::OSPlugin::Roster->addAllStage1AttributesToHash( + $attrInfo, $_->{plugin_name} + ); + $attributes .= join( + "\n\t ", + map { + my $stage + = $attrInfo->{$_}->{applies_to_vendor_os} + ? '[stage 1]' + : '[stage 3]'; + "$stage $_=" + . (defined $attrs->{$_} ? $attrs->{$_} : '-') + } + sort { + (($attrInfo->{$b}->{applies_to_vendor_os} || '') + cmp ($attrInfo->{$a}->{applies_to_vendor_os} || '')) + || ($a cmp $b); + } + keys %$attrs + ); + "\n\t$_->{plugin_name}\n\t $attributes\n"; + } + else { + "\t$_->{plugin_name}\n"; + } + } + sort @installedPlugins + ); } elsif ($action =~ m[^install]i) { - if (scalar(@ARGV) < 2) { - print STDERR _tr( - "You need to specify a vendor-OS and at least one plugin-name!\n" - ); - pod2usage(2); - } - my $vendorOSName = shift @ARGV; - my $pluginAttrs = parsePluginAttrs(1); - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - for my $pluginName (keys %$pluginAttrs) { - # create & start OSPlugin-engine for vendor-OS and current plugin: - my $engine = OpenSLX::OSPlugin::Engine->new; - $engine->initialize( - $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} - ); - if (!-e $engine->{'plugin-path'}) { - die _tr("plugin '%s' doesn't exist, giving up!\n", - $engine->{'plugin-path'}); - } - if ($vendorOSName ne '<<>>' - && !-e $engine->{'vendor-os-path'}) { - die _tr( - "vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'} - ); - } - if ($engine->installPlugin()) { - print _tr( - "Plugin $pluginName has been installed into vendor-OS '$vendorOSName'.\n" - ); - } - } + if (scalar(@ARGV) < 2) { + print STDERR _tr( + "You need to specify a vendor-OS and at least one plugin-name!\n" + ); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + my $pluginAttrs = parsePluginAttrs(1); + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + for my $pluginName (keys %$pluginAttrs) { + # create & start OSPlugin-engine for vendor-OS and current plugin: + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize( + $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} + ); + if (!-e $engine->{'plugin-path'}) { + die _tr("plugin '%s' doesn't exist, giving up!\n", + $engine->{'plugin-path'}); + } + if ($vendorOSName ne '<<>>' + && !-e $engine->{'vendor-os-path'}) { + die _tr( + "vendor-OS '%s' doesn't exist, giving up!\n", + $engine->{'vendor-os-path'} + ); + } + if ($engine->installPlugin()) { + print _tr( + "Plugin $pluginName has been installed into vendor-OS '$vendorOSName'.\n" + ); + } + } } elsif ($action =~ m[^remove]i) { - if (scalar(@ARGV) < 2) { - print STDERR _tr( - "You need to specify a vendor-OS and at least one plugin-name!\n" - ); - pod2usage(2); - } - my $vendorOSName = shift @ARGV; - my $pluginAttrs = parsePluginAttrs(0); - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - for my $pluginName (keys %$pluginAttrs) { - # create & start OSPlugin-engine for vendor-OS and current plugin: - my $engine = OpenSLX::OSPlugin::Engine->new; - $engine->initialize( - $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} - ); - if (!-e $engine->{'plugin-path'}) { - die _tr("plugin '%s' doesn't exist, giving up!\n", - $engine->{'plugin-path'}); - } - if ($vendorOSName ne '<<>>' && !-e $engine->{'vendor-os-path'}) { - die _tr("vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'}); - } - if ($engine->removePlugin()) { - print _tr( - "Plugin $pluginName has been removed from vendor-OS '$vendorOSName'.\n" - ); - } - } + if (scalar(@ARGV) < 2) { + print STDERR _tr( + "You need to specify a vendor-OS and at least one plugin-name!\n" + ); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + my $pluginAttrs = parsePluginAttrs(0); + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + for my $pluginName (keys %$pluginAttrs) { + # create & start OSPlugin-engine for vendor-OS and current plugin: + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize( + $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} + ); + if (!-e $engine->{'plugin-path'}) { + die _tr("plugin '%s' doesn't exist, giving up!\n", + $engine->{'plugin-path'}); + } + if ($vendorOSName ne '<<>>' && !-e $engine->{'vendor-os-path'}) { + die _tr("vendor-OS '%s' doesn't exist, giving up!\n", + $engine->{'vendor-os-path'}); + } + if ($engine->removePlugin()) { + print _tr( + "Plugin $pluginName has been removed from vendor-OS '$vendorOSName'.\n" + ); + } + } } else { - vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0)); - You need to specify exactly one action: - install [= ...] - list-attributes [] - list-available - list-installed - remove - Try '%s --help' for more info. - END-OF-HERE + vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0)); + You need to specify exactly one action: + install [= ...] + list-attributes [] + list-available + list-installed + remove + Try '%s --help' for more info. + END-OF-HERE } sub parsePluginAttrs { - my $acceptAttributes = shift; - - my (%pluginAttrs, $pluginName, @attrSpecs); - for my $arg (@ARGV) { - if ($arg =~ m{^(.+)=(.*)$}) { - next if !$acceptAttributes; - my $attr = $1; - my $value = $2; - if ($value =~ m{^(-|undef)$}) { - $value = undef; - } - if ($attr =~ m{^(.+)::}) { - $pluginName = $1; - } - else { - if (!defined $pluginName) { - die _tr('You have to give a plugin-name before you can specify unscoped attributes!'); - } - $attr = $pluginName . '::' . $attr; - } - $pluginAttrs{$pluginName}->{$attr} = $value; - } - else { - $pluginName = $arg; - $pluginAttrs{$pluginName} = {}; - } - } - return \%pluginAttrs; + my $acceptAttributes = shift; + + my (%pluginAttrs, $pluginName, @attrSpecs); + for my $arg (@ARGV) { + if ($arg =~ m{^(.+)=(.*)$}) { + next if !$acceptAttributes; + my $attr = $1; + my $value = $2; + if ($value =~ m{^(-|undef)$}) { + $value = undef; + } + if ($attr =~ m{^(.+)::}) { + $pluginName = $1; + } + else { + if (!defined $pluginName) { + die _tr('You have to give a plugin-name before you can specify unscoped attributes!'); + } + $attr = $pluginName . '::' . $attr; + } + $pluginAttrs{$pluginName}->{$attr} = $value; + } + else { + $pluginName = $arg; + $pluginAttrs{$pluginName} = {}; + } + } + return \%pluginAttrs; } =head1 NAME -- cgit v1.2.3-55-g7522