I must be missing something here so I'm asking for more eyes on something.
I built a fairly simple straightforward module here and yet it is failing to work. This module does curls to an API (The Foreman) to extract some data from it. Nothing fancy here.... Here are the most important bits:
The one and only script using it (so far) is complaining:package NCS::PuppetDB::Data; use 5.010000; use strict; use warnings; use JSON; our $curl="/usr/bin/curl -G 'http://localhost:8080/v3"; our $VERSION = '0.5.2'; sub new { my $self={}; bless $self,"NCS::PupptDB::Data"; return $self; } sub getHosts { my $self = shift; my $cmd=sprintf("%s/nodes 2>/dev/null",$curl); my $json = JSON->new->allow_nonref; my $jsonData=`$cmd`; my $decoded = $json->decode($jsonData); my $retval=[]; for my $entry(@$decoded){ push @$retval,$entry->{name}; } return sort $retval; } sub getHostFacts { my $self = shift; my $host = shift; my $cmd=sprintf("%s/nodes/%s/facts' 2>/dev/null",$curl,$host); my $json = JSON->new->allow_nonref; my $jsonData=`$cmd`; my $decoded = $json->decode($jsonData); my $retval = {}; for my $fact(@$decoded){ $retval->{$fact->{name}} = $fact->{value}; } return $retval; } sub getFact { my ($self,$host,$factname)=@_; my $facts=getHostFacts($host); return $facts->{$factname}; } 1;
What am I missing?Can't locate object method "getHosts" via package "NCS::PupptDB::Data"
In reply to Need a second set of eyes: Very odd failure by blue_cowdawg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |