blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:
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"
Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; Blog: http://blog.berghold.net Warning: No political correctness allowed.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need a second set of eyes: Very odd failure
by haukex (Archbishop) on Nov 17, 2017 at 17:00 UTC | |
by blue_cowdawg (Monsignor) on Nov 17, 2017 at 17:13 UTC | |
by haukex (Archbishop) on Nov 18, 2017 at 10:36 UTC | |
by stevieb (Canon) on Nov 17, 2017 at 17:16 UTC | |
by karlgoethebier (Abbot) on Nov 17, 2017 at 17:32 UTC | |
Re: Need a second set of eyes: Very odd failure
by stevieb (Canon) on Nov 17, 2017 at 17:00 UTC | |
Re: Need a second set of eyes: Very odd failure
by karlgoethebier (Abbot) on Nov 17, 2017 at 17:21 UTC | |
Re: Need a second set of eyes: Very odd failure
by AnomalousMonk (Archbishop) on Nov 17, 2017 at 18:52 UTC | |
Re: Need a second set of eyes: Very odd failure
by RMGir (Prior) on Nov 17, 2017 at 19:35 UTC |
Back to
Seekers of Perl Wisdom