view release on metacpan or search on metacpan
* Updated usb.ids to 2017.07.29 version
* Updated storage inventory on MacOS supporting Firewire storages: #309 #310
* Fixes on dmidecode memory inventory: #320
* Update memory component capacity on virtual systems: #339
* Fix lenovo system information product name read from dmidecode: fix #311
* Include TL in AIX OS version: #328
* Fix Xen vm with space in name not colleted: #176
netdiscovery/netinventory:
* Bump NetDiscovery & NetInventory task version to 2.3
* Fix credentials option support
* Fixed duplicated mac addresses: #315
* Also accept LLDP notifications on sysName
* Force MANUFACTURER to match real vendor, VENDOR inventory key removed
* Better cleanup of canonical strings with invalid characters
* Support more alternate mac address formats
* Fix some string field encoding
* Support Digi devices serial
* Support ups model oid
* Fixed Juniper serial retrieval
* Enhanced Konica printer discovery
2.3.9 Tue, 15 Jul 2014
core:
* disable lower-level SSL checks when no-ssl-checks is used
netinventory and netdiscovery tasks:
* merge all files from sysobjectid database into a single one
* update sysobjectid database
netdiscovery task:
* catch more SNMPv3 authentication errors
* allow multiple SNMP credentials for netdiscovery executable
netinventory task:
* better printer consumable identification, using vendor references
(#2581,#2582,#2583,#2584,#2587,#2589,#2591,#2592,#2593,#2594)
* externalize consumable ids in a data file
* report 0% level instead of 100% for wastetoners with OK status (#2593)
* skip problematic address only for non-existing interfaces (#2599)
* mark --model option as deprecated for netinventory executable
inventory task:
core:
* abort with explicit error message when there is
no available task
* when receiving a push request from a server, reschedule
contact for this server only
inventory task:
* fix a warning with LXC 1.0.x
netinventory task:
* fix SNMPv3 credentials handling
* fix mac address retrieval on non-default VLANs
* fix LLDP info retrieval for some hardware
* fix memory exhaustion for some hardware (#2414)
* use get-next-requests instead of get-bulk-requests, slower but safer,
especially with large gaps in indexes
netdiscovery task:
* fix SNMPv3 credentials handling
* do not report errors for non-responding host with SNMPv3
wake-on-lan task
* honour all mac addresses from server request (#2353)
test suite:
* fix network interface test on Solaris (#2438)
2.3.5.1 Tue, 14 Jan 2014
inventory task:
* handle MAC addresses with embedded VLAN identifier
netdiscovery task
* backport device model identification from sysobjectid value
2.3.2 Fri, 20 Sep 2013
core
* avoid some warning messages
netinventory task
* fix: properly pass the SNMP credentials
* better handling of mac addresses
2.3.1 Mon, 09 Sep 2013
inventory task
* report when running in a BSD Jail or a LXC system, thanks Igor Morozov
* better strategy for extracting USB printer serial on windows (#2213)
* force lowercase identifiers for USB and PCI lookups (#2122)
netdiscovery task
* fix invalid log message and spurious warnings during discovery (#2200)
bin/fusioninventory-netdiscovery view on Meta::CPAN
our $options = {
debug => 0,
threads => 1
};
GetOptions(
$options,
'first=s',
'last=s',
'community=s@',
'credentials=s@',
'entity=s',
'port=s@',
'protocol=s@',
'threads=i',
'timeout=i',
'control',
'debug+',
'help',
'inventory|i',
'save|s=s',
bin/fusioninventory-netdiscovery view on Meta::CPAN
pod2usage(
-message => "\nsave folder must exist, aborting\n", -verbose => 0
) if ($options->{save} && ! -d $options->{save});
my $discovery = FusionInventory::Agent::Task::NetDiscovery->new(
%setup,
target => FusionInventory::Agent::Task::NetInventory::Target->new(),
logger => FusionInventory::Agent::Logger->new(config => $options)
);
my $credentials_id = 1;
our @credentials;
if ($options->{community}) {
foreach my $community (@{$options->{community}}) {
push @credentials,
{ ID => $credentials_id++, VERSION => 1, COMMUNITY => $community };
}
} elsif ($options->{credentials}) {
foreach my $specification (@{$options->{credentials}}) {
my $credential = { ID => $credentials_id++ };
foreach my $parameter (split(',', $specification)) {
my ($key, $value) = split(':', $parameter);
$credential->{uc($key)} = $value;
}
push @credentials, $credential;
}
} else {
push @credentials, {
ID => $credentials_id++, VERSION => 1, COMMUNITY => 'public'
};
}
$discovery->{jobs} = [
FusionInventory::Agent::Task::NetDiscovery::Job->new(
logger => $discovery->{logger},
params => {
PID => 1,
THREADS_DISCOVERY => $options->{threads},
TIMEOUT => $options->{timeout},
},
ranges => [
{
ID => 1,
IPSTART => $options->{first},
IPEND => $options->{last},
PORT => $options->{port},
PROTOCOL => $options->{protocol},
}
],
credentials => \@credentials
)
];
if (defined($options->{entity})) {
$discovery->{jobs}->[0]->{ranges}->[0]->{ENTITY} = $options->{entity};
}
$discovery->{client} = FusionInventory::Agent::Task::NetDiscovery::Client->new(
logger => $discovery->{logger},
);
if ($options->{save} && $options->{debug}) {
bin/fusioninventory-netdiscovery view on Meta::CPAN
if ($options->{save} && $device) {
die "No ip given with device\n" unless $ip;
if ($self->netdiscovery()) {
$self->{logger}->info("Saving $ip discovery infos as XML...");
_writeXml($options->{save} . "/netdiscovery", "$ip.xml", $xml);
} else {
if ($device->{ERROR}) {
my $message = $device->{ERROR}->{MESSAGE};
$self->{logger}->error("Inventory failed on $message");
$self->{logger}->error("Check your credentials") if $message =~ /timeout/;
} else {
$self->{logger}->info("Saving $ip inventory infos as XML...");
_writeXml($options->{save} . "/netinventory", "$ip.xml", $xml);
}
}
} else {
print $xml;
}
if ($self->netdiscovery() && $options->{inventory} && $device) {
bin/fusioninventory-netdiscovery view on Meta::CPAN
THREADS_QUERY => 1,
TIMEOUT => $options->{timeout},
},
devices => [{
ID => 0,
IP => $ip,
PORT => $options->{port},
PROTOCOL => $options->{protocol},
AUTHSNMP_ID => $device->{AUTHSNMP}
}],
credentials => \@{main::credentials},
)
];
$inventory->{client} = FusionInventory::Agent::Task::NetInventory::Client->new(
logger => $self->{logger},
ip => $ip
);
$inventory->run();
}
bin/fusioninventory-netdiscovery view on Meta::CPAN
=head1 SYNOPSIS
fusioninventory-netdiscovery [options] --first <address> --last <address>
Options:
--first <ADDRESS> IP range first address
--last <ADDRESS> IP range last address
--port <PORT[,PORT2]> SNMP port (161)
--protocol <PROT[,P2]> SNMP protocol/domain (udp/ipv4)
--community <STRING> SNMP community string (public)
--credentials <STRING> SNMP credentials (version:1,community:public)
--timeout <TIME SNMP timeout, in seconds (1)
--entity <ENTITY> GLPI entity
--threads <COUNT> number of discovery threads (1)
--control output control messages
-i --inventory chain with netinventory task for discovered devices
-s --save <FOLDER> base folder where to save discovery and inventory xmls
- netdiscovery xmls will go in <FOLDER>/netdiscovery
- netinventory xmls will go in <FOLDER>/netinventory
--debug debug output
-h --help print this message and exit
bin/fusioninventory-netdiscovery view on Meta::CPAN
=item B<--protocol> I<PROTOCOL[,PROTOCOL2]>
List of protocols to try, defaults to: udp/ipv4
Possible values are: udp/ipv4,udp/ipv6,tcp/ipv4,tcp/ipv6
=item B<--community> I<STRING>
Use given string as SNMP community (assume SNMPv1).
=item B<--credentials> I<STRING>
Use given string as SNMP credentials specification. This specification is a
comma-separated list of key:value authentication parameters, such as:
=over
=item * version:2c,community:public
=item * version:3,username:admin,authprotocol:sha,authpassword:s3cr3t
=item * etc.
bin/fusioninventory-netdiscovery view on Meta::CPAN
=back
=head1 EXAMPLES
Run a discovery against a network range, using SNMP version 1:
$> fusioninventory-netdiscovery --first 192.168.0.1 --last 192.168.0.254 \
--community public
Run a discovery against a network range, using multiple SNMP credentials:
$> fusioninventory-netdiscovery --first 192.168.0.1 --last 192.168.0.254 \
--credentials version:2c,community:public \
--credentials version:3,username:admin,authprotocol:sha,authpassword:s3cr3t
bin/fusioninventory-netinventory view on Meta::CPAN
threads => 1
};
GetOptions(
$options,
'model=s',
'type=s',
'host=s@',
'file=s@',
'community=s',
'credentials=s',
'port=s@',
'protocol=s@',
'threads=i',
'timeout=i',
'control',
'debug+',
'help',
'version',
) or pod2usage(-verbose => 0);
bin/fusioninventory-netinventory view on Meta::CPAN
push @devices, {
ID => $id++,
IP => $_,
PORT => shift @{$options->{port}},
PROTOCOL => shift @{$options->{protocol}},
AUTHSNMP_ID => 1,
MODELSNMP_ID => 1
} foreach @{$options->{host}};
}
my $credentials = { ID => 1 };
if ($options->{type}) {
pod2usage(
-message => "invalid type '$options->{type}', aborting\n",
-verbose => 0
) unless any { $options->{type} eq $_ } values %types;
map { $_->{TYPE} = $options->{type} } @devices;
}
if ($options->{community}) {
$credentials->{COMMUNITY} = $options->{community};
} elsif (defined $options->{credentials}) {
foreach my $parameter (split(',', $options->{credentials})) {
my ($key, $value) = split(':', $parameter);
my $newkey =
$key eq 'authpassword' ? 'AUTHPASSPHRASE' :
$key eq 'privpassword' ? 'PRIVPASSPHRASE' :
uc($key);
$credentials->{$newkey} = $value;
}
} else {
$credentials->{COMMUNITY} = 'public';
}
my $inventory = FusionInventory::Agent::Task::NetInventory->new(
%setup,
target => FusionInventory::Agent::Task::NetInventory::Target->new(),
logger => FusionInventory::Agent::Logger->new(config => $options)
);
$inventory->{jobs} = [
FusionInventory::Agent::Task::NetInventory::Job->new(
params => {
PID => 1,
THREADS_QUERY => $options->{threads},
TIMEOUT => $options->{timeout},
},
devices => \@devices,
credentials => [ $credentials ]
)
];
$inventory->{client} =
FusionInventory::Agent::Task::NetInventory::Client->new(
control => $options->{control}
);
$inventory->run();
bin/fusioninventory-netinventory view on Meta::CPAN
=head1 SYNOPSIS
fusioninventory-netinventory [options] [--host <host>|--file <file>]
Options:
--host <HOST> target host
--port <PORT[,PORT2]> SNMP port (161)
--protocol <PROT[,P2]> SNMP protocol/domain (udp/ipv4)
--file <FILE> snmpwalk output file
--community <STRING> community string (public)
--credentials <STRING> SNMP credentials (version:1,community:public)
--timeout <TIME> SNMP timeout, in seconds (15)
--type <TYPE> force device type
--threads <COUNT> number of inventory threads (1)
--control output control messages
--debug debug output
-h --help print this message and exit
--version print the task version and exit
=head1 DESCRIPTION
bin/fusioninventory-netinventory view on Meta::CPAN
=item B<--file> I<FILE>
Run an offline inventory against snmpwalk output, stored in given file.
Multiple usage allowed, for multiple files.
=item B<--communty> I<STRING>
Use given string as SNMP community (assume SNMPv1)
=item B<--credentials> I<STRING>
Use given string as SNMP credentials specification. This specification is a
comma-separated list of key:value authentication parameters, such as:
=over
=item * version:2c,community:public
=item * version:3,username:admin,authprotocol:sha,authpassword:s3cr3t
=item * etc.
bin/fusioninventory-netinventory view on Meta::CPAN
Turn the debug mode on. Multiple usage allowed, for additional verbosity.
=back
=head1 EXAMPLES
Run an inventory against a network device, using SNMP version 2c authentication:
$> fusioninventory-netinventory --host 192.168.0.1 \
--credentials version:2c,community:public
Run an inventory against a network device, using SNMP version 3 authentication
and forcing its type:
$> fusioninventory-netinventory --host my.device --type NETWORKING \
--credentials version:3,username:admin,authprotocol:sha,authpassword:s3cr3t
lib/FusionInventory/Agent/HTTP/Client.pm view on Meta::CPAN
alarm 0;
};
# check result first
if (!$result->is_success()) {
# authentication required
if ($result->code() == 401) {
if ($self->{user} && $self->{password}) {
$logger->debug(
$log_prefix .
"authentication required, submitting credentials"
);
# compute authentication parameters
my $header = $result->header('www-authenticate');
my ($realm) = $header =~ /^Basic realm="(.*)"/;
my $host = $url->host();
my $port = $url->port() ||
($scheme eq 'https' ? 443 : 80);
$self->{ua}->credentials(
"$host:$port",
$realm,
$self->{user},
$self->{password}
);
# replay request
eval {
if ($OSNAME eq 'MSWin32' && $scheme eq 'https') {
alarm $self->{ua}->{timeout};
}
$result = $self->{ua}->request($request, $file);
alarm 0;
};
if (!$result->is_success()) {
$logger->error(
$log_prefix .
"authentication required, wrong credentials"
);
}
} else {
# abort
$logger->error(
$log_prefix .
"authentication required, no credentials available"
);
}
} elsif ($result->code() == 407) {
$logger->error(
$log_prefix .
"proxy authentication required, wrong or no proxy credentials"
);
} else {
# check we request through a proxy
my $proxyreq = defined $result->request->{proxy};
$logger->error(
$log_prefix .
($proxyreq ? "proxy" : "communication") .
" error: " . $result->status_line()
lib/FusionInventory/Agent/SOAP/VMware.pm view on Meta::CPAN
and _WITHOUT_ their Perl library.
=head1 METHODS
=head2 new(%params)
Returns a VMware object.
=head2 connect($user, $password)
Connect the VMware object with the given credentials.
=head2 getHostFullInfo($id)
Returns a large hash structure with the host information.
=head2 getHostIds()
Returns the list of the virtual machine ID in an array reference.
lib/FusionInventory/Agent/Task/NetDiscovery.pm view on Meta::CPAN
next;
}
if (!defined($params->{PID})) {
$self->{logger}->error("invalid job: no PID defined");
next;
}
push @jobs, FusionInventory::Agent::Task::NetDiscovery::Job->new(
logger => $self->{logger},
params => $params,
credentials => $option->{AUTHENTICATION},
ranges => \@ranges,
);
}
if (!@jobs) {
$self->{logger}->error("no valid job found, aborting");
return;
}
$self->{jobs} = \@jobs;
lib/FusionInventory/Agent/Task/NetDiscovery.pm view on Meta::CPAN
# Start jobs by preparing range queues and counting ips
my $max_count = 0;
foreach my $job (@{$self->{jobs}}) {
my $pid = $job->pid;
my $queue = {
max_in_queue => $job->max_threads(),
in_queue => 0,
timeout => $job->timeout(),
snmp_credentials => $job->getValidCredentials(),
};
my $size = 0;
my @list = ();
# process each address block
foreach my $range ($job->ranges()) {
my $start = $range->{start};
my $end = $range->{end};
my $block = Net::IP->new( "$start-$end" );
lib/FusionInventory/Agent/Task/NetDiscovery.pm view on Meta::CPAN
# Enqueue as ip as possible
foreach my $pid (@pids) {
my $queue = $queues{$pid};
next unless @{$queue->{list}};
next if $queue->{in_queue} >= $queue->{max_in_queue};
my $address = shift @{$queue->{list}};
# Update address hash with common parameters
$address->{pid} = $pid;
$address->{timeout} = $queue->{timeout};
$address->{snmp_credentials} = $queue->{snmp_credentials};
$address->{jid} = sprintf($jid_pattern, ++$job_count);
$queue->{in_queue} ++;
$jobs->enqueue($address);
$queued_count++;
}
# as long as some of our threads are still running...
if (keys(%running_threads)) {
# send available results on the fly
lib/FusionInventory/Agent/Task/NetDiscovery.pm view on Meta::CPAN
return %device;
}
sub _scanAddressBySNMP {
my ($self, $params) = @_;
my $tries = [];
if ($params->{snmp_ports} && @{$params->{snmp_ports}}) {
foreach my $port (@{$params->{snmp_ports}}) {
my @cases = map { { port => $port, credential => $_ } } @{$params->{snmp_credentials}};
push @{$tries}, @cases;
}
} else {
@{$tries} = map { { credential => $_ } } @{$params->{snmp_credentials}};
}
if ($params->{snmp_domains} && @{$params->{snmp_domains}}) {
my @domtries = ();
foreach my $domain (@{$params->{snmp_domains}}) {
foreach my $try (@{$tries}) {
$try->{domain} = $domain;
}
push @domtries, @{$tries};
}
$tries = \@domtries;
lib/FusionInventory/Agent/Task/NetDiscovery.pm view on Meta::CPAN
foreach my $try (@{$tries}) {
my $credential = $try->{credential};
my $device = $self->_scanAddressBySNMPReal(
ip => $params->{ip},
port => $try->{port},
domain => $try->{domain},
timeout => $params->{timeout},
credential => $credential
);
# no result means either no host, no response, or invalid credentials
$self->{logger}->debug(
sprintf "- scanning %s%s with SNMP%s, credentials %d: %s",
$params->{ip},
$try->{port} ? ':'.$try->{port} : '',
$try->{domain} ? ' '.$try->{domain} : '',
$credential->{ID},
ref $device eq 'HASH' ? 'success' :
$device ? "no result, $device" : 'no result'
);
if (ref $device eq 'HASH') {
$device->{AUTHSNMP} = $credential->{ID};
lib/FusionInventory/Agent/Task/NetDiscovery.pm view on Meta::CPAN
timeout => $params{timeout} || 1,
community => $params{credential}->{COMMUNITY},
username => $params{credential}->{USERNAME},
authpassword => $params{credential}->{AUTHPASSPHRASE},
authprotocol => $params{credential}->{AUTHPROTOCOL},
privpassword => $params{credential}->{PRIVPASSPHRASE},
privprotocol => $params{credential}->{PRIVPROTOCOL},
);
};
# an exception here just means no device or wrong credentials
return $EVAL_ERROR if $EVAL_ERROR;
my $info = getDeviceInfo(
snmp => $snmp,
datadir => $self->{datadir},
logger => $self->{logger},
);
return unless $info;
return $info;
lib/FusionInventory/Agent/Task/NetDiscovery/Job.pm view on Meta::CPAN
use English qw(-no_match_vars);
use FusionInventory::Agent::Logger;
sub new {
my ($class, %params) = @_;
my $self = {
logger => $params{logger} || FusionInventory::Agent::Logger->new(),
_params => $params{params},
_credentials => $params{credentials},
_ranges => $params{ranges},
};
bless $self, $class;
}
sub pid {
my ($self) = @_;
return $self->{_params}->{PID} || 0;
}
lib/FusionInventory/Agent/Task/NetDiscovery/Job.pm view on Meta::CPAN
end => $range->{IPEND},
};
}
return @ranges;
}
sub getValidCredentials {
my ($self) = @_;
my @credentials;
foreach my $credential (@{$self->{_credentials}}) {
if ($credential->{VERSION} eq '3') {
# a user name is required
next unless $credential->{USERNAME};
# DES support is required
next unless Crypt::DES->require();
} else {
next unless $credential->{COMMUNITY};
}
push @credentials, $credential;
}
return \@credentials;
}
sub _getSNMPPorts {
my ($ports) = @_;
return [] unless $ports;
# Given ports can be an array of strings or just a string and each string
# can be a comma separated list of ports
my @given_ports = map { split(/\s*,\s*/, $_) }
lib/FusionInventory/Agent/Task/NetInventory.pm view on Meta::CPAN
if (!@devices) {
$self->{logger}->error("invalid job: no valid device defined");
next;
}
my $params = $option->{PARAM}->[0];
push @jobs, FusionInventory::Agent::Task::NetInventory::Job->new(
logger => $self->{logger},
params => $params,
credentials => $option->{AUTHENTICATION},
devices => \@devices
);
}
if (!@jobs) {
$self->{logger}->error("no valid job found, aborting");
return;
}
$self->{jobs} = \@jobs;
lib/FusionInventory/Agent/Task/NetInventory.pm view on Meta::CPAN
$self->{logger}->debug(scalar(@really_running)." really running: [@really_running]");
$self->{logger}->debug(scalar(@started_threads)." started: [@started_threads]");
}
my %queues = ();
my $pid_index = 1;
# Start jobs by preparing queues
foreach my $job (@{$self->{jobs}}) {
# SNMP credentials
my $credentials = $job->credentials();
# set pid
my $pid = $job->pid() || $pid_index++;
# send initial message to server unless it supports newer protocol
$self->_sendStartMessage($pid) unless $skip_start_stop;
# prepare queue
my $queue = $queues{$pid} || {
max_in_queue => $job->max_threads(),
in_queue => 0,
todo => []
};
foreach my $device ($job->devices()) {
push @{$queue->{todo}}, {
pid => $pid,
device => $device,
timeout => $job->timeout(),
credentials => $credentials->{$device->{AUTHSNMP_ID}}
};
}
# Only keep queue if we have a device to scan
$queues{$pid} = $queue
if @{$queue->{todo}};
}
my $queued_count = 0;
my $job_count = 0;
lib/FusionInventory/Agent/Task/NetInventory.pm view on Meta::CPAN
$self->_sendMessage({
DEVICE => $result,
MODULEVERSION => $VERSION,
PROCESSNUMBER => $pid || 0
});
}
sub _queryDevice {
my ($self, $params) = @_;
my $credentials = $params->{credentials};
my $device = $params->{device};
my $logger = $self->{logger};
my $id = threads->tid();
$logger->{prefix} = "[thread $id] $params->{jid}, ";
$logger->debug(
"scanning $device->{ID}: $device->{IP}" .
( $device->{PORT} ? ' on port ' . $device->{PORT} : '' ) .
( $device->{PROTOCOL} ? ' via ' . $device->{PROTOCOL} : '' )
);
lib/FusionInventory/Agent/Task/NetInventory.pm view on Meta::CPAN
$snmp = FusionInventory::Agent::SNMP::Mock->new(
ip => $device->{IP},
file => $device->{FILE}
);
};
die "SNMP emulation error: $EVAL_ERROR" if $EVAL_ERROR;
} else {
eval {
FusionInventory::Agent::SNMP::Live->require();
$snmp = FusionInventory::Agent::SNMP::Live->new(
version => $credentials->{VERSION},
hostname => $device->{IP},
port => $device->{PORT},
domain => $device->{PROTOCOL},
timeout => $params->{timeout} || 15,
community => $credentials->{COMMUNITY},
username => $credentials->{USERNAME},
authpassword => $credentials->{AUTHPASSPHRASE},
authprotocol => $credentials->{AUTHPROTOCOL},
privpassword => $credentials->{PRIVPASSPHRASE},
privprotocol => $credentials->{PRIVPROTOCOL},
);
};
die "SNMP communication error: $EVAL_ERROR" if $EVAL_ERROR;
}
my $result = getDeviceFullInfo(
id => $device->{ID},
type => $device->{TYPE},
snmp => $snmp,
model => $params->{model},
lib/FusionInventory/Agent/Task/NetInventory/Job.pm view on Meta::CPAN
use English qw(-no_match_vars);
use FusionInventory::Agent::Logger;
sub new {
my ($class, %params) = @_;
my $self = {
logger => $params{logger} || FusionInventory::Agent::Logger->new(),
_params => $params{params},
_credentials => $params{credentials},
_devices => $params{devices},
};
bless $self, $class;
}
sub pid {
my ($self) = @_;
return $self->{_params}->{PID} || 0;
}
lib/FusionInventory/Agent/Task/NetInventory/Job.pm view on Meta::CPAN
my ($self) = @_;
return scalar(@{$self->{_devices}});
}
sub devices {
my ($self) = @_;
return @{$self->{_devices}};
}
sub credentials {
my ($self) = @_;
# index credentials by their ID
return { map { $_->{ID} => $_ } @{$self->{_credentials}} };
}
1;
lib/FusionInventory/Agent/Task/WMI.pm view on Meta::CPAN
if (!$content || !$content->{RESPONSE} || $content->{RESPONSE} ne 'SEND') {
if ($self->{config}->{force}) {
$self->{logger}->debug("WMI inventory task execution not requested, but execution forced");
} else {
$self->{logger}->debug("WMI inventory task execution not requested");
return 0;
}
}
# TODO: This is only a POC as nothing is implemented server-side and we need
# to safely pass credentials
my %connection = (
host => $response->getOptionsInfoByName('REMOTEHOST') || '',
user => $response->getOptionsInfoByName('REMOTEUSER') || '',
pass => $response->getOptionsInfoByName('REMOTEPASS') || ''
);
# 'host' parameter remains mandatory to enable any wmi inventory
return 0 unless $connection{host};
$self->{registry} = [ $response->getOptionsInfoByName('REGISTRY') ];
lib/FusionInventory/Agent/Tools/Win32.pm view on Meta::CPAN
return _call_win32_ole_dependent_api({
funct => 'getLastError',
array => 1,
args => []
});
}
my %known_ole_errors = (
scalar(0x80041003) => "Access denied as the current or specified user name and password were not valid or authorized to make the connection.",
scalar(0x8004100E) => "Invalid namespace",
scalar(0x80041064) => "User credentials cannot be used for local connections",
scalar(0x80070005) => "Access denied",
scalar(0x800706BA) => "The RPC server is unavailable",
);
sub _keepOleLastError {
my $lasterror = Win32::OLE->LastError();
if ($lasterror) {
my $error = 0x80000000 | ($lasterror & 0x7fffffff);
# Don't report not accurate and not failure error
t/agent/http/client/connection.t view on Meta::CPAN
check_response_ok(
$client,
"http://127.0.0.1:$port/public"
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
logger => $logger
);
} 'instanciation: http, auth, no credentials';
subtest "no response" => sub {
check_response_nok(
$client,
"http://127.0.0.1:$port/private",
$logger,
"[http client] authentication required, no credentials available",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
user => 'test',
password => 'test',
logger => $logger,
);
} 'instanciation: http, auth, with credentials';
subtest "correct response" => sub {
check_response_ok(
$client,
"http://127.0.0.1:$port/private"
);
};
$server->stop();
t/agent/http/client/connection.t view on Meta::CPAN
$client,
"https://127.0.0.1:$port/public"
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
logger => $logger,
no_ssl_check => 1,
);
} 'instanciation: https, check disabled, auth, no credentials';
subtest "no response" => sub {
check_response_nok(
$client,
"https://127.0.0.1:$port/private",
$logger,
"[http client] authentication required, no credentials available",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
user => 'test',
password => 'test',
logger => $logger,
no_ssl_check => 1,
);
} 'instanciation: https, check disabled, auth, credentials';
subtest "correct response" => sub {
check_response_ok(
$client,
"https://127.0.0.1:$port/private",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
t/agent/http/client/connection.t view on Meta::CPAN
$client,
"https://127.0.0.1:$port/public",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
logger => $logger,
ca_cert_file => 'resources/ssl/crt/ca.pem',
);
} 'instanciation: https, auth, no credentials';
subtest "no response" => sub {
check_response_nok(
$client,
"https://127.0.0.1:$port/private",
$logger,
"[http client] authentication required, no credentials available",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
user => 'test',
password => 'test',
logger => $logger,
ca_cert_file => 'resources/ssl/crt/ca.pem',
);
} 'instanciation: https, auth, credentials';
subtest "correct response" => sub {
check_response_ok(
$client,
"https://127.0.0.1:$port/private",
);
};
$server->stop();
}
t/agent/http/client/connection.t view on Meta::CPAN
$client,
"http://127.0.0.1:$port/public",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
logger => $logger,
proxy => $proxy->url()
);
} 'instanciation: http, proxy, auth, no credentials';
subtest "no response" => sub {
check_response_nok(
$client,
"http://127.0.0.1:$port/private",
$logger,
"[http client] authentication required, no credentials available",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
user => 'test',
password => 'test',
logger => $logger,
proxy => $proxy->url()
);
} 'instanciation: http, proxy, auth, credentials';
subtest "correct response" => sub {
check_response_ok(
$client,
"http://127.0.0.1:$port/private",
);
};
$server->stop();
t/agent/http/client/connection.t view on Meta::CPAN
"https://127.0.0.1:$port/public",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
logger => $logger,
no_ssl_check => 1,
proxy => $proxy->url()
);
} 'instanciation: https, check disabled, proxy, auth, no credentials';
subtest "no response" => sub {
check_response_nok(
$client,
"https://127.0.0.1:$port/private",
$logger,
"[http client] authentication required, no credentials available",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
user => 'test',
password => 'test',
logger => $logger,
no_ssl_check => 1,
proxy => $proxy->url()
);
} 'instanciation: https, check disabled, proxy, auth, credentials';
subtest "correct response" => sub {
check_response_ok(
$client,
"https://127.0.0.1:$port/private",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
t/agent/http/client/connection.t view on Meta::CPAN
"https://127.0.0.1:$port/public",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
logger => $logger,
ca_cert_file => 'resources/ssl/crt/ca.pem',
proxy => $proxy->url()
);
} 'instanciation: https, proxy, auth, no credentials';
subtest "no response" => sub {
check_response_nok(
$client,
"https://127.0.0.1:$port/private",
$logger,
"[http client] authentication required, no credentials available",
);
};
lives_ok {
$client = FusionInventory::Agent::HTTP::Client->new(
user => 'test',
password => 'test',
logger => $logger,
ca_cert_file => 'resources/ssl/crt/ca.pem',
proxy => $proxy->url()
);
} 'instanciation: https, proxy, auth, credentials';
subtest "correct response" => sub {
check_response_ok(
$client,
"https://127.0.0.1:$port/private",
);
};
$server->stop();
}