Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'tag' support for NetDiscovery/NetInventory tasks #828

Closed
wants to merge 13 commits into from
15 changes: 10 additions & 5 deletions lib/GLPI/Agent/Inventory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -778,12 +778,17 @@ sub save {

my $xml = GLPI::Agent::XML->new();

my %request_params = (REQUEST => {
CONTENT => $self->getContent(),
DEVICEID => $self->getDeviceId(),
QUERY => "INVENTORY",
});
my $config = $self->{config} || GLPI::Agent::Config->new();
$request_params{REQUEST}{TAG} = $config->{tag}
if defined($config->{tag}) && length($config->{tag});

print $handle $xml->write({
REQUEST => {
CONTENT => $self->getContent(),
DEVICEID => $self->getDeviceId(),
QUERY => "INVENTORY",
}
%request_params
});

} elsif ($format eq 'html') {
Expand Down
8 changes: 7 additions & 1 deletion lib/GLPI/Agent/Task/NetDiscovery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,17 @@ sub _sendMessage {
# Load GLPI::Agent::XML::Query as late as possible
return unless GLPI::Agent::XML::Query->require();

my $message = GLPI::Agent::XML::Query->new(
my %message_params = (
deviceid => $self->{deviceid} || 'foo',
query => 'NETDISCOVERY',
content => $content
);
$message_params{tag} = $self->{config}->{'tag'}
if defined($self->{config}->{tag}) && length($self->{config}->{tag});

my $message = GLPI::Agent::XML::Query->new(
%message_params
);

if ($self->{target}->isType('local')) {
my ($handle, $file, $ip);
Expand Down
8 changes: 7 additions & 1 deletion lib/GLPI/Agent/Task/NetInventory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,17 @@ sub _sendMessage {
# Load GLPI::Agent::XML::Query as late as possible
return unless GLPI::Agent::XML::Query->require();

my $message = GLPI::Agent::XML::Query->new(
my %message_params = (
deviceid => $self->{deviceid} || 'foo',
query => 'SNMPQUERY',
content => $content
);
$message_params{tag} = $self->{config}->{'tag'}
if defined($self->{config}->{tag}) && length($self->{config}->{tag});

my $message = GLPI::Agent::XML::Query->new(
%message_params
);

if ($self->{target}->isType('local')) {
my ($handle, $file);
Expand Down
Loading