Recent Changes - Search:


Code:


Social:


My journals will take the place of a blog. If you go to the Journal page there is an RSS feed to subscribe with.

« September 2017 
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930

Sites I take responsibility for

West Volusia, Florida

Documents

Technical

General

Me

Living

Places I frequent

Hobbies

Humor

Items for sale:


Clipboard

edit SideBar

WebService::Linode

Include our styles below Infobox - invoke as >>infobox<< ... >><<

Codebox: - invoke as >>codebox<< ... >><<

warnbox: - invoke as >>codebox<< ... >><<

editingbox: - invoke as >>codebox<< ... >><<

noticebox: - invoke as >>codebox<< ... >><<

Page bread crumbs: Welcome to ke3vin.org! - My Public Technical Notes - Services - Linode Dot Com - AP Is - Web Service Linode

Pages by tags: (:listtags:)
Subscribe to this wiki: RSS Feed RSS or subscribe to this page for changes: RSS Feed RSS
496 articles have been published so far. Recent changes
Share

2016-03-22: This site is being moved to my main site at https://kevininscoe.com/wiki as part of a consolidation to one domain.


The Linode.com API documentation is here: http://www.linode.com/api/

Linode ticket 161973 (now ticket ):

There are errors in the documentation (or function since the documentation does not match the function) in Perl module http://search.cpan.org/~mikegrb/WebService-Linode/lib/WebService/Linode.pm-WebService::Linode.

 [161973] Can't locate object method "getDomainIDbyName" v
 Status 	OPEN
 Opened On 	2010-03-28 08:01:10 AM by kinsce2
 Last Updated On 	2010-03-28 02:56:50 PM by mgreb

shell script:

 setenv linode_api `/bin/cat /usr/local/admin/etc/linode`
 setenv public_ip `some routine to pull the public address from the NAT`

CPAN module:

http://search.cpan.org/~mikegrb/WebService-Linode/lib/WebService/Linode.pm

 Additional Helper Methods
          o getDomainIDbyName( domain => 'example.com' )
          o getDomainResourceIDbyName( domainid => 242, name => 'www') 

Perl script:

 
#!/usr/bin/perl -w

use WebService::Linode;

my $apikey = $ENV{'linode_api'};
die "error: environment variable linode_api is not set correctly." unless $apikey;
my $pubip = $ENV{'public_ip'};
die "error: environment variable public_ip is not set correctly." unless $pubip;

print "Public ip is $pubip\n";

if ( $pubip eq "" || $apikey eq "" ) {
        die "error: environment variables are not set correctly.";
}

my @domains = ('kevininscoe.com', 'unixforbusypeople.com');
my @Site1Names;
my $domain='';
my $record='';
my $domainid=0;
my $api;

foreach (@domains) {

        $domain = $_;
        print "Entering domain=$domain\n";

        if ( $domain eq "kevininscoe.com" ) {
                @Site1Names = ('site1', 'home.site1', 'proxy', 
            'svn', 'icecast', 'private', 'pub', 'lab.site1');
        } elsif ( $domain eq "unixforbusypeople.com" ) {
                @Site1Names = ('lab');
        } else {
                print "Unknown domain name $domain\n"; 
                @Site1Names = ('unknown');
        }

# Get the domainid needed by the API
        $api = new WebService::Linode(apikey => $apikey);
        $domainid = $api->getDomainIDbyName( domain => $domain );
#       die "Couldn't get domain id for $domain" unless $domainid;
#       print "DomainID for $domain is $domainid\n";

        foreach (@Site1Names) {

                $record = $_;
                print "Setting FQDN=$record.$domain\n";
                print "Domain=$domain, Record=$record\n";

                my $resourceid = $api->getResourceIDbyName(domain => $domain, name => $record);
#               die "Couldn't find RR id for $domain" unless $resourceid;

                $api->domainResourceUpdate(domainid => $domainid, 
                    resourceid => $resourceid, target => $pubip);
        }
}

Error produced:

 # set_linode_site1_dns.sh.orig   
 Public ip is n.n.n.n
 Entering domain=kevininscoe.com
 Setting FQDN=site1.kevininscoe.com
 Domain=kevininscoe.com, Record=site1
 Undefined subroutine &WebService::Linode::getResourceIDbyName called at 
       set_linode_site1_dns.pl.orig line 52

