File: external_cluster_command

package info (click to toggle)
clusterssh 4.18-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 704 kB
  • sloc: perl: 4,309; sh: 178; makefile: 11
file content (50 lines) | stat: -rwxr-xr-x 948 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
#
# test script for proving external command for fetching tags works
#
use strict;
use warnings;
use Getopt::Std;

my $opt = {};
getopts( 'Lqx', $opt );

my %tag_lookup = (
    tag100 => [qw/ host100 /],
    tag200 => [qw/ host200 host210 host205 /],
    tag300 => [qw/ host300 host350 host325 /],
    tag400 => [qw/ tag100 tag200 tag300 host400 host401 /],
);

# if we get '-q' option, force an error
if ( $opt->{q} ) {
    my $fail;
    $fail->cause_death();
}

# if we get '-x' option, die with non-0 return code
if ( $opt->{x} ) {
    warn 'Forced non-0 exit', $/;
    exit 5;
}

# '-L' means list out available tags
if ( $opt->{L} ) {
    print join( ' ', sort keys %tag_lookup ), $/;
    exit 0;
}

my @lookup = @ARGV;

for (@lookup) {
    if ( $tag_lookup{$_} ) {
        push( @lookup, @{ $tag_lookup{$_} } );
        $_ = '';
    }
}

@lookup = grep { $_ !~ m/^$/ } sort @lookup;

if (@lookup) {
    print "@lookup", $/;
}