Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.143.222.84
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : Local.pm
package FusionInventory::Agent::Target::Local;

use strict;
use warnings;

use parent 'FusionInventory::Agent::Target';

my $count = 0;

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

    die "no path parameter for local target\n" unless $params{path};

    my $self = $class->SUPER::new(%params);

    $self->{path} = $params{path};

    $self->{format} = $params{html} ? 'html' :'xml';

    $self->_init(
        id     => 'local' . $count++,
        vardir => $params{basevardir} . '/__LOCAL__',
    );

    return $self;
}

sub reset {
    $count = 0;
}

sub getPath {
    my ($self) = @_;

    return $self->{path};
}

sub getName {
    my ($self) = @_;

    return $self->{path};
}

sub getType {
    my ($self) = @_;

    return 'local';
}

sub plannedTasks {
    my $self = shift @_;

    # Keep only inventory as local task
    if (@_) {
        $self->{tasks} = [ grep { $_ =~ /^Inventory$/i } @_ ];
    }

    return @{$self->{tasks} || []};
}

1;

__END__

=head1 NAME

FusionInventory::Agent::Target::Local - Local target

=head1 DESCRIPTION

This is a target for storing execution result in a local folder.

=head1 METHODS

=head2 new(%params)

The constructor. The following parameters are allowed, in addition to those
from the base class C<FusionInventory::Agent::Target>, as keys of the %params
hash:

=over

=item I<path>

the output directory path (mandatory)

=back

=head2 reset()

Reset the local target counter.

=head2 getPath()

Return the local output directory for this target.

=head2 getName()

Return the target name

=head2 getType()

Return the target type

=head2 plannedTasks([@tasks])

Initializes target tasks with supported ones if a list of tasks is provided

Return an array of planned tasks.
© 2025 GrazzMean