Mike Greb responds:

Hello Kevin,

Sorry I didn't catch it sooner, the helper is getDomainResourceIDbyName rather then getResourceIDbyName. Also, getDomainIDbyName takes just the domain, without key/value pairs.

Try this out:

 
--- urmomA.pl    2010-03-29 21:13:46.000000000 -0400
+++ urmomB.pl   2010-03-29 21:15:55.000000000 -0400
@@ -36,7 +36,7 @@

 # Get the domainid needed by the API
        $api = new WebService::Linode(apikey => $apikey);
-        $domainid = $api->getDomainIDbyName( domain => $domain );
+        $domainid = $api->getDomainIDbyName( $domain );
 #       die "Couldn't get domain id for $domain" unless $domainid;
 #       print "DomainID for $domain is $domainid\n";

@@ -46,7 +46,7 @@
                print "Setting FQDN=$record.$domain\n";
                print "Domain=$domain, Record=$record\n";

-                my $resourceid = $api->getResourceIDbyName(domain => $domain, name => $record);
+                my $resourceid = $api->getDomainResourceIDbyName(domain => $domain, name => $record);
 #               die "Couldn't find RR id for $domain" unless $resourceid;

                $api->domainResourceUpdate(domainid => $domainid, resourceid => $resourceid, 
                     target => $pubip);

Which now produces code:

 
#!/usr/bin/perl -w

use WebService::Linode;

my $apikey = $ENV{'linode_api'};
die "error: environment variable linode_api is not set correctly." unless $apikey;
my $pubip = $ENV{'public_ip'};
die "error: environment variable public_ip is not set correctly." unless $pubip;

print "Public ip is $pubip\n";

# Crusise all the domains
#my $api = new WebService::Linode(apikey => $apikey);

if ( $pubip eq "" || $apikey eq "" ) {
	die "error: environment variables are not set correctly.";
}

my @domains = ('kevininscoe.com', 'unixforbusypeople.com');
my @Site1Names;
my $domain='';
my $record='';
my $domainid=0;
my $api;

foreach (@domains) {

	$domain = $_;
	print "Entering domain=$domain\n";

	if ( $domain eq "kevininscoe.com" ) {
		@Site1Names = ('site1', 'home.site1', 'proxy', 'svn', 'icecast', 
                    'private', 'pub', 'lab.site1');
	} elsif ( $domain eq "unixforbusypeople.com" ) {
		@Site1Names = ('lab');
	} else {
 		print "Unknown domain name $domain\n"; 
		@Site1Names = ('unknown');
	}

# Get the domainid needed by the API
	$api = new WebService::Linode(apikey => $apikey);
#	$domainid = $api->getDomainIDbyName( domain => $domain );
	$domainid = $api->getDomainIDbyName( $domain );
#	die "Couldn't get domain id for $domain" unless $domainid;
#	print "DomainID for $domain is $domainid\n";

	foreach (@Site1Names) {

		$record = $_;
		print "Setting FQDN=$record.$domain\n";
		print "Domain=$domain, Record=$record\n";

#		my $resourceid = $api->getResourceIDbyName(domain => $domain, name => $record);
		my $resourceid = $api->getDomainResourceIDbyName(domain => $domain, name => $record);
#		die "Couldn't find RR id for $domain" unless $resourceid;

		$api->domainResourceUpdate(domainid => $domainid, 
                     resourceid => $resourceid, target => $pubip);
	}
}

Basically the call for getDomainIDbyName has changed from (domain => $domain) to just ($domain) but that does not match the documentation

<b>But I still get an error anyway when I make that code change</b>:

 Undefined subroutine 
    &WebService::Linode::domainResourceUpdate called at 
    set_linode_site1_dns.pl.orig line 57

So I am maintaining that the routine "domainResourceUpdate" does not exist in module WebService::Linode despite being advertised as such in the Perl module documentation. This should be corrected.


Kevin's Public Wiki maintained and created by Kevin P. Inscoe is licensed under a
Creative Commons Attribution 3.0 United States License.

Back to my web site - http://kevininscoe.com

Edit - History - Print - Recent Changes - Search
Page last modified on April 03, 2010, at 08:19 AM EST