summaryrefslogtreecommitdiffstats
path: root/os-plugins/slxos-plugin
diff options
context:
space:
mode:
authorOliver Tappe2008-03-20 01:04:16 +0100
committerOliver Tappe2008-03-20 01:04:16 +0100
commita0ce0340d0f95514008cfac751fe58748bbadd88 (patch)
tree844bb9e015f2fbcd83de54c3a63dd027b1218211 /os-plugins/slxos-plugin
parent* fixed several bugs with respect to the listing of plugins (as part of a system (diff)
downloadcore-a0ce0340d0f95514008cfac751fe58748bbadd88.tar.gz
core-a0ce0340d0f95514008cfac751fe58748bbadd88.tar.xz
core-a0ce0340d0f95514008cfac751fe58748bbadd88.zip
* 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
Diffstat (limited to 'os-plugins/slxos-plugin')
-rwxr-xr-xos-plugins/slxos-plugin470
1 files changed, 235 insertions, 235 deletions
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 => '<none>' };
- }
- 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 => '<none>' };
+ }
+ 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 '<<<default>>>'
- && !-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 '<<<default>>>'
+ && !-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 '<<<default>>>' && !-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 '<<<default>>>' && !-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 <vendor-OS-name> <plugin-name> [<plugin-attr>=<value> ...]
- list-attributes [<plugin-name>]
- list-available
- list-installed <vendor-OS-name>
- remove <vendor-OS-name> <plugin-name>
- 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 <vendor-OS-name> <plugin-name> [<plugin-attr>=<value> ...]
+ list-attributes [<plugin-name>]
+ list-available
+ list-installed <vendor-OS-name>
+ remove <vendor-OS-name> <plugin-name>
+ 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