This file is indexed.

/usr/share/perl5/App/ClusterSSH/Cluster.pm is in clusterssh 4.01.01-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package App::ClusterSSH::Cluster;

use strict;
use warnings;

use version;
our $VERSION = version->new('0.01');

use Carp;
use Try::Tiny;

use base qw/ App::ClusterSSH::Base /;

our $master_object_ref;

sub new {
    my ( $class, %args ) = @_;

    if ( !$master_object_ref ) {
        $master_object_ref = $class->SUPER::new(%args);
    }

    return $master_object_ref;
}

sub get_clusters {
    my ( $self, @files ) = @_;

    for my $file ( '/etc/clusters', @files ) {
        $self->debug(3, 'Loading in config from: ', $file);
        $self->read_cluster_file($file);
    }

    return $self;
}

sub read_cluster_file {
    my ( $self, $filename ) = @_;
    $self->debug( 2, 'Reading clusters from file ', $filename );

    if ( -f $filename ) {
        open( my $fh, '<', $filename )
            || croak(
            App::ClusterSSH::Exception::Cluster->throw(
                error => $self->loc(
                    'Unable to read file [_1]: [_2]',
                    $filename, $!
                )
            )
            );

        my $line;
        while ( defined( $line = <$fh> ) ) {
            next
                if ( $line =~ /^\s*$/ || $line =~ /^#/ )
                ;    # ignore blank lines & commented lines
            chomp $line;
            if ( $line =~ s/\\\s*$// ) {
                $line .= <$fh>;
                redo unless eof($fh);
            }
            my @line = split( /\s+/, $line );

        #s/^([\w-]+)\s*//;               # remote first word and stick into $1

            $self->debug( 3, "read line: $line" );
            $self->register_tag(@line);
        }

        close($fh);
    }
    else {
        $self->debug( 2, 'No file found to read');
    }
    return $self;
}

sub register_tag {
    my ( $self, $tag, @nodes ) = @_;

    $self->debug( 2, "Registering tag $tag: ", join( ' ', @nodes ) );

    $self->{$tag} = \@nodes;

    return $self;
}

sub get_tag {
    my ( $self, $tag ) = @_;

    if ( $self->{$tag} ) {
        $self->debug( 2, "Retrieving tag $tag: ",
            join( ' ', $self->{$tag} ) );

        return @{ $self->{$tag} };
    }

    $self->debug( 2, "Tag $tag is not registered" );
    return;
}

sub list_tags {
    my ($self) = @_;
    return keys(%$self);
}

#use overload (
#    q{""} => sub {
#        my ($self) = @_;
#        return $self->{hostname};
#    },
#    fallback => 1,
#);

1;

=pod

=head1 NAME

App::ClusterSSH::Cluster - Object representing cluster configuration

=head1 SYNOPSIS

=head1 DESCRIPTION

Object representing application configuration

=head1 METHODS

=over 4

=item $cluster=ClusterSSH::Cluster->new();

Create a new object.  Object should be common across all invocations.

=item $cluster->get_clusters($filename);

Read in /etc/clusters and any other given file name and register the tags found.

=item $cluster->read_cluster_file($filename);

Read in the given cluster file and register the tags found

=item $cluster->register_tag($tag,@hosts);

Register the given tag name with the given host names.

=item @entries = $cluster->get_tag('tag');

Retrieve all entries for the given tag

=item @tags = $cluster->list_tags();

Return an array of all available tag names

=back

=head1 AUTHOR

Duncan Ferguson, C<< <duncan_j_ferguson at yahoo.co.uk> >>

=head1 LICENSE AND COPYRIGHT

Copyright 1999-2010 Duncan Ferguson.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

=cut

1